Do not repeatedly probe for LLM provider type.

This commit is contained in:
Bartosz Taudul
2025-06-08 21:10:13 +02:00
parent a84e63d573
commit b9595add71
2 changed files with 7 additions and 2 deletions

View File

@@ -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<const std::string&>();
if( json2.contains( "loaded_context_length" ) ) m_models.back().contextSize = json2["loaded_context_length"].get<int>();
}
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 )

View File

@@ -25,6 +25,7 @@ class TracyLlmApi
Unknown,
Ollama,
LmStudio,
Other
};
public: