fix: resolve issue where model failed to start on TCE due to missing environment variables (#2403)

This commit is contained in:
Ryo
2025-10-28 20:48:26 +08:00
committed by GitHub
parent 125f1fbb01
commit 5f11c49733
3 changed files with 12 additions and 2 deletions

View File

@ -47,6 +47,11 @@ func getOldKnowledgeBuiltinChatModelConfig() *Model {
}
typeStr := strings.ToUpper(os.Getenv("BUILTIN_CM_TYPE"))
if typeStr == "" {
return nil
}
baseURLKey := fmt.Sprintf("BUILTIN_CM_%s_BASE_URL", typeStr)
apiKeyKey := fmt.Sprintf("BUILTIN_CM_%s_API_KEY", typeStr)
modelKey := fmt.Sprintf("BUILTIN_CM_%s_MODEL", typeStr)

View File

@ -63,7 +63,9 @@ func initOldModelConf(ctx context.Context, oss storage.Storage, c *ModelConfig)
return err
}
if envModel != nil {
oldModels = append(oldModels, envModel)
}
for _, q := range oldModels {
if q.Provider.IconURI != "" {
@ -106,6 +108,9 @@ func initOldModelConf(ctx context.Context, oss storage.Storage, c *ModelConfig)
}
func initModelByEnv() (*Model, error) {
if os.Getenv("MODEL_PROTOCOL_0") == "" || os.Getenv("MODEL_OPENCOZE_ID_0") == "" {
return nil, nil
}
protocol := os.Getenv("MODEL_PROTOCOL_0")
openCozeID, err := envkey.GetI64("MODEL_OPENCOZE_ID_0")
if err != nil {

View File

@ -73,7 +73,7 @@ func GetBuiltinChatModel(ctx context.Context, envPrefix string) (bcm BaseChatMod
}
return nil, true, nil
return nil, false, nil
}
func checkModelConfig(ctx context.Context, bcm BaseChatModel) (err error) {