Skip to content

Commit 4bd4b83

Browse files
authored
fix(llm): use generic model fields in frontend instead of OllamaModels (#1093)
The frontend index page indexed cfg.OllamaModels[0] directly, which panics with "index out of range [0] with length 0" when LLM_PROVIDER is not ollama (config.go only populates OllamaModels for the ollama provider). The CLI already uses cfg.LLMModelsList / cfg.ModelName, so align the frontend with the same generic fields. Also mark the configured MODEL_NAME as the selected option in the dropdown so the initial display matches the user's .env choice. Closes #1072
1 parent 6f86c7f commit 4bd4b83

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

llm/go-client/frontend/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func main() {
9191
r.GET("/", func(c *gin.Context) {
9292
c.HTML(http.StatusOK, "index.html", gin.H{
9393
"TimeoutSecond": cfg.TimeoutSeconds,
94-
"OllamaModels": cfg.OllamaModels,
95-
"DefaultModel": cfg.OllamaModels[0],
94+
"Models": cfg.LLMModelsList,
95+
"DefaultModel": cfg.ModelName,
9696
})
9797
})
9898
r.POST("/api/chat", h.Chat)

llm/go-client/frontend/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<h2>LLM Chat</h2>
2222
<div class="model-selector">
2323
<label for="model-select"></label><select id="model-select">
24-
{{range .OllamaModels}}
25-
<option value="{{.}}">{{.}}</option>
24+
{{range .Models}}
25+
<option value="{{.}}" {{if eq . $.DefaultModel}}selected{{end}}>{{.}}</option>
2626
{{end}}
2727
</select>
2828
</div>

0 commit comments

Comments
 (0)