on main help sign in
chore: small fixes to the config
commit8992d029b2cc6e9df9daf8782a58dbc097b27b93 authorKujtim Hoxha <kujtimii.h@gmail.com> dateMon 30 Jun 2025, 21:40 (1 year ago) parent2b6766a
4 files changed+83−16
crush-schema.json+2−5 internal/config/config.go+10−10 internal/llm/provider/openai.go+1−1 internal/tui/components/dialogs/models/models.go+70
crush-schema.json+2−5
@@ -187,7 +187,7 @@
187187 "title": "Model ID",
188188 "description": "Unique identifier for the model"
189189 },
190− "model": {
190+ "name": {
191191 "type": "string",
192192 "title": "Model Name",
193193 "description": "Display name of the model"
@@ -252,10 +252,7 @@
252252 "type": "object",
253253 "required": [
254254 "id",
255− "model",
256− "cost_per_1m_in",
257− "cost_per_1m_out",
258− "cost_per_1m_in_cached",
255+ "name",
259256 "cost_per_1m_out_cached",
260257 "context_window",
261258 "default_max_tokens",
internal/config/config.go+10−10
@@ -56,18 +56,18 @@ const (
5656)
5757
5858type Model struct {
59− ID string `json:"id" jsonschema:"title=Model ID,description=Unique identifier for the model"`
60− Name string `json:"model" jsonschema:"title=Model Name,description=Display name of the model"`
61− CostPer1MIn float64 `json:"cost_per_1m_in" jsonschema:"title=Input Cost,description=Cost per 1 million input tokens,minimum=0"`
62− CostPer1MOut float64 `json:"cost_per_1m_out" jsonschema:"title=Output Cost,description=Cost per 1 million output tokens,minimum=0"`
63− CostPer1MInCached float64 `json:"cost_per_1m_in_cached" jsonschema:"title=Cached Input Cost,description=Cost per 1 million cached input tokens,minimum=0"`
64− CostPer1MOutCached float64 `json:"cost_per_1m_out_cached" jsonschema:"title=Cached Output Cost,description=Cost per 1 million cached output tokens,minimum=0"`
59+ ID string `json:"id" jsonschema:"title=Model ID,description=Unique identifier for the model, the API model"`
60+ Name string `json:"name" jsonschema:"title=Model Name,description=Display name of the model"`
61+ CostPer1MIn float64 `json:"cost_per_1m_in,omitempty" jsonschema:"title=Input Cost,description=Cost per 1 million input tokens,minimum=0"`
62+ CostPer1MOut float64 `json:"cost_per_1m_out,omitempty" jsonschema:"title=Output Cost,description=Cost per 1 million output tokens,minimum=0"`
63+ CostPer1MInCached float64 `json:"cost_per_1m_in_cached,omitempty" jsonschema:"title=Cached Input Cost,description=Cost per 1 million cached input tokens,minimum=0"`
64+ CostPer1MOutCached float64 `json:"cost_per_1m_out_cached,omitempty" jsonschema:"title=Cached Output Cost,description=Cost per 1 million cached output tokens,minimum=0"`
6565 ContextWindow int64 `json:"context_window" jsonschema:"title=Context Window,description=Maximum context window size in tokens,minimum=1"`
6666 DefaultMaxTokens int64 `json:"default_max_tokens" jsonschema:"title=Default Max Tokens,description=Default maximum tokens for responses,minimum=1"`
67− CanReason bool `json:"can_reason" jsonschema:"title=Can Reason,description=Whether the model supports reasoning capabilities"`
68− ReasoningEffort string `json:"reasoning_effort" jsonschema:"title=Reasoning Effort,description=Default reasoning effort level for reasoning models"`
69− HasReasoningEffort bool `json:"has_reasoning_effort" jsonschema:"title=Has Reasoning Effort,description=Whether the model supports reasoning effort configuration"`
70− SupportsImages bool `json:"supports_attachments" jsonschema:"title=Supports Images,description=Whether the model supports image attachments"`
67+ CanReason bool `json:"can_reason,omitempty" jsonschema:"title=Can Reason,description=Whether the model supports reasoning capabilities"`
68+ ReasoningEffort string `json:"reasoning_effort,omitempty" jsonschema:"title=Reasoning Effort,description=Default reasoning effort level for reasoning models"`
69+ HasReasoningEffort bool `json:"has_reasoning_effort,omitempty" jsonschema:"title=Has Reasoning Effort,description=Whether the model supports reasoning effort configuration"`
70+ SupportsImages bool `json:"supports_attachments,omitempty" jsonschema:"title=Supports Images,description=Whether the model supports image attachments"`
7171}
7272
7373type VertexAIOptions struct {
internal/llm/provider/openai.go+1−1
@@ -183,7 +183,7 @@ func (o *openaiClient) preparedParams(messages []openai.ChatCompletionMessagePar
183183 case "high":
184184 params.ReasoningEffort = shared.ReasoningEffortHigh
185185 default:
186− params.ReasoningEffort = shared.ReasoningEffortMedium
186+ params.ReasoningEffort = shared.ReasoningEffort(reasoningEffort)
187187 }
188188 } else {
189189 params.MaxTokens = openai.Int(maxTokens)
internal/tui/components/dialogs/models/models.go+70
@@ -1,6 +1,8 @@
11package models
22
33import (
4+ "slices"
5+
46 "github.com/charmbracelet/bubbles/v2/help"
57 "github.com/charmbracelet/bubbles/v2/key"
68 tea "github.com/charmbracelet/bubbletea/v2"
@@ -228,7 +230,75 @@ func (m *modelDialogCmp) SetModelType(modelType int) tea.Cmd {
228230 currentModel = cfg.Models.Small
229231 }
230232
233+ // Create a map to track which providers we've already added
234+ addedProviders := make(map[provider.InferenceProvider]bool)
235+
236+ // First, add any configured providers that are not in the known providers list
237+ // These should appear at the top of the list
238+ knownProviders := provider.KnownProviders()
239+ for providerID, providerConfig := range cfg.Providers {
240+ if providerConfig.Disabled {
241+ continue
242+ }
243+
244+ // Check if this provider is not in the known providers list
245+ if !slices.Contains(knownProviders, providerID) {
246+ // Convert config provider to provider.Provider format
247+ configProvider := provider.Provider{
248+ Name: string(providerID), // Use provider ID as name for unknown providers
249+ ID: providerID,
250+ Models: make([]provider.Model, len(providerConfig.Models)),
251+ }
252+
253+ // Convert models
254+ for i, model := range providerConfig.Models {
255+ configProvider.Models[i] = provider.Model{
256+ ID: model.ID,
257+ Name: model.Name,
258+ CostPer1MIn: model.CostPer1MIn,
259+ CostPer1MOut: model.CostPer1MOut,
260+ CostPer1MInCached: model.CostPer1MInCached,
261+ CostPer1MOutCached: model.CostPer1MOutCached,
262+ ContextWindow: model.ContextWindow,
263+ DefaultMaxTokens: model.DefaultMaxTokens,
264+ CanReason: model.CanReason,
265+ HasReasoningEffort: model.HasReasoningEffort,
266+ DefaultReasoningEffort: model.ReasoningEffort,
267+ SupportsImages: model.SupportsImages,
268+ }
269+ }
270+
271+ // Add this unknown provider to the list
272+ name := configProvider.Name
273+ if name == "" {
274+ name = string(configProvider.ID)
275+ }
276+ modelItems = append(modelItems, commands.NewItemSection(name))
277+ for _, model := range configProvider.Models {
278+ modelItems = append(modelItems, completions.NewCompletionItem(model.Name, ModelOption{
279+ Provider: configProvider,
280+ Model: model,
281+ }))
282+ if model.ID == currentModel.ModelID && configProvider.ID == currentModel.Provider {
283+ selectIndex = len(modelItems) - 1 // Set the selected index to the current model
284+ }
285+ }
286+ addedProviders[providerID] = true
287+ }
288+ }
289+
290+ // Then add the known providers from the predefined list
231291 for _, provider := range providers {
292+ // Skip if we already added this provider as an unknown provider
293+ if addedProviders[provider.ID] {
294+ continue
295+ }
296+
297+ // Check if this provider is configured and not disabled
298+ if providerConfig, exists := cfg.Providers[provider.ID]; exists && providerConfig.Disabled {
299+ continue
300+ }
301+
232302 name := provider.Name
233303 if name == "" {
234304 name = string(provider.ID)