fix(ai): set correct links in tests, fix headers
This commit is contained in:
@@ -22,8 +22,8 @@
|
||||
#include <string.h>
|
||||
|
||||
/* Default providers */
|
||||
#define DEFAULT_OPENAI_URL "https://api.openai.com/v1/responses"
|
||||
#define DEFAULT_PERPLEXITY_URL "https://api.perplexity.ai/v1/responses"
|
||||
#define DEFAULT_OPENAI_URL "https://api.openai.com/"
|
||||
#define DEFAULT_PERPLEXITY_URL "https://api.perplexity.ai/"
|
||||
|
||||
/* Global state */
|
||||
static GHashTable* providers = NULL;
|
||||
@@ -713,10 +713,12 @@ _ai_request_thread(gpointer data)
|
||||
|
||||
/* Configure request */
|
||||
const gchar* api_url = session->provider ? session->provider->api_url : DEFAULT_OPENAI_URL;
|
||||
auto_gchar gchar* request_url = g_strdup_printf("%s%sv1/responses", api_url, g_str_has_suffix(api_url, "/") ? "" : "/");
|
||||
log_debug("[AI-THREAD] API URL: %s", api_url);
|
||||
log_debug("[AI-THREAD] API Request URL: %s", request_url);
|
||||
log_debug("[AI-THREAD] Model: %s", session->model);
|
||||
log_debug("[AI-THREAD] API Key: %s", session->api_key ? (strlen(session->api_key) > 10 ? g_strndup(session->api_key, 10) : session->api_key) : "NULL");
|
||||
curl_easy_setopt(curl, CURLOPT_URL, api_url);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, request_url);
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_payload);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _write_callback);
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
#include "tools/bookmark_ignore.h"
|
||||
#include "tools/editor.h"
|
||||
#include "plugins/plugins.h"
|
||||
#include "ui/inputwin.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/ui.h"
|
||||
#include "ui/window_list.h"
|
||||
#include "xmpp/avatar.h"
|
||||
|
||||
@@ -101,8 +101,6 @@ char* win_quote_autocomplete(ProfWin* window, const char* const input, gboolean
|
||||
char* get_show_char(prof_enc_t encryption_mode);
|
||||
char* get_enc_char(prof_enc_t enc_mode, const char* alt);
|
||||
|
||||
#include "ai/ai_client.h"
|
||||
|
||||
// AI window functions
|
||||
void win_ai_free(ProfAiWin* win);
|
||||
char* aiwin_get_string(ProfAiWin* win);
|
||||
|
||||
@@ -32,12 +32,12 @@ test_ai_client_init(void** state)
|
||||
AIProvider* openai = ai_get_provider("openai");
|
||||
assert_non_null(openai);
|
||||
assert_string_equal("openai", openai->name);
|
||||
assert_string_equal("https://api.openai.com/v1/chat/completions", openai->api_url);
|
||||
assert_string_equal("https://api.openai.com/", openai->api_url);
|
||||
|
||||
AIProvider* perplexity = ai_get_provider("perplexity");
|
||||
assert_non_null(perplexity);
|
||||
assert_string_equal("perplexity", perplexity->name);
|
||||
assert_string_equal("https://api.perplexity.ai/v1/chat/completions", perplexity->api_url);
|
||||
assert_string_equal("https://api.perplexity.ai/", perplexity->api_url);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user