ai_scheduler/tmp_fix_order.go

50 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//go:build ignore
package main
import (
"os"
"strings"
)
func main() {
f := "internal/biz/advice_chat.go"
b, _ := os.ReadFile(f)
s := string(b)
// Fix buildChatPromptResponse: put output format AFTER everything
old := ` Content: a.taskPrompt(session) + outputFormatHint,`
new := ` Content: a.taskPrompt(session) + "\n" + outputFormatHint,`
// Actually the real fix: taskPrompt already has mission, we just need
// to ensure outputFormatHint is separated by a newline for clarity.
// But the real structural issue is that taskPrompt dumps everything.
// Let's restructure: taskPrompt returns context only,
// buildChatPromptResponse assembles: context + mission + format
// Revert taskPrompt to NOT include mission
oldTask := ` // 注入 mission(含人格 + 项目信息),确保每次 Chat 模型都能看到
if session.Mission != "" {
b.WriteString("\n" + session.Mission)
}
return b.String()`
newTask := ` return b.String()`
if strings.Contains(s, oldTask) {
s = strings.Replace(s, oldTask, newTask, 1)
println("reverted taskPrompt")
}
// Now fix buildChatPromptResponse to include mission BEFORE output format
oldBuild := ` Content: a.taskPrompt(session) + outputFormatHint,`
newBuild := ` Content: a.taskPrompt(session) + "\n" + session.Mission + outputFormatHint,`
if strings.Contains(s, oldBuild) {
s = strings.Replace(s, oldBuild, newBuild, 1)
println("fixed buildChatPromptResponse order")
}
os.WriteFile(f, []byte(s), 0644)
println("done")
}