mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: add IsUnset method to LLMProvider
Introduced a new method to check if an LLM provider is considered unset: - Added Unset field to LLMProvider struct - Implemented IsUnset() method with logic to validate provider configuration - Handles special cases for different provider types (azure-openai, openai-compatible) - Checks for empty API key, missing models, and provider-specific configuration requirements
This commit is contained in:
@@ -11,4 +11,21 @@ type LLMProvider struct {
|
||||
ApiBaseUrl string `json:"api_base_url" bson:"api_base_url"` // API base URL for the provider
|
||||
ApiVersion string `json:"api_version" bson:"api_version"` // API version for the provider
|
||||
Models []string `json:"models" bson:"models"` // Models supported by this provider
|
||||
Unset bool `json:"unset" bson:"-"` // Whether the provider is unset
|
||||
}
|
||||
|
||||
func (p *LLMProvider) IsUnset() bool {
|
||||
if p.ApiKey == "" {
|
||||
return true
|
||||
}
|
||||
if len(p.Models) == 0 {
|
||||
return true
|
||||
}
|
||||
switch p.Key {
|
||||
case "azure-openai":
|
||||
return p.ApiBaseUrl == "" && p.ApiVersion == ""
|
||||
case "openai-compatible":
|
||||
return p.ApiBaseUrl == ""
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user