fix: fix null pointer in unconfigured provider fetch, add model name to list

This commit is contained in:
sunanzhi
2025-03-07 11:38:14 +08:00
parent bc16d7f5ce
commit 22f15f5cbf
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -83,6 +83,7 @@ type BackupProvider struct {
type LLMItem struct {
Id string `json:"id"`
Name string `json:"name"`
Logo string `json:"logo"`
Config string `json:"config"`
AccessConfiguration string `json:"access_configuration"`
+6 -1
View File
@@ -411,12 +411,16 @@ func (i *imlProviderModule) UnConfiguredProviders(ctx context.Context) ([]*ai_dt
// 已配置,跳过
continue
}
defaultLLMID := ""
defaultLLM, _ := v.DefaultModel(model_runtime.ModelTypeLLM)
if defaultLLM != nil {
defaultLLMID = defaultLLM.ID()
}
item := &ai_dto.ProviderItem{
Id: v.ID(),
Name: v.Name(),
Logo: v.Logo(),
DefaultLLM: defaultLLM.ID(),
DefaultLLM: defaultLLMID,
Sort: v.Sort(),
}
items = append(items, item)
@@ -508,6 +512,7 @@ func (i *imlProviderModule) LLMs(ctx context.Context, driver string) ([]*ai_dto.
for _, v := range llms {
items = append(items, &ai_dto.LLMItem{
Id: v.ID(),
Name: v.Name(),
Logo: v.Logo(),
Config: v.DefaultConfig(),
AccessConfiguration: v.AccessConfiguration(),