Fix apibase (#43)

* 🐛 set `api_base=/v1` as default value

* 🐛 fix EndpointUrl=nil when `InitFromEnvironmentVariables`

*  add notebook examples

* 💚 fix ci err, fmt for log.Fatalf
This commit is contained in:
warjiang
2023-06-16 10:16:01 +08:00
committed by GitHub
parent 2f4a6e64ff
commit 857d7e0e99
2 changed files with 240 additions and 0 deletions

View File

@@ -42,6 +42,7 @@ func Init() error {
}
// ensure apiBase likes /v1
viper.SetDefault("api_base", "/v1")
apiBase := viper.GetString("api_base")
if !strings.HasPrefix(apiBase, "/") {
apiBase = "/" + apiBase
@@ -73,10 +74,15 @@ func InitFromEnvironmentVariables(apiVersion, endpoint, openaiModelMapper string
log.Fatalf("error parsing %s, invalid value %s", constant.ENV_AZURE_OPENAI_MODEL_MAPPER, pair)
}
modelName, deploymentName := info[0], info[1]
u, err := url.Parse(endpoint)
if err != nil {
log.Fatalf("parse endpoint error: %s", err.Error())
}
ModelDeploymentConfig[modelName] = DeploymentConfig{
DeploymentName: deploymentName,
ModelName: modelName,
Endpoint: endpoint,
EndpointUrl: u,
ApiKey: "",
ApiVersion: apiVersion,
}

File diff suppressed because one or more lines are too long