mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-11 11:18:50 +01:00
🎨 支持应用内配置人工智能 https://github.com/siyuan-note/siyuan/issues/7714
This commit is contained in:
parent
cb1c20ea92
commit
bbbedac655
4 changed files with 24 additions and 68 deletions
|
|
@ -77,7 +77,7 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
|
|||
if cloud {
|
||||
gpt = &CloudGPT{}
|
||||
} else {
|
||||
gpt = &OpenAIGPT{c: util.NewOpenAIClient()}
|
||||
gpt = &OpenAIGPT{c: util.NewOpenAIClient(Conf.AI.OpenAI.APIKey, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIBaseURL)}
|
||||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
|
|
@ -99,7 +99,7 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
|
|||
}
|
||||
|
||||
func isOpenAIAPIEnabled() bool {
|
||||
if "" == util.OpenAIAPIKey {
|
||||
if "" == Conf.AI.OpenAI.APIKey {
|
||||
util.PushMsg(Conf.Language(193), 5000)
|
||||
return false
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ type OpenAIGPT struct {
|
|||
}
|
||||
|
||||
func (gpt *OpenAIGPT) chat(msg string, contextMsgs []string) (partRet string, stop bool, err error) {
|
||||
return util.ChatGPT(msg, contextMsgs, gpt.c)
|
||||
return util.ChatGPT(msg, contextMsgs, gpt.c, Conf.AI.OpenAI.APIMaxTokens, Conf.AI.OpenAI.APITimeout)
|
||||
}
|
||||
|
||||
type CloudGPT struct {
|
||||
|
|
|
|||
|
|
@ -323,6 +323,15 @@ func InitConf() {
|
|||
Conf.AI = conf.NewAI()
|
||||
}
|
||||
|
||||
if "" != Conf.AI.OpenAI.APIKey {
|
||||
logging.LogInfof("OpenAI API enabled\n"+
|
||||
" baseURL=%s\n"+
|
||||
" timeout=%ds\n"+
|
||||
" proxy=%s\n"+
|
||||
" maxTokens=%d",
|
||||
Conf.AI.OpenAI.APIBaseURL, Conf.AI.OpenAI.APITimeout, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIMaxTokens)
|
||||
}
|
||||
|
||||
Conf.ReadOnly = util.ReadOnly
|
||||
|
||||
if "" != util.AccessAuthCode {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue