feat(provider): add lmstudio and align local provider default auth/base handling (#2193)
* feat(provider): add lmstudio vendor and local no-key behavior * refactor(provider): consolidate protocol metadata and local tests * fix(provider): sync lmstudio probing and model normalization * test(web): format lmstudio model status cases for golines
This commit is contained in:
11 files changed
+307
-72
No files matched your search
@@ -10,6 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/sipeed/picoclaw/pkg/config"
|
||||
"github.com/sipeed/picoclaw/pkg/providers"
|
||||
)
|
||||
|
||||
const modelProbeTimeout = 800 * time.Millisecond
|
||||
@@ -60,10 +61,14 @@ func requiresRuntimeProbe(m *config.ModelConfig) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
switch modelProtocol(m.Model) {
|
||||
protocol := modelProtocol(m.Model)
|
||||
|
||||
switch protocol {
|
||||
case "claude-cli", "claudecli", "codex-cli", "codexcli", "github-copilot", "copilot":
|
||||
return true
|
||||
case "ollama", "vllm":
|
||||
}
|
||||
|
||||
if providers.IsEmptyAPIKeyAllowedForProtocol(protocol) {
|
||||
apiBase := strings.TrimSpace(m.APIBase)
|
||||
return apiBase == "" || hasLocalAPIBase(apiBase)
|
||||
}
|
||||
@@ -81,7 +86,7 @@ func probeLocalModelAvailability(m *config.ModelConfig) bool {
|
||||
switch protocol {
|
||||
case "ollama":
|
||||
return probeOllamaModelFunc(apiBase, modelID)
|
||||
case "vllm":
|
||||
case "vllm", "lmstudio":
|
||||
return probeOpenAICompatibleModelFunc(apiBase, modelID, m.APIKey())
|
||||
case "github-copilot", "copilot":
|
||||
return probeTCPServiceFunc(apiBase)
|
||||
@@ -100,11 +105,12 @@ func modelProbeAPIBase(m *config.ModelConfig) string {
|
||||
return normalizeModelProbeAPIBase(apiBase)
|
||||
}
|
||||
|
||||
switch modelProtocol(m.Model) {
|
||||
case "ollama":
|
||||
return "http://localhost:11434/v1"
|
||||
case "vllm":
|
||||
return "http://localhost:8000/v1"
|
||||
protocol := modelProtocol(m.Model)
|
||||
if providers.IsEmptyAPIKeyAllowedForProtocol(protocol) {
|
||||
return providers.DefaultAPIBaseForProtocol(protocol)
|
||||
}
|
||||
|
||||
switch protocol {
|
||||
case "github-copilot", "copilot":
|
||||
return "localhost:4321"
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user