Skip to content

Commit

Permalink
Beta95 (#95)
Browse files Browse the repository at this point in the history
* 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

* beat48

* beta49

* beta50

* beta51

* beta52

* beta53

* beta54

* beta55

* beta57

* beta58

* beta59

* beta61

* beta62

* beta63

* beta63

* beta64

* beta65

* beta66

* beta67

* beta70

* beta71

* beta72

* beta72

* beta74

* beta75

* beta76

* beta77

* beta78

* beta79

* beta80

* beta81

* beta82

* beta83

* beta85

* beta86

* beta87

* beta88

* beta89

* beta90

* beta91

* beta92

* beta93

* beta94

* beta94
  • Loading branch information
Hoshinonyaruko authored Apr 29, 2024
1 parent b7514c0 commit 4480176
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions applogic/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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配置项
Expand Down Expand Up @@ -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)
}
}
}
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
}
}
Expand All @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions applogic/gensokyo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4480176

Please sign in to comment.