Don't fail when there are no models downloaded.

This commit is contained in:
Bartosz Taudul
2025-05-11 19:26:40 +02:00
parent d50f05c00b
commit 6ce5c345a5

View File

@@ -922,37 +922,44 @@ static void DrawContents()
break;
}
if( !llmModels.empty() )
if( llmstatus == 2 )
{
ImGui::TextDisabled( "Selected model:" );
int sel;
for( sel=0; sel<llmModels.size(); sel++ )
if( !llmModels.empty() )
{
if( llmModels[sel].name == s_config.llmModel ) break;
}
if( sel == llmModels.size() )
{
sel = 0;
s_config.llmModel = llmModels[0].name;
SaveConfig();
}
ImGui::SameLine();
ImGui::SetNextItemWidth( 225 * dpiScale );
if( ImGui::BeginCombo( "##llmmodel", llmModels[sel].name.c_str() ) )
{
for( int i=0; i<llmModels.size(); i++ )
ImGui::TextDisabled( "Selected model:" );
int sel;
for( sel=0; sel<llmModels.size(); sel++ )
{
bool isSelected = ( i == sel );
if( ImGui::Selectable( llmModels[i].name.c_str(), isSelected ) )
{
s_config.llmModel = llmModels[i].name;
SaveConfig();
}
if( isSelected ) ImGui::SetItemDefaultFocus();
ImGui::SameLine();
ImGui::TextDisabled( "(ctx: %s)", tracy::RealToString( llmModels[i].ctxSize ) );
if( llmModels[sel].name == s_config.llmModel ) break;
}
ImGui::EndCombo();
if( sel == llmModels.size() )
{
sel = 0;
s_config.llmModel = llmModels[0].name;
SaveConfig();
}
ImGui::SameLine();
ImGui::SetNextItemWidth( 225 * dpiScale );
if( ImGui::BeginCombo( "##llmmodel", llmModels[sel].name.c_str() ) )
{
for( int i=0; i<llmModels.size(); i++ )
{
bool isSelected = ( i == sel );
if( ImGui::Selectable( llmModels[i].name.c_str(), isSelected ) )
{
s_config.llmModel = llmModels[i].name;
SaveConfig();
}
if( isSelected ) ImGui::SetItemDefaultFocus();
ImGui::SameLine();
ImGui::TextDisabled( "(ctx: %s)", tracy::RealToString( llmModels[i].ctxSize ) );
}
ImGui::EndCombo();
}
}
else
{
ImGui::TextColored( ImVec4( 1, 0.5f, 0.5f, 1 ), "No models available! Use ollama to get some." );
}
}