|
#ifndef R_H
|
|
#define R_H
|
|
#include "auth.h"
|
|
#include "utils.h"
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
bool is_verbose = true;
|
|
|
|
char *models_api_url = "https://api.openai.com/v1/models";
|
|
char *completions_api_url = "https://api.openai.com/v1/chat/completions";
|
|
char *advanced_model = "gpt-4o-mini";
|
|
char *fast_model = "gpt-3.5-turbo";
|
|
|
|
//char *models_api_url = "https://api.openai.com/v1/models";
|
|
//char *completions_api_url = "https://api.anthropic.com/v1/chat/completions";
|
|
//char *advanced_model = "claude-3-5-haiku-20241022";
|
|
//char *advanced_model = "meta-llama/Meta-Llama-3.1-8B-Instruct";
|
|
//char *advanced_model = "google/gemini-1.5-flash";
|
|
//char *fast_model = "claude-3-5-haiku-20241022";
|
|
|
|
//#endif
|
|
//#ifdef OLLAMA
|
|
//char *models_api_url = "https://ollama.molodetz.nl/v1/models";
|
|
//char *completions_api_url = "https://ollama.molodetz.nl/v1/chat/completions";
|
|
//char *advanced_model = "qwen2.5:3b";
|
|
//char *advanced_model = "qwen2.5-coder:0.5b";
|
|
//char *fast_model = "qwen2.5:0.5b";
|
|
//#endif
|
|
|
|
char *_model = NULL;
|
|
|
|
#define DB_FILE "~/.r.db"
|
|
#define PROMPT_TEMPERATURE 0.1
|
|
|
|
char * get_completions_api_url() {
|
|
if(getenv("R_BASE_URL") != NULL) {
|
|
return joinpath(getenv("R_BASE_URL"), "v1/chat/completions");
|
|
}
|
|
return completions_api_url;
|
|
}
|
|
char * get_models_api_url() {
|
|
if(getenv("R_BASE_URL") != NULL) {
|
|
return joinpath(getenv("R_BASE_URL"), "v1/models");
|
|
}
|
|
return models_api_url;
|
|
}
|
|
|
|
void set_prompt_model(const char *model) {
|
|
if (_model != NULL) {
|
|
free(_model);
|
|
}
|
|
_model = strdup(model);
|
|
}
|
|
|
|
const char *get_prompt_model() {
|
|
if(_model == NULL && getenv("R_MODEL") != NULL) {
|
|
_model = getenv("R_MODEL");
|
|
}
|
|
if(_model){
|
|
return _model;
|
|
}
|
|
if (auth_type != AUTH_TYPE_API_KEY) {
|
|
if (_model == NULL) {
|
|
_model = strdup(fast_model);
|
|
}
|
|
} else if (_model == NULL) {
|
|
_model = strdup(advanced_model);
|
|
}
|
|
return _model;
|
|
}
|
|
|
|
#endif
|