This repository was archived by the owner on Oct 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Backend flag support #126
Merged
Merged
Backend flag support #126
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
56e38fd
Add support for backend's flag for docker model run
ilopezluna 71c4c1e
Add support for backend's flag for docker model list
ilopezluna f777da5
Updated docs
ilopezluna 134ce03
require OpenAI's api key
ilopezluna 66a9239
Skip model validation when using openai backend. Let them handle it
ilopezluna 3cc946d
On model listing backend and openai params can be used together
ilopezluna 4680f91
OPENAI_API_KEY env var must be set when using --backend openai
ilopezluna 83fd2e5
Include OPENAI_API_KEY on model list using openai backend
ilopezluna 694c5f8
Update commands/list.go
ilopezluna 183f880
Use a map to store valid backends
ilopezluna 0cc1b14
Merge remote-tracking branch 'origin/backend-flag-support' into backe…
ilopezluna 511f5bc
Ensure API Key extracted to function
ilopezluna 1191fca
Update desktop/desktop.go
ilopezluna 0f53979
Merge remote-tracking branch 'origin/backend-flag-support' into backe…
ilopezluna 7e1bc2f
Fix listing OpenAI models
ilopezluna 3427ed8
Update commands/backend.go
ilopezluna b3044ee
Simplify backend validation error message
ilopezluna 59d330a
Fix docs
ilopezluna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package commands | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "maps" | ||
| "os" | ||
| "slices" | ||
| "strings" | ||
| ) | ||
|
|
||
| // ValidBackends is a map of valid backends | ||
| var ValidBackends = map[string]bool{ | ||
| "llama.cpp": true, | ||
| "openai": true, | ||
| } | ||
|
|
||
| // validateBackend checks if the provided backend is valid | ||
| func validateBackend(backend string) error { | ||
| if !ValidBackends[backend] { | ||
| return fmt.Errorf("invalid backend '%s'. Valid backends are: %s", | ||
| backend, ValidBackendsKeys()) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // ensureAPIKey retrieves the API key if needed | ||
| func ensureAPIKey(backend string) (string, error) { | ||
| if backend == "openai" { | ||
| apiKey := os.Getenv("OPENAI_API_KEY") | ||
| if apiKey == "" { | ||
| return "", errors.New("OPENAI_API_KEY environment variable is required when using --backend=openai") | ||
| } | ||
| return apiKey, nil | ||
| } | ||
| return "", nil | ||
| } | ||
|
|
||
| func ValidBackendsKeys() string { | ||
| return strings.Join(slices.Collect(maps.Keys(ValidBackends)), ", ") | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.