Skip to content

Commit 1e61e7e

Browse files
committed
删除部分无用说明
1 parent fa94651 commit 1e61e7e

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

eino/message.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import (
88
"github.com/cloudwego/eino/schema"
99
)
1010

11-
const (
12-
UnrelatedQuestion = "不相关的问题,请重新提问"
13-
)
14-
1511
func 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,

text2sql.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package text2sql
22

33
import (
4-
"errors"
54
"log"
6-
"strings"
75

86
"github.com/wangle201210/text2sql/eino"
97
"github.com/wangle201210/text2sql/mysql"
@@ -24,10 +22,6 @@ func (x *Text2sql) Do(question string) (sql string, runResult map[string]interfa
2422
}
2523
ddl := db.GetDdl()
2624
sql = eino.GetSQL(ddl, question)
27-
if strings.HasPrefix(sql, eino.UnrelatedQuestion) {
28-
err = errors.New(sql)
29-
return
30-
}
3125
err = db.CheckSQL(sql)
3226
try := x.Try
3327
for err != nil && try > 0 {

0 commit comments

Comments
 (0)