diff --git a/auth.h b/auth.h index cf32dd9..141f0ea 100644 --- a/auth.h +++ b/auth.h @@ -12,6 +12,13 @@ #include <stdlib.h> #include <stdio.h> +enum AUTH_TYPE { + AUTH_TYPE_API_KEY, + AUTH_TYPE_FREE +}; + +int auth_type = AUTH_TYPE_FREE; + const char *resolve_api_key() { static char *api_key = NULL; api_key = getenv("R_KEY"); @@ -20,6 +27,7 @@ const char *resolve_api_key() { } api_key = getenv("OPENAI_API_KEY"); if (api_key) { + auth_type = AUTH_TYPE_API_KEY; return api_key; } api_key = "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"; diff --git a/chat.h b/chat.h index c1df187..54e2437 100644 --- a/chat.h +++ b/chat.h @@ -31,14 +31,18 @@ #define R_PROMPT_H #include "tools.h" +#include "auth.h" #include <json-c/json.h> #include "messages.h" -#ifdef FREE_VERSION -static char *prompt_model = "gpt-3.5-turbo"; -#else -static char *prompt_model = "gpt-4o-mini"; -#endif +const char * get_prompt_model() { + if(auth_type != AUTH_TYPE_API_KEY) { + return "gpt-3.5-turbo"; + } else { + return "gpt-4o-mini"; + } +} + static int prompt_max_tokens = 2048; static double prompt_temperature = 0.1; @@ -53,7 +57,7 @@ void chat_free() { char *chat_json(const char *role, const char *message) { chat_free(); json_object *root_object = json_object_new_object(); - json_object_object_add(root_object, "model", json_object_new_string(prompt_model)); + json_object_object_add(root_object, "model", json_object_new_string(get_prompt_model())); if (role != NULL && message != NULL) { message_add(role, message); @@ -67,4 +71,4 @@ char *chat_json(const char *role, const char *message) { return (char *)json_object_to_json_string_ext(root_object, JSON_C_TO_STRING_PRETTY); } -#endif \ No newline at end of file +#endif diff --git a/main.c b/main.c index 6984990..918805d 100644 --- a/main.c +++ b/main.c @@ -247,7 +247,7 @@ void help() { " - **google search** and actions with those results.\n" " - **reminders**.\n" " - predefined **templates** for **reviewing** / **refactoring** so you can personalize.\n"; - sprintf(help_text, template, prompt_temperature, prompt_model, prompt_max_tokens); + sprintf(help_text, template, prompt_temperature, get_prompt_model(), prompt_max_tokens); render(help_text); }