mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-10 17:24:21 +01:00
🎨 Allow GPT Model selection in UI https://github.com/siyuan-note/siyuan/issues/8142
This commit is contained in:
parent
f6f3ebbcb2
commit
7daafcb3af
13 changed files with 63 additions and 19 deletions
|
|
@ -22,7 +22,7 @@ import (
|
|||
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/parse"
|
||||
gogpt "github.com/sashabaranov/go-gpt3"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
|
@ -154,11 +154,11 @@ type GPT interface {
|
|||
}
|
||||
|
||||
type OpenAIGPT struct {
|
||||
c *gogpt.Client
|
||||
c *openai.Client
|
||||
}
|
||||
|
||||
func (gpt *OpenAIGPT) chat(msg string, contextMsgs []string) (partRet string, stop bool, err error) {
|
||||
return util.ChatGPT(msg, contextMsgs, gpt.c, 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.APITimeout)
|
||||
}
|
||||
|
||||
type CloudGPT struct {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package model
|
|||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
|
@ -337,14 +338,18 @@ func InitConf() {
|
|||
if nil == Conf.AI {
|
||||
Conf.AI = conf.NewAI()
|
||||
}
|
||||
if "" == Conf.AI.OpenAI.APIModel {
|
||||
Conf.AI.OpenAI.APIModel = openai.GPT4
|
||||
}
|
||||
|
||||
if "" != Conf.AI.OpenAI.APIKey {
|
||||
logging.LogInfof("OpenAI API enabled\n"+
|
||||
" baseURL=%s\n"+
|
||||
" timeout=%ds\n"+
|
||||
" proxy=%s\n"+
|
||||
" model=%s\n"+
|
||||
" maxTokens=%d",
|
||||
Conf.AI.OpenAI.APIBaseURL, Conf.AI.OpenAI.APITimeout, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIMaxTokens)
|
||||
Conf.AI.OpenAI.APIBaseURL, Conf.AI.OpenAI.APITimeout, Conf.AI.OpenAI.APIProxy, Conf.AI.OpenAI.APIModel, Conf.AI.OpenAI.APIMaxTokens)
|
||||
}
|
||||
|
||||
Conf.ReadOnly = util.ReadOnly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue