mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-16 13:45:29 +01:00
🎨 AI supports configuration randomness and context number https://github.com/siyuan-note/siyuan/issues/10660
This commit is contained in:
parent
97e3ff656d
commit
a7e1e3abac
12 changed files with 66 additions and 16 deletions
|
|
@ -170,7 +170,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, Conf.AI.OpenAI.APIModel, Conf.AI.OpenAI.APIMaxTokens, Conf.AI.OpenAI.APITimeout)
|
||||
return util.ChatGPT(msg, contextMsgs, gpt.c, Conf.AI.OpenAI.APIModel, Conf.AI.OpenAI.APIMaxTokens, Conf.AI.OpenAI.APITemperature, Conf.AI.OpenAI.APITimeout)
|
||||
}
|
||||
|
||||
type CloudGPT struct {
|
||||
|
|
|
|||
|
|
@ -408,9 +408,18 @@ func InitConf() {
|
|||
if "" == Conf.AI.OpenAI.APIUserAgent {
|
||||
Conf.AI.OpenAI.APIUserAgent = util.UserAgent
|
||||
}
|
||||
if strings.HasPrefix(Conf.AI.OpenAI.APIUserAgent, "SiYuan/") {
|
||||
Conf.AI.OpenAI.APIUserAgent = util.UserAgent
|
||||
}
|
||||
if "" == Conf.AI.OpenAI.APIProvider {
|
||||
Conf.AI.OpenAI.APIProvider = "OpenAI"
|
||||
}
|
||||
if 0 > Conf.AI.OpenAI.APIMaxTokens {
|
||||
Conf.AI.OpenAI.APIMaxTokens = 0
|
||||
}
|
||||
if 0 >= Conf.AI.OpenAI.APITemperature || 2 < Conf.AI.OpenAI.APITemperature {
|
||||
Conf.AI.OpenAI.APITemperature = 1.0
|
||||
}
|
||||
|
||||
if "" != Conf.AI.OpenAI.APIKey {
|
||||
logging.LogInfof("OpenAI API enabled\n"+
|
||||
|
|
@ -419,13 +428,15 @@ func InitConf() {
|
|||
" timeout=%ds\n"+
|
||||
" proxy=%s\n"+
|
||||
" model=%s\n"+
|
||||
" maxTokens=%d",
|
||||
" maxTokens=%d\n"+
|
||||
" temperature=%.1f",
|
||||
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.APIMaxTokens,
|
||||
Conf.AI.OpenAI.APITemperature)
|
||||
}
|
||||
|
||||
Conf.ReadOnly = util.ReadOnly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue