@@ -8,10 +8,6 @@ import (
88 "github.com/cloudwego/eino/schema"
99)
1010
11- const (
12- UnrelatedQuestion = "不相关的问题,请重新提问"
13- )
14-
1511func createTemplate () prompt.ChatTemplate {
1612 // 创建模板,使用 FString 格式
1713 return prompt .FromMessages (schema .FString ,
@@ -28,13 +24,10 @@ func createTemplate() prompt.ChatTemplate {
2824 "Also, pay attention to which column is in which table." +
2925 "Pay attention to use CURDATE() function to get the current date, if the question involves \" today\" ." +
3026 "Can only perform queries and does not accept any modification or deletion functions." +
31- "Use the following table schema info to create your SQL query:\n {ddl}" +
32- "返回内容只能包含SQL语句,不包含解释及其他信息也不要加上sql标签。" ,
33- // "通过分析用户的提问与数据库表结构之间的关系,生成相应的SQL查询语句。如果提问的内容与现有的数据库表结构没有任何关联,返回:\"{unrelated}\"。",
27+ "Use the following table schema info to create your SQL query:\n {ddl}\n " +
28+ "The returned content can only contain SQL statements, without explanations or other information, and should not be labeled with SQL tags." ,
3429 ),
35- // 插入需要的对话历史(新对话的话这里不填)
3630 schema .MessagesPlaceholder ("chat_history" , true ),
37-
3831 // 用户消息模板
3932 schema .UserMessage ("Question: {question}" ),
4033 )
@@ -44,8 +37,7 @@ func createMessagesFromTemplate(ddl, question string) []*schema.Message {
4437 template := createTemplate ()
4538 // 使用模板生成消息
4639 messages , err := template .Format (context .Background (), map [string ]any {
47- "role" : "You are a MySQL expert." ,
48- // "unrelated": UnrelatedQuestion,
40+ "role" : "You are a MySQL expert." ,
4941 "question" : question ,
5042 "ddl" : ddl ,
5143 "limit" : 10 ,
0 commit comments