diff --git a/applogic/flow.go b/applogic/flow.go index 278fe7e..077b749 100644 --- a/applogic/flow.go +++ b/applogic/flow.go @@ -46,7 +46,7 @@ func (app *App) ApplyPromptChoiceQ(promptstr string, requestmsg *string, message // 计算当前对话轮次 currentRound := PromptMarksLength - CustomRecord.PromptStrStat + 1 - fmt.Printf("故事模式:当前对话轮次Q %v", currentRound) + fmt.Printf("故事模式:当前对话轮次Q %v\n", currentRound) enhancedChoices := config.GetEnhancedPromptChoices(promptstr) if enhancedChoices { @@ -148,10 +148,10 @@ func (app *App) ApplySwitchOnQ(promptstr *string, requestmsg *string, message *s // 计算当前对话轮次 currentRound := PromptMarksLength - CustomRecord.PromptStrStat + 1 - fmt.Printf("关键词切换分支状态:当前对话轮次Q %v,当前promptstr:%v", currentRound, promptstr) + fmt.Printf("关键词切换分支状态:当前对话轮次Q %v,当前promptstr:%v\n", currentRound, promptstr) enhancedChoices := config.GetEnhancedPromptChoices(*promptstr) - fmt.Printf("关键词切换分支状态:%v", enhancedChoices) + fmt.Printf("关键词切换分支状态:%v\n", enhancedChoices) if enhancedChoices { // 遍历所有的promptChoices配置项 for _, choice := range promptstrChoices { diff --git a/prompt/prompt.go b/prompt/prompt.go index e4300f5..e214850 100644 --- a/prompt/prompt.go +++ b/prompt/prompt.go @@ -171,6 +171,8 @@ func FindFirstSystemMessage(history []structs.Message) (structs.Message, error) } // 返回除了 "system" 角色之外的所有消息 +// GetMessagesExcludingSystem returns a list of messages that are not of "system" role, +// randomly selecting from options separated by "||" in prompt contents. func GetMessagesExcludingSystem(basename string) ([]structs.Message, error) { lock.RLock() defer lock.RUnlock() @@ -184,21 +186,12 @@ func GetMessagesExcludingSystem(basename string) ([]structs.Message, error) { var history []structs.Message for _, prompt := range promptFile.Prompts { if prompt.Role != "system" && prompt.Role != "System" { - // Check if Content contains || and create a separate message for each part - if strings.Contains(prompt.Content, "||") { - contents := strings.Split(prompt.Content, "||") - for _, content := range contents { - history = append(history, structs.Message{ - Text: strings.TrimSpace(content), // Trim spaces for clean message text - Role: prompt.Role, - }) - } - } else { - history = append(history, structs.Message{ - Text: prompt.Content, - Role: prompt.Role, - }) - } + // Check if Content contains || and randomly select one part + content := chooseRandomContent(prompt.Content) + history = append(history, structs.Message{ + Text: content, + Role: prompt.Role, + }) } }