Skip to content

Commit

Permalink
Fix error when locating config.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed May 12, 2024
1 parent e85eed3 commit 481108d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion azure/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/stulzq/azure-openai-proxy/util"
"log"
"net/url"
"os"
"path/filepath"
"strings"
)
Expand Down Expand Up @@ -101,10 +102,15 @@ func InitFromConfigFile() error {
configFile = filepath.Join(util.GetWorkdir(), configFile)
}

if _, err := os.Stat(configFile); os.IsNotExist(err) {
log.Println("config.yaml does not exist, attempting to read configuration from environment variables")
return InitFromEnvironmentVariables(viper.GetString(constant.ENV_AZURE_OPENAI_API_VER), viper.GetString(constant.ENV_AZURE_OPENAI_ENDPOINT), viper.GetString(constant.ENV_AZURE_OPENAI_MODEL_MAPPER))

Check failure on line 107 in azure/init.go

View workflow job for this annotation

GitHub Actions / build

InitFromEnvironmentVariables(viper.GetString(constant.ENV_AZURE_OPENAI_API_VER), viper.GetString(constant.ENV_AZURE_OPENAI_ENDPOINT), viper.GetString(constant.ENV_AZURE_OPENAI_MODEL_MAPPER)) (no value) used as value
}

viper.SetConfigType("yaml")
viper.SetConfigFile(configFile)
if err := viper.ReadInConfig(); err != nil {
log.Printf("read config file error: %+v\n", err)
log.Printf("Failed to read config file: %s. Please check if the file exists or consider using environment variables for configuration.\n", err)
return err
}

Expand Down

0 comments on commit 481108d

Please sign in to comment.