From b9595add71b4c6ba09f084c3c54fa8ece8fdc7ce Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 8 Jun 2025 21:10:13 +0200 Subject: [PATCH] Do not repeatedly probe for LLM provider type. --- profiler/src/profiler/TracyLlmApi.cpp | 8 ++++++-- profiler/src/profiler/TracyLlmApi.hpp | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/profiler/src/profiler/TracyLlmApi.cpp b/profiler/src/profiler/TracyLlmApi.cpp index d7c46030..410649d9 100644 --- a/profiler/src/profiler/TracyLlmApi.cpp +++ b/profiler/src/profiler/TracyLlmApi.cpp @@ -61,7 +61,7 @@ bool TracyLlmApi::Connect( const char* url ) m_models.emplace_back( LlmModel { .name = id } ); std::string buf2; - if( GetRequest( m_url + "/api/v0/models/" + id, buf2 ) == 200 ) + if( ( m_type == Type::Unknown || m_type == Type::LmStudio ) && GetRequest( m_url + "/api/v0/models/" + id, buf2 ) == 200 ) { m_type = Type::LmStudio; auto json2 = nlohmann::json::parse( buf2 ); @@ -69,7 +69,7 @@ bool TracyLlmApi::Connect( const char* url ) m_models.back().quant = json2["quantization"].get_ref(); if( json2.contains( "loaded_context_length" ) ) m_models.back().contextSize = json2["loaded_context_length"].get(); } - else if( PostRequest( m_url + "/api/show", "{\"name\":\"" + id + "\"}", buf2 ) == 200 ) + else if( ( m_type == Type::Unknown || m_type == Type::Ollama ) && PostRequest( m_url + "/api/show", "{\"name\":\"" + id + "\"}", buf2 ) == 200 ) { m_type = Type::Ollama; auto json2 = nlohmann::json::parse( buf2 ); @@ -83,6 +83,10 @@ bool TracyLlmApi::Connect( const char* url ) } } } + else if( m_type == Type::Unknown ) + { + m_type = Type::Other; + } } } catch( const std::exception& e ) diff --git a/profiler/src/profiler/TracyLlmApi.hpp b/profiler/src/profiler/TracyLlmApi.hpp index 00e48647..b117a98a 100644 --- a/profiler/src/profiler/TracyLlmApi.hpp +++ b/profiler/src/profiler/TracyLlmApi.hpp @@ -25,6 +25,7 @@ class TracyLlmApi Unknown, Ollama, LmStudio, + Other }; public: