فهرست منبع

修改大模型提示词

Gaokun Wang 4 ماه پیش
والد
کامیت
ca2669985b

+ 9 - 9
eco-ai/ai-text-sql-biz/src/main/java/org/eco/vip/ai/text2sql/service/Text2SqlService.java

@@ -15,7 +15,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.eco.vip.ai.text2sql.domain.CommentVo;
 import org.eco.vip.ai.text2sql.mapper.Text2SqlMapper;
 import org.eco.vip.ai.text2sql.utils.SqlValidator;
-import org.eco.vip.orm.utils.DataBaseHelper;
+import org.eco.vip.orm.utils.DBaseHelper;
 import org.eco.vip.text2sql.domain.ContentVo;
 import org.springframework.stereotype.Service;
 
@@ -50,9 +50,9 @@ public class Text2SqlService implements IText2SqlService {
 
     @Override
     public List<CommentVo> commentByTableName(String schema, String tableName) {
-        if (DataBaseHelper.isMySql()) {
+        if (DBaseHelper.isMySql()) {
             return text2SqlMapper.selectCommentsByMysql(schema, tableName);
-        } else if (DataBaseHelper.isDmSql()) {
+        } else if (DBaseHelper.isDmSql()) {
             return text2SqlMapper.selectCommentsByDm(schema, tableName);
         }
         return Collections.emptyList();
@@ -87,7 +87,7 @@ public class Text2SqlService implements IText2SqlService {
             return new JSONArray().put("只支持查询");
         }
         List<Map<String, Object>> mapList = text2SqlMapper.executeSql(sql);
-        List<CommentVo> tableNames = this.commentByTableName(DataBaseHelper.getSchema(), question.getTableName());
+        List<CommentVo> tableNames = this.commentByTableName(DBaseHelper.getSchema(), question.getTableName());
         return this.getCommentData(mapList, tableNames);
     }
 
@@ -95,16 +95,16 @@ public class Text2SqlService implements IText2SqlService {
     public ContentVo getQuestion(String question) {
         String tableName = this.tableNameByNl(question);
         Map<String, String> map = Collections.emptyMap();
-        if (DataBaseHelper.isMySql()) {
+        if (DBaseHelper.isMySql()) {
             map = text2SqlMapper.selectTableDdlByMysql(tableName);
-        } else if (DataBaseHelper.isDmSql()) {
-            map = text2SqlMapper.selectTableDdlDm(DataBaseHelper.getSchema(), tableName);
+        } else if (DBaseHelper.isDmSql()) {
+            map = text2SqlMapper.selectTableDdlDm(DBaseHelper.getSchema(), tableName);
         }
         String ddl = map.get("create table");
-        return ContentVo.builder().content(ddl + "\n" + question + ",根据需求生成Mysql的查询SQL.\n" +
+        return ContentVo.builder().content(ddl + "\n" + question + ",根据需求生成" + DBaseHelper.getDbType() + "的查询SQL.\n" +
                         "1.不要需求外的条件.\n" +
                         "2.只输出sql语句不需要任何格式样式,就是一串sql.\n" +
-                        "3.不需要带Schema:" + DataBaseHelper.getSchema()).
+                        "3.不需要带Schema:" + DBaseHelper.getSchema()).
                 tableName(tableName).build();
 
     }

+ 6 - 2
eco-common/com-orm/src/main/java/org/eco/vip/orm/utils/DataBaseHelper.java → eco-common/com-orm/src/main/java/org/eco/vip/orm/utils/DBaseHelper.java

@@ -14,11 +14,11 @@ import java.sql.SQLException;
 
 /**
  * @author GaoKunW
- * @description DataBaseHelper
+ * @description DBaseHelper
  * @date 2025/3/16 03:28
  */
 @Slf4j
-public class DataBaseHelper {
+public class DBaseHelper {
     public static boolean isMySql() {
         return DbType.MYSQL == FlexGlobalConfig.getDefaultConfig().getDbType();
     }
@@ -27,6 +27,10 @@ public class DataBaseHelper {
         return DbType.DM == FlexGlobalConfig.getDefaultConfig().getDbType();
     }
 
+    public static String getDbType() {
+        return FlexGlobalConfig.getDefaultConfig().getDbType().getName();
+    }
+
     public static String getSchema() {
         try {
             return FlexGlobalConfig.getDefaultConfig().getDataSource().getConnection().getSchema();