feat(openrouter): fetch live model catalogue for the picker#140
Conversation
Replace the hardcoded OpenRouter model list in the model picker with a live query against OpenRouter's public /models endpoint, so the list never goes stale. Falls back to the provider default on fetch failure (offline/timeout) and is time-boxed so startup never hangs. Also refresh the config template (embedded default + generated config docs): drop hardcoded model ids from the provider examples and point users at each provider's live model list instead.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 677168e826
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if name == "" { | ||
| name = m.ID | ||
| } | ||
| choices = append(choices, tui.ModelChoice{ID: m.ID, Name: name, Description: m.Description}) |
There was a problem hiding this comment.
Filter OpenRouter choices to tool-capable models
When an OpenRouter user selects a catalogue entry that does not advertise tools in supported_parameters, normal chat turns will fail because internal/llm/chatcompletions.BuildRequest always sends Neo's tool specs and sets tool_choice whenever tools are registered. OpenRouter's /models response includes non-tool-capable models, and its docs describe supported_parameters as the field indicating tools support, but this loop adds every id without decoding/filtering that field, so the picker offers unusable models. Please filter the live catalogue to tool-capable text chat models before appending them.
Useful? React with 👍 / 👎.
Summary
Replaces the hardcoded OpenRouter model list in the model picker with a live query against OpenRouter's public
/modelsendpoint, so the picker never goes stale.openrouter.Models(ctx, httpClient): fetches, decodes, drops empty ids, sorts by id. SendsOPENROUTER_API_KEYif present (higher rate limits) but works without it.cmd/neo): OpenRouter case now fetches live, time-boxed to 5s, with graceful fallback to the provider default on failure (offline/timeout/API change).Tests
openrouter: mock-server tests for fetch/sort/blank-id filtering and non-OK status.cmd/neo: fallback test (cancelled context still yields the default).go test ./...,go vet, andneo-docs --checkall pass.Follow-up
OpenAI's api-key model list is still hardcoded (its
/modelsendpoint needs a key and returns everything with no coding-suitability signal).