diff --git a/profiler/src/profiler/TracyConfig.cpp b/profiler/src/profiler/TracyConfig.cpp index 3ad6e842..966b4059 100644 --- a/profiler/src/profiler/TracyConfig.cpp +++ b/profiler/src/profiler/TracyConfig.cpp @@ -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; diff --git a/profiler/src/profiler/TracyConfig.hpp b/profiler/src/profiler/TracyConfig.hpp index 2be6f42a..023cf6e8 100644 --- a/profiler/src/profiler/TracyConfig.hpp +++ b/profiler/src/profiler/TracyConfig.hpp @@ -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; diff --git a/profiler/src/profiler/TracyLlm.cpp b/profiler/src/profiler/TracyLlm.cpp index e9c825df..a1f59d64 100644 --- a/profiler/src/profiler/TracyLlm.cpp +++ b/profiler/src/profiler/TracyLlm.cpp @@ -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(); } diff --git a/profiler/src/profiler/TracyLlmTools.cpp b/profiler/src/profiler/TracyLlmTools.cpp index a064ed2b..b9253450 100644 --- a/profiler/src/profiler/TracyLlmTools.cpp +++ b/profiler/src/profiler/TracyLlmTools.cpp @@ -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 );