diff --git a/AI/Text2Sql/Sql/CreateTable.sql b/AI/Text2Sql/Sql/AreaSchoolLesson.sql similarity index 100% rename from AI/Text2Sql/Sql/CreateTable.sql rename to AI/Text2Sql/Sql/AreaSchoolLesson.sql diff --git a/AI/Text2Sql/Start.py b/AI/Text2Sql/Start.py index 2f7da1c9..397d41f6 100644 --- a/AI/Text2Sql/Start.py +++ b/AI/Text2Sql/Start.py @@ -101,7 +101,7 @@ if __name__ == "__main__": # 开始训练 print("开始训练...") # 打开CreateTable.sql文件内容 - with open("Sql/CreateTable.sql", "r", encoding="utf-8") as file: + with open("Sql/AreaSchoolLesson.sql", "r", encoding="utf-8") as file: ddl = file.read() # 训练数据 vn.train( diff --git a/AI/Text2Sql/Test/YunXiao_Deepseek.py b/AI/Text2Sql/Test/YunXiao_Deepseek.py index a074bd8d..4f5620e5 100644 --- a/AI/Text2Sql/Test/YunXiao_Deepseek.py +++ b/AI/Text2Sql/Test/YunXiao_Deepseek.py @@ -42,8 +42,8 @@ def generate_sql_from_prompt(ddl: str, prompt: str) -> str: raise ValueError("未能生成 SQL 查询") if __name__ == '__main__': - # 读取 Sql/CreateTable.sql 文件 - with open("../Sql/CreateTable.sql", "r", encoding="utf-8") as file: + # 读取 Sql/AreaSchoolLesson.sql 文件 + with open("../Sql/AreaSchoolLesson.sql", "r", encoding="utf-8") as file: ddl = file.read() # 自然语言描述 diff --git a/AI/Text2Sql/YunXiao.py b/AI/Text2Sql/YunXiao.py index 9ed3d47a..7b083566 100644 --- a/AI/Text2Sql/YunXiao.py +++ b/AI/Text2Sql/YunXiao.py @@ -15,7 +15,7 @@ if __name__ == "__main__": # 开始训练 print("开始训练...") # 打开CreateTable.sql文件内容 - with open("Sql/CreateTable.sql", "r", encoding="utf-8") as file: + with open("Sql/AreaSchoolLesson.sql", "r", encoding="utf-8") as file: ddl = file.read() # 训练数据 vn.train( @@ -23,16 +23,35 @@ if __name__ == "__main__": ) # 自然语言提问 - # ''' + # 整体情况 question = ''' 查询: 1、发布时间是2024年度 2、每个行政区每个学校都上传了多少课程数量 3、格式: 行政区划名,学段,排名,学校名称,课程数量 ''' + + # 指定行政区域 + # question = ''' + # 查询: + # 1、发布时间是2024年度 + # 2、二道区每个学校都上传了多少课程数量 + # 3、格式: 行政区划名,学段,排名,学校名称,发布年份,课程数量 + # ''' + + # 指定学段 + # question = ''' + # 查询: + # 1、发布时间是2024年度 + # 2、每个学段,每个科目,上传课程数量,按由多到少排序 + # 3、字段名: 学段,科目,排名,课程数量 + # ''' common_prompt = ''' - 要求: + 返回的信息要求: 1、行政区划为NULL 或者是空字符的不参加统计 + 2、目标数据库是Postgresql 16,注意字段名称不要有二义性问题 + 3、使用stage_name描述学段,一定不要使用stage_id + 4、使用subject_name描述科目,一定不要使用subject_id ''' question = question + common_prompt # 开始查询