Handle ollama with no models available.

This commit is contained in:
Bartosz Taudul
2025-05-18 23:35:21 +02:00
parent 915e4ab77e
commit a68cd2543d

View File

@@ -119,14 +119,17 @@ void TracyLlm::Draw()
auto& style = ImGui::GetStyle();
std::lock_guard lock( m_lock );
if( ImGui::Button( ICON_FA_BROOM " Clear chat" ) )
if( !m_models.empty() )
{
if( m_responding ) m_stop = true;
ResetChat();
m_chatCache.clear();
*m_input = 0;
if( ImGui::Button( ICON_FA_BROOM " Clear chat" ) )
{
if( m_responding ) m_stop = true;
ResetChat();
m_chatCache.clear();
*m_input = 0;
}
ImGui::SameLine();
}
ImGui::SameLine();
if( ImGui::Button( ICON_FA_ARROWS_ROTATE " Reload models" ) )
{
if( m_responding ) m_stop = true;
@@ -137,6 +140,22 @@ void TracyLlm::Draw()
m_cv.notify_all();
}
if( m_models.empty() )
{
ImGui::PushFont( m_bigFont );
ImGui::Dummy( ImVec2( 0, ( ImGui::GetContentRegionAvail().y - ImGui::GetTextLineHeight() * 10 ) * 0.5f ) );
TextCentered( ICON_FA_WORM );
ImGui::Spacing();
TextCentered( "No models available." );
ImGui::Dummy( ImVec2( 0, ImGui::GetTextLineHeight() * 1.5f ) );
ImGui::PopFont();
ImGui::TextWrapped( "You need to retrieve at least one model with the ollama tools before you can use this feature." );
ImGui::TextWrapped( "Models can be downloaded by running the 'ollama pull <model>' command." );
ImGui::TextWrapped( "The https://ollama.com/ website contains a list of available models. The 'gemma3' model works quite well." );
ImGui::End();
return;
}
ImGui::SameLine();
if( ImGui::TreeNode( "Settings" ) )
{