fix: runtime error: index out of range [1] with length 1

This commit is contained in:
Pluto 2023-10-11 10:07:07 +08:00
parent 427b655b60
commit 46ac4cf28f

View File

@ -13,8 +13,8 @@ import (
func parseOpenaiConfig(config string) (apiKey string, organization string) { func parseOpenaiConfig(config string) (apiKey string, organization string) {
parts := strings.Split(config, "|") parts := strings.Split(config, "|")
if len(parts) != 2 { if len(parts) < 2 {
parts[1] = "" parts = append(parts, "")
} }
apiKey = parts[0] apiKey = parts[0]
organization = parts[1] organization = parts[1]