Allow disabling network access for the LLM.

This commit is contained in:
Bartosz Taudul
2025-05-17 21:19:50 +02:00
parent b574e28b79
commit f68253a085
2 changed files with 9 additions and 0 deletions

View File

@@ -188,6 +188,8 @@ void TracyLlm::Draw()
ImGui::SetNextItemWidth( 40 * scale );
if( ImGui::InputFloat( "##temperature", &m_temperature, 0, 0, "%.2f" ) ) m_temperature = std::clamp( m_temperature, 0.f, 2.f );
ImGui::Checkbox( ICON_FA_GLOBE " Internet access", &m_netAccess );
ImGui::TreePop();
}
@@ -917,6 +919,8 @@ std::string TracyLlm::FetchWebPage( const std::string& url )
TracyLlm::ToolReply TracyLlm::SearchWikipedia( std::string query, const std::string& lang )
{
if( !m_netAccess ) return { .reply = "Internet access is disabled by the user." };
std::ranges::replace( query, ' ', '+' );
const auto response = FetchWebPage( "https://" + lang + ".wikipedia.org/w/rest.php/v1/search/page?q=" + UrlEncode( query ) + "&limit=1" );
@@ -968,6 +972,8 @@ TracyLlm::ToolReply TracyLlm::SearchWikipedia( std::string query, const std::str
std::string TracyLlm::GetWikipedia( std::string page, const std::string& lang )
{
if( !m_netAccess ) return "Internet access is disabled by the user.";
std::ranges::replace( page, ' ', '_' );
auto res = FetchWebPage( "https://" + lang + ".wikipedia.org/w/rest.php/v1/page/" + page );
@@ -989,6 +995,8 @@ static std::string RemoveNewline( std::string str )
std::string TracyLlm::SearchWeb( std::string query )
{
if( !m_netAccess ) return "Internet access is disabled by the user.";
std::ranges::replace( query, ' ', '+' );
const auto response = FetchWebPage( "https://lite.duckduckgo.com/lite?q=" + UrlEncode( query ) );

View File

@@ -126,6 +126,7 @@ private:
int m_usedCtx = 0;
float m_temperature = 1.0f;
bool m_setTemperature = false;
bool m_netAccess = true;
char* m_input;
std::unique_ptr<ollama::messages> m_chat;