Make SetupCurl() work with any curl context.

This commit is contained in:
Bartosz Taudul
2025-05-23 18:57:24 +02:00
parent f1d1e00659
commit 75e9e589b8
2 changed files with 9 additions and 9 deletions

View File

@@ -23,13 +23,13 @@ TracyLlmApi::~TracyLlmApi()
if( m_curl ) curl_easy_cleanup( m_curl );
}
void TracyLlmApi::SetupCurl()
void TracyLlmApi::SetupCurl( void* curl )
{
curl_easy_setopt( m_curl, CURLOPT_NOSIGNAL, 1L );
curl_easy_setopt( m_curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L );
curl_easy_setopt( m_curl, CURLOPT_FOLLOWLOCATION, 1L );
curl_easy_setopt( m_curl, CURLOPT_TIMEOUT, 300 );
curl_easy_setopt( m_curl, CURLOPT_USERAGENT, "Tracy Profiler" );
curl_easy_setopt( curl, CURLOPT_NOSIGNAL, 1L );
curl_easy_setopt( curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L );
curl_easy_setopt( curl, CURLOPT_FOLLOWLOCATION, 1L );
curl_easy_setopt( curl, CURLOPT_TIMEOUT, 300 );
curl_easy_setopt( curl, CURLOPT_USERAGENT, "Tracy Profiler" );
}
bool TracyLlmApi::Connect( const char* url )
@@ -41,7 +41,7 @@ bool TracyLlmApi::Connect( const char* url )
m_curl = curl_easy_init();
if( !m_curl ) return false;
SetupCurl();
SetupCurl( m_curl );
std::string buf;
if( GetRequest( m_url + "/v1/models", buf ) != 200 )
@@ -156,7 +156,7 @@ bool TracyLlmApi::ChatCompletion( const nlohmann::json& req, const std::function
if( m_type == Type::LmStudio && m_models[modelIdx].contextSize <= 0 )
{
curl_easy_reset( m_curl );
SetupCurl();
SetupCurl( m_curl );
std::string buf;
if( GetRequest( m_url + "/api/v0/models/" + m_models[modelIdx].name, buf ) == 200 )
{

View File

@@ -38,7 +38,7 @@ public:
[[nodiscard]] const std::vector<LlmModel>& GetModels() const { return m_models; }
private:
void SetupCurl();
void SetupCurl( void* curl );
int64_t GetRequest( const std::string& url, std::string& response );
int64_t PostRequest( const std::string& url, const std::string& data, std::string& response );