refactor: 重构配置管理,使用强类型配置结构并更新相关代码
This commit is contained in:
@@ -46,14 +46,14 @@ func headmasterHandler(msg model.Message) (reply model.Reply) {
|
||||
}
|
||||
|
||||
func ask(from string, question string) (reply string) {
|
||||
llmConfig := openai.DefaultAzureConfig(config.ConfigManager.GetProperty("openai_api_key"), config.ConfigManager.GetProperty("openai_api_base_url"))
|
||||
llmConfig := openai.DefaultAzureConfig(config.ConfigManager.GetConfig().OpenaiApiKey, config.ConfigManager.GetConfig().OpenaiApiBaseUrl)
|
||||
llmConfig.APIType = openai.APITypeOpenAI
|
||||
llmConfig.APIVersion = ""
|
||||
client := openai.NewClientWithConfig(llmConfig)
|
||||
resp, err := client.CreateChatCompletion(
|
||||
context.Background(),
|
||||
openai.ChatCompletionRequest{
|
||||
Model: config.ConfigManager.GetProperty("openai_model_name"),
|
||||
Model: config.ConfigManager.GetConfig().OpenaiModelName,
|
||||
Messages: GenRequestFromUsr(from, question),
|
||||
// Tools: []openai.Tool{
|
||||
// {
|
||||
@@ -91,7 +91,7 @@ func GenRequestFromUsr(from string, question string) []openai.ChatCompletionMess
|
||||
histories[from] = make([]openai.ChatCompletionMessage, 0)
|
||||
histories[from] = append(histories[from], openai.ChatCompletionMessage{
|
||||
Role: openai.ChatMessageRoleSystem,
|
||||
Content: config.ConfigManager.GetProperty("openai_prompt"),
|
||||
Content: config.ConfigManager.GetConfig().OpenaiPrompt,
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func AppendReplyToHistory(from string, reply string) {
|
||||
histories[from] = histories[from][1:]
|
||||
histories[from][0] = openai.ChatCompletionMessage{
|
||||
Role: openai.ChatMessageRoleSystem,
|
||||
Content: config.ConfigManager.GetProperty("openai_prompt"),
|
||||
Content: config.ConfigManager.GetConfig().OpenaiPrompt,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ var SteamAPIKey = ""
|
||||
var ProxyAddr = ""
|
||||
|
||||
func init() {
|
||||
SteamAPIKey = config.ConfigManager.GetProperty("steam_api_key")
|
||||
ProxyAddr = config.ConfigManager.GetProperty("proxy_addr")
|
||||
SteamAPIKey = config.ConfigManager.GetConfig().SteamApiKey
|
||||
ProxyAddr = config.ConfigManager.GetConfig().ProxyAddr
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
Reference in New Issue
Block a user