fix: resolve issue where model failed to start on TCE due to missing environment variables (#2403)
This commit is contained in:
@ -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)
|
||||
|
||||
@ -63,7 +63,9 @@ func initOldModelConf(ctx context.Context, oss storage.Storage, c *ModelConfig)
|
||||
return err
|
||||
}
|
||||
|
||||
oldModels = append(oldModels, envModel)
|
||||
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 {
|
||||
|
||||
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user