mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-13 20:35:41 +00:00
Allow setting user agent for tools.
This commit is contained in:
@@ -39,6 +39,7 @@ void LoadConfig()
|
||||
if( v2 = ini_get( ini, "llm", "model" ); v2 ) s_config.llmModel = v2;
|
||||
if( v2 = ini_get( ini, "llm", "embeddings" ); v2 ) s_config.llmEmbeddingsModel = v2;
|
||||
if( v2 = ini_get( ini, "llm", "readability" ); v2 ) s_config.llmReadability = v2;
|
||||
if( v2 = ini_get( ini, "llm", "useragent" ); v2 ) s_config.llmUserAgent = v2;
|
||||
|
||||
ini_free( ini );
|
||||
}
|
||||
@@ -79,6 +80,7 @@ bool SaveConfig()
|
||||
fprintf( f, "model = %s\n", s_config.llmModel.c_str() );
|
||||
fprintf( f, "embeddings = %s\n", s_config.llmEmbeddingsModel.c_str() );
|
||||
fprintf( f, "readability = %s\n", s_config.llmReadability.c_str() );
|
||||
fprintf( f, "useragent = %s\n", s_config.llmUserAgent.c_str() );
|
||||
|
||||
fclose( f );
|
||||
return true;
|
||||
|
||||
@@ -29,6 +29,7 @@ struct Config
|
||||
std::string llmModel;
|
||||
std::string llmEmbeddingsModel;
|
||||
std::string llmReadability;
|
||||
std::string llmUserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36";
|
||||
};
|
||||
|
||||
extern Config s_config;
|
||||
|
||||
@@ -256,10 +256,11 @@ void TracyLlm::Draw()
|
||||
|
||||
if( ImGui::TreeNode( "External services" ) )
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted( "Readability.js:" );
|
||||
ImGui::SameLine();
|
||||
char buf[1024];
|
||||
snprintf( buf, sizeof( buf ), "%s", s_config.llmReadability.c_str() );
|
||||
if( ImGui::InputTextWithHint( "##readability", "http://127.0.0.1:3000", buf, sizeof( buf ) ) )
|
||||
{
|
||||
@@ -268,6 +269,17 @@ void TracyLlm::Draw()
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if( ImGui::Button( ICON_FA_HOUSE ) ) OpenWebpage( "https://github.com/phpdocker-io/readability-js-server" );
|
||||
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextUnformatted( "User agent:" );
|
||||
ImGui::SameLine();
|
||||
snprintf( buf, sizeof( buf ), "%s", s_config.llmUserAgent.c_str() );
|
||||
if( ImGui::InputTextWithHint( "##useragent", "Spoof user agent", buf, sizeof( buf ) ) )
|
||||
{
|
||||
s_config.llmUserAgent = buf;
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ std::string TracyLlmTools::FetchWebPage( const std::string& url, bool cache )
|
||||
curl_easy_setopt( curl, CURLOPT_TIMEOUT, 10 );
|
||||
curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, WriteFn );
|
||||
curl_easy_setopt( curl, CURLOPT_WRITEDATA, &buf );
|
||||
curl_easy_setopt( curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" );
|
||||
curl_easy_setopt( curl, CURLOPT_USERAGENT, s_config.llmUserAgent.c_str() );
|
||||
|
||||
auto res = curl_easy_perform( curl );
|
||||
|
||||
@@ -526,7 +526,7 @@ std::string TracyLlmTools::GetWebpage( const std::string& url )
|
||||
curl_easy_setopt( curl, CURLOPT_POSTFIELDSIZE, postStr.size() );
|
||||
curl_easy_setopt( curl, CURLOPT_WRITEFUNCTION, WriteFn );
|
||||
curl_easy_setopt( curl, CURLOPT_WRITEDATA, &buf );
|
||||
curl_easy_setopt( curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36" );
|
||||
curl_easy_setopt( curl, CURLOPT_USERAGENT, s_config.llmUserAgent.c_str() );
|
||||
|
||||
auto res = curl_easy_perform( curl );
|
||||
curl_slist_free_all( hdr );
|
||||
|
||||
Reference in New Issue
Block a user