-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* beta1 * beta2 * beta3 * beta4 * beta5 * beta6 * beta7 * beta8 * beta9 * beta10 * beta11 * beta12 * beta13 * beta14 * beta15 * beta16 * beta16 * beta19 * beta20 * beta21 * beta22 * beta23 * beta24 * beta25 * beta27 * beta28 * beta29 * beta30 * beta31 * beta33 * beta34 * beta35 * beta36 * beta37 * beta38 * beta39 * beta40 * beta41 * beta42 * beta43 * beta44 * beta45 * beta45 * beta46
- Loading branch information
1 parent
7930408
commit b55e758
Showing
10 changed files
with
310 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# specific | ||
config.yml | ||
*.yml | ||
*.sqlite | ||
*.txt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package applogic | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/hoshinonyaruko/gensokyo-llm/fmtf" | ||
"github.com/hoshinonyaruko/gensokyo-llm/structs" | ||
) | ||
|
||
// 直接根据缓存来储存上下文 | ||
// 其实向量缓存是一个单轮的QA缓存,因为这个项目很初步,很显然无法应对上下文场景的缓存 | ||
// 通过这种方式,将每次缓存的内容也加入上下文,可能会有一个初步的效果提升. | ||
func (app *App) AddSingleContext(message structs.OnebotGroupMessage, responseText string) bool { | ||
// 请求conversation api 增加当前用户上下文 | ||
conversationID, parentMessageID, err := app.handleUserContext(message.UserID) | ||
if err != nil { | ||
fmtf.Printf("error in AddSingleContext app.handleUserContex :%v", err) | ||
return false | ||
} | ||
|
||
// 构造用户消息并添加到上下文 | ||
userMessage := structs.Message{ | ||
ConversationID: conversationID, | ||
ParentMessageID: parentMessageID, | ||
Text: message.Message.(string), | ||
Role: "user", | ||
CreatedAt: time.Now().Format(time.RFC3339), | ||
} | ||
userMessageID, err := app.addMessage(userMessage) | ||
if err != nil { | ||
fmtf.Printf("error in AddSingleContext app.addMessage(userMessage) :%v", err) | ||
return false | ||
} | ||
|
||
// 构造助理消息并添加到上下文 | ||
assistantMessage := structs.Message{ | ||
ConversationID: conversationID, | ||
ParentMessageID: userMessageID, | ||
Text: responseText, | ||
Role: "assistant", | ||
CreatedAt: time.Now().Format(time.RFC3339), | ||
} | ||
_, err = app.addMessage(assistantMessage) | ||
if err != nil { | ||
fmtf.Printf("error in AddSingleContext app.addMessage(assistantMessage) :%v", err) | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.