feat: 添加指定模型的能力 (#74)

This commit is contained in:
二丫讲梵
2023-03-07 13:29:05 +08:00
committed by GitHub
parent ab6ecc3f26
commit acb5462a01
8 changed files with 71 additions and 46 deletions

View File

@@ -8,7 +8,6 @@ import (
"strings"
"time"
"github.com/eryajf/chatgpt-dingtalk/config"
"github.com/eryajf/chatgpt-dingtalk/public"
"github.com/eryajf/chatgpt-dingtalk/public/logger"
"github.com/solywsh/chatgpt"
@@ -213,15 +212,13 @@ func Do(mode string, rmsg public.ReceiveMsg) error {
}
func SingleQa(question, userId string) (answer string, err error) {
cfg := config.LoadConfig()
chat := chatgpt.New(cfg.ApiKey, cfg.HttpProxy, userId, cfg.SessionTimeout)
chat := chatgpt.New(public.Config.ApiKey, public.Config.HttpProxy, userId, public.Config.SessionTimeout)
defer chat.Close()
return chat.ChatWithContext(question)
}
func ContextQa(question, userId string) (chat *chatgpt.ChatGPT, answer string, err error) {
cfg := config.LoadConfig()
chat = chatgpt.New(cfg.ApiKey, cfg.HttpProxy, userId, cfg.SessionTimeout)
chat = chatgpt.New(public.Config.ApiKey, public.Config.HttpProxy, userId, public.Config.SessionTimeout)
if public.UserService.GetUserSessionContext(userId) != "" {
err = chat.ChatContext.LoadConversation(userId)
if err != nil {