mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-17 14:25:37 +00:00
Allow disabling network access for the LLM.
This commit is contained in:
@@ -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 ) );
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user