mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-20 07:16:10 +01:00
This commit is contained in:
parent
ba400854b0
commit
69c18db9ed
4 changed files with 81 additions and 9 deletions
|
|
@ -23,20 +23,32 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func ChatGPTSummary(ids []string) (ret string) {
|
||||
if !isOpenAIAPIEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
msg := getBlocksContent(ids)
|
||||
ret = util.ChatGPTSummary(msg, Conf.Lang)
|
||||
return
|
||||
}
|
||||
|
||||
func ChatGPTTranslate(ids []string, lang string) (ret string) {
|
||||
if !isOpenAIAPIEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
msg := getBlocksContent(ids)
|
||||
ret = util.ChatGPTTranslate(msg, lang)
|
||||
return
|
||||
}
|
||||
|
||||
func ChatGPTContinueWriteBlocks(ids []string) (ret string) {
|
||||
if !isOpenAIAPIEnabled() {
|
||||
return
|
||||
}
|
||||
|
||||
sqlBlocks := sql.GetBlocks(ids)
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
for _, sqlBlock := range sqlBlocks {
|
||||
buf.WriteString(sqlBlock.Content)
|
||||
buf.WriteString("\n\n")
|
||||
}
|
||||
|
||||
msg := buf.String()
|
||||
msg := getBlocksContent(ids)
|
||||
ret, _ = util.ChatGPTContinueWrite(msg, nil)
|
||||
return
|
||||
}
|
||||
|
|
@ -56,3 +68,14 @@ func isOpenAIAPIEnabled() bool {
|
|||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getBlocksContent(ids []string) string {
|
||||
sqlBlocks := sql.GetBlocks(ids)
|
||||
buf := bytes.Buffer{}
|
||||
for _, sqlBlock := range sqlBlocks {
|
||||
buf.WriteString(sqlBlock.Content)
|
||||
buf.WriteString("\n\n")
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue