mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-22 06:54:08 +01:00
🎨 AI supports configuration randomness and context number https://github.com/siyuan-note/siyuan/issues/10660
This commit is contained in:
parent
41b4984de3
commit
5300638622
11 changed files with 55 additions and 10 deletions
|
|
@ -84,8 +84,8 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
|
|||
util.PushEndlessProgress("Requesting...")
|
||||
defer util.ClearPushProgress(100)
|
||||
|
||||
if 7 < len(contextMsgs) {
|
||||
contextMsgs = contextMsgs[len(contextMsgs)-7:]
|
||||
if Conf.AI.OpenAI.APIMaxContexts < len(contextMsgs) {
|
||||
contextMsgs = contextMsgs[len(contextMsgs)-Conf.AI.OpenAI.APIMaxContexts:]
|
||||
}
|
||||
|
||||
var gpt GPT
|
||||
|
|
@ -96,7 +96,7 @@ func chatGPTContinueWrite(msg string, contextMsgs []string, cloud bool) (ret str
|
|||
}
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
for i := 0; i < 7; i++ {
|
||||
for i := 0; i < Conf.AI.OpenAI.APIMaxContexts; i++ {
|
||||
part, stop, chatErr := gpt.chat(msg, contextMsgs)
|
||||
buf.WriteString(part)
|
||||
|
||||
|
|
|
|||
|
|
@ -420,6 +420,9 @@ func InitConf() {
|
|||
if 0 >= Conf.AI.OpenAI.APITemperature || 2 < Conf.AI.OpenAI.APITemperature {
|
||||
Conf.AI.OpenAI.APITemperature = 1.0
|
||||
}
|
||||
if 1 > Conf.AI.OpenAI.APIMaxContexts || 64 < Conf.AI.OpenAI.APIMaxContexts {
|
||||
Conf.AI.OpenAI.APIMaxContexts = 7
|
||||
}
|
||||
|
||||
if "" != Conf.AI.OpenAI.APIKey {
|
||||
logging.LogInfof("OpenAI API enabled\n"+
|
||||
|
|
@ -429,14 +432,16 @@ func InitConf() {
|
|||
" proxy=%s\n"+
|
||||
" model=%s\n"+
|
||||
" maxTokens=%d\n"+
|
||||
" temperature=%.1f",
|
||||
" temperature=%.1f\n"+
|
||||
" maxContexts=%d",
|
||||
Conf.AI.OpenAI.APIUserAgent,
|
||||
Conf.AI.OpenAI.APIBaseURL,
|
||||
Conf.AI.OpenAI.APITimeout,
|
||||
Conf.AI.OpenAI.APIProxy,
|
||||
Conf.AI.OpenAI.APIModel,
|
||||
Conf.AI.OpenAI.APIMaxTokens,
|
||||
Conf.AI.OpenAI.APITemperature)
|
||||
Conf.AI.OpenAI.APITemperature,
|
||||
Conf.AI.OpenAI.APIMaxContexts)
|
||||
}
|
||||
|
||||
Conf.ReadOnly = util.ReadOnly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue