fix: 移除 session 自动继承和异步向量生成
This commit is contained in:
@@ -27,12 +27,7 @@ func GetContextPrompt(userInput string) string {
|
|||||||
|
|
||||||
session := currentSession
|
session := currentSession
|
||||||
if session == nil {
|
if session == nil {
|
||||||
var err error
|
return "" // 没有 session,不提供上下文
|
||||||
session, err = db.GetLatestSession()
|
|
||||||
if err != nil || session == nil {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
currentSession = session
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var context string
|
var context string
|
||||||
@@ -254,7 +249,7 @@ func SaveChat(userInput, aiReply string, useSessionSummary bool) (int, error) {
|
|||||||
// 生成并保存向量
|
// 生成并保存向量
|
||||||
vs := GetVectorService()
|
vs := GetVectorService()
|
||||||
if vs != nil && memoryCfg.Vector.APIKey != "" {
|
if vs != nil && memoryCfg.Vector.APIKey != "" {
|
||||||
go generateEmbedding(chat)
|
generateEmbedding(chat)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := db.UpdateChat(chat); err != nil {
|
if err := db.UpdateChat(chat); err != nil {
|
||||||
@@ -272,7 +267,7 @@ func SaveChat(userInput, aiReply string, useSessionSummary bool) (int, error) {
|
|||||||
|
|
||||||
// Session 也要生成向量
|
// Session 也要生成向量
|
||||||
if vs != nil && memoryCfg.Vector.APIKey != "" && useSessionSummary {
|
if vs != nil && memoryCfg.Vector.APIKey != "" && useSessionSummary {
|
||||||
go generateSessionEmbedding(session)
|
generateSessionEmbedding(session)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := db.UpdateSession(session); err != nil {
|
if err := db.UpdateSession(session); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user