diff --git a/applogic/flow.go b/applogic/flow.go index 163c04d..dfe8a97 100644 --- a/applogic/flow.go +++ b/applogic/flow.go @@ -132,9 +132,9 @@ func (app *App) ApplyPromptChoiceQ(promptstr string, requestmsg *string, message } // ApplySwitchOnQ 应用switchOnQ的逻辑,动态修改promptstr -func (app *App) ApplySwitchOnQ(promptstr string, requestmsg *string, message *structs.OnebotGroupMessage) { +func (app *App) ApplySwitchOnQ(promptstr *string, requestmsg *string, message *structs.OnebotGroupMessage) { // promptstr 随 switchOnQ 变化 - promptstrChoices := config.GetSwitchOnQ(promptstr) + promptstrChoices := config.GetSwitchOnQ(*promptstr) if len(promptstrChoices) != 0 { // 获取用户剧情存档中的当前状态 CustomRecord, err := app.FetchCustomRecord(message.UserID) @@ -144,13 +144,13 @@ func (app *App) ApplySwitchOnQ(promptstr string, requestmsg *string, message *st } // 获取当前场景的总对话长度 - PromptMarksLength := config.GetPromptMarksLength(promptstr) + PromptMarksLength := config.GetPromptMarksLength(*promptstr) // 计算当前对话轮次 currentRound := PromptMarksLength - CustomRecord.PromptStrStat + 1 fmt.Printf("关键词切换分支状态:当前对话轮次Q %v,当前promptstr:%v", currentRound, promptstr) - enhancedChoices := config.GetEnhancedPromptChoices(promptstr) + enhancedChoices := config.GetEnhancedPromptChoices(*promptstr) fmt.Printf("关键词切换分支状态:%v", enhancedChoices) if enhancedChoices { // 遍历所有的promptChoices配置项 @@ -188,13 +188,13 @@ func (app *App) ApplySwitchOnQ(promptstr string, requestmsg *string, message *st } // 如果找到了有效的触发词组合,修改分支 if bestMatchCount > 0 { - promptstr = bestText + *promptstr = bestText // 获取新的信号长度 刷新持久化数据库 - PromptMarksLength := config.GetPromptMarksLength(promptstr) - app.InsertCustomTableRecord(message.UserID, promptstr, PromptMarksLength) - fmt.Printf("enhancedChoices=true,根据关键词切换prompt为: %s,newPromptStrStat:%d\n", promptstr, PromptMarksLength) + PromptMarksLength := config.GetPromptMarksLength(*promptstr) + app.InsertCustomTableRecord(message.UserID, *promptstr, PromptMarksLength) + fmt.Printf("enhancedChoices=true,根据关键词切换prompt为: %s,newPromptStrStat:%d\n", *promptstr, PromptMarksLength) // 故事模式规则 应用 PromptChoiceQ 这一次是为了,替换了分支后,再次用新的分支的promptstr处理一次,因为原先的promptstr是跳转前,要用跳转后的再替换一次 - app.ApplyPromptChoiceQ(promptstr, requestmsg, message) + app.ApplyPromptChoiceQ(*promptstr, requestmsg, message) } } } @@ -213,13 +213,13 @@ func (app *App) ApplySwitchOnQ(promptstr string, requestmsg *string, message *st texts := strings.Split(addedTexts, "-") if len(texts) > 0 { selectedText := texts[rand.Intn(len(texts))] // 随机选择一个文本 - promptstr = selectedText + *promptstr = selectedText // 获取新的信号长度 刷新持久化数据库 - PromptMarksLength := config.GetPromptMarksLength(promptstr) - app.InsertCustomTableRecord(message.UserID, promptstr, PromptMarksLength) - fmt.Printf("enhancedChoices=false,根据关键词切换prompt为: %s,newPromptStrStat:%d\n", promptstr, PromptMarksLength) + PromptMarksLength := config.GetPromptMarksLength(*promptstr) + app.InsertCustomTableRecord(message.UserID, *promptstr, PromptMarksLength) + fmt.Printf("enhancedChoices=false,根据关键词切换prompt为: %s,newPromptStrStat:%d\n", *promptstr, PromptMarksLength) // 故事模式规则 应用 PromptChoiceQ 这一次是为了,替换了分支后,再次用新的分支的promptstr处理一次,因为原先的promptstr是跳转前,要用跳转后的再替换一次 - app.ApplyPromptChoiceQ(promptstr, requestmsg, message) + app.ApplyPromptChoiceQ(*promptstr, requestmsg, message) } } } @@ -399,9 +399,9 @@ func (app *App) ProcessExitChoicesA(promptstr string, response *string, message } // ApplySwitchOnA 应用switchOnA的逻辑,动态修改promptstr -func (app *App) ApplySwitchOnA(promptstr string, response *string, message *structs.OnebotGroupMessage) { +func (app *App) ApplySwitchOnA(promptstr *string, response *string, message *structs.OnebotGroupMessage) { // 获取与 switchOnA 相关的选择 - promptstrChoices := config.GetSwitchOnA(promptstr) + promptstrChoices := config.GetSwitchOnA(*promptstr) if len(promptstrChoices) != 0 { // 获取用户剧情存档中的当前状态 CustomRecord, err := app.FetchCustomRecord(message.UserID) @@ -411,13 +411,13 @@ func (app *App) ApplySwitchOnA(promptstr string, response *string, message *stru } // 获取当前场景的总对话长度 - PromptMarksLength := config.GetPromptMarksLength(promptstr) + PromptMarksLength := config.GetPromptMarksLength(*promptstr) // 计算当前对话轮次 currentRound := PromptMarksLength - CustomRecord.PromptStrStat + 1 fmt.Printf("关键词[%v]切换分支状态:当前对话轮次A %v", *response, currentRound) - enhancedChoices := config.GetEnhancedPromptChoices(promptstr) + enhancedChoices := config.GetEnhancedPromptChoices(*promptstr) fmt.Printf("关键词切换分支状态:%v", enhancedChoices) if enhancedChoices { for _, choice := range promptstrChoices { @@ -448,10 +448,10 @@ func (app *App) ApplySwitchOnA(promptstr string, response *string, message *stru } } if bestMatchCount > 0 { - promptstr = bestText - PromptMarksLength := config.GetPromptMarksLength(promptstr) - app.InsertCustomTableRecord(message.UserID, promptstr, PromptMarksLength) - fmt.Printf("enhancedChoices=true,根据关键词A切换prompt为: %s,newPromptStrStat:%d\n", promptstr, PromptMarksLength) + *promptstr = bestText + PromptMarksLength := config.GetPromptMarksLength(*promptstr) + app.InsertCustomTableRecord(message.UserID, *promptstr, PromptMarksLength) + fmt.Printf("enhancedChoices=true,根据关键词A切换prompt为: %s,newPromptStrStat:%d\n", *promptstr, PromptMarksLength) } } } @@ -468,10 +468,10 @@ func (app *App) ApplySwitchOnA(promptstr string, response *string, message *stru texts := strings.Split(addedTexts, "-") if len(texts) > 0 { selectedText := texts[rand.Intn(len(texts))] // 随机选择一个文本 - promptstr = selectedText - PromptMarksLength := config.GetPromptMarksLength(promptstr) - app.InsertCustomTableRecord(message.UserID, promptstr, PromptMarksLength) - fmt.Printf("enhancedChoices=false,根据关键词A切换prompt为: %s,newPromptStrStat:%d\n", promptstr, PromptMarksLength) + *promptstr = selectedText + PromptMarksLength := config.GetPromptMarksLength(*promptstr) + app.InsertCustomTableRecord(message.UserID, *promptstr, PromptMarksLength) + fmt.Printf("enhancedChoices=false,根据关键词A切换prompt为: %s,newPromptStrStat:%d\n", *promptstr, PromptMarksLength) } } } diff --git a/applogic/gensokyo.go b/applogic/gensokyo.go index e6e7105..af021ee 100644 --- a/applogic/gensokyo.go +++ b/applogic/gensokyo.go @@ -451,7 +451,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) { app.ApplyPromptChoiceQ(promptstr, &requestmsg, &message) // promptstr 随 switchOnQ 变化 切换Q - app.ApplySwitchOnQ(promptstr, &requestmsg, &message) + app.ApplySwitchOnQ(&promptstr, &requestmsg, &message) fmtf.Printf("实际请求conversation端点内容:[%v]%v\n", message.UserID, requestmsg) @@ -747,7 +747,7 @@ func (app *App) GensokyoHandler(w http.ResponseWriter, r *http.Request) { // 这里的代码也会继续运行,不会影响本次请求的返回值 // promptstr 随 switchOnA 变化 切换A - app.ApplySwitchOnA(promptstr, &requestmsg, &message) + app.ApplySwitchOnA(&promptstr, &requestmsg, &message) case map[string]interface{}: // message.Message是一个map[string]interface{} fmtf.Println("Received map message, handling not implemented yet")