diff --git a/AI/Config.py b/AI/Config.py index 4979f5bd..8b590938 100644 --- a/AI/Config.py +++ b/AI/Config.py @@ -1,27 +1,27 @@ from pathlib import Path # 固定配置项 -# 阿里云中用来调用deepseek r1的密钥 MODEL_API_KEY = "sk-01d13a39e09844038322108ecdbd1bbc" -MODEL_API_URL= 'https://dashscope.aliyuncs.com/compatible-mode/v1' +MODEL_API_URL = 'https://dashscope.aliyuncs.com/compatible-mode/v1' MODEL_NAME = "deepseek-v3" -QWEN_MODEL_NAME='qwen-plus' +MODEL_GENERATION_TEXT_URL = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" # 阿里云文本生成服务 +QWEN_MODEL_NAME = 'qwen-plus' # 华为云 -HW_API_KEY='2R7vrjfIZO1chcfk4V3zDscx2Ms4I4kdoY7XSFnxa8Z2RNfAztg8qrXXKkwJGZWvMtS4qnN782WmaY4xZfMhyg' -HW_API_URL= url = "https://infer-modelarts-cn-southwest-2.modelarts-infer.com/v1/infers/952e4f88-ef93-4398-ae8d-af37f63f0d8e/v1/chat/completions" -HW_MODEL_NAME='DeepSeek-R1' +HW_API_KEY = '2R7vrjfIZO1chcfk4V3zDscx2Ms4I4kdoY7XSFnxa8Z2RNfAztg8qrXXKkwJGZWvMtS4qnN782WmaY4xZfMhyg' +HW_API_URL = url = "https://infer-modelarts-cn-southwest-2.modelarts-infer.com/v1/infers/952e4f88-ef93-4398-ae8d-af37f63f0d8e/v1/chat/completions" +HW_MODEL_NAME = 'DeepSeek-R1' # 阿里云的配置信息 -ALY_AK='LTAI5tE4tgpGcKWhbZg6C4bh' -ALY_SK='oizcTOZ8izbGUouboC00RcmGE8vBQ1' +ALY_AK = 'LTAI5tE4tgpGcKWhbZg6C4bh' +ALY_SK = 'oizcTOZ8izbGUouboC00RcmGE8vBQ1' # 正确路径拼接方式 mdWorkingPath = Path(__file__).parent / 'md-file' / 'readme' DEFAULT_TEMPLATE = mdWorkingPath / 'default.md' # 使用 / 运算符 -DEFAULT_OUTPUT_DIR = mdWorkingPath / 'output' # 使用 / 运算符 +DEFAULT_OUTPUT_DIR = mdWorkingPath / 'output' # 使用 / 运算符 # 请在Config.py中配置以下参数 NEO4J_URI = "neo4j://10.10.21.20:7687" -NEO4J_AUTH = ("neo4j", "DsideaL4r5t6y7u") \ No newline at end of file +NEO4J_AUTH = ("neo4j", "DsideaL4r5t6y7u") diff --git a/AI/Text2Sql/Test/chroma.sqlite3 b/AI/Text2Sql/Test/chroma.sqlite3 new file mode 100644 index 00000000..bea4a154 Binary files /dev/null and b/AI/Text2Sql/Test/chroma.sqlite3 differ diff --git a/AI/Text2Sql/Util/Text2SqlUtil.py b/AI/Text2Sql/Util/VannaUtil.py similarity index 91% rename from AI/Text2Sql/Util/Text2SqlUtil.py rename to AI/Text2Sql/Util/VannaUtil.py index 9ecb3b5a..3dfe7df1 100644 --- a/AI/Text2Sql/Util/Text2SqlUtil.py +++ b/AI/Text2Sql/Util/VannaUtil.py @@ -4,14 +4,13 @@ import requests from vanna.base import VannaBase from Config import * -class DeepSeekVanna(VannaBase): + +class VannaUtil(VannaBase): def __init__(self): super().__init__() self.api_key = MODEL_API_KEY - self.base_url = "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation" # 阿里云专用API地址 + self.base_url = MODEL_GENERATION_TEXT_URL # 阿里云专用API地址 self.model = QWEN_MODEL_NAME # 根据实际模型名称调整 - #self.base_url= MODEL_API_URL, - #self.model = MODEL_NAME self.training_data = [] self.chat_history = [] @@ -57,14 +56,12 @@ class DeepSeekVanna(VannaBase): def get_similar_question_sql(self, question: str, **kwargs) -> List[Dict[str, Any]]: return [] - - def _clean_sql_output(self, raw_sql: str) -> str: """增强版清洗逻辑""" # 移除所有非SQL内容 - cleaned = re.sub(r'^.*?(?=SELECT)', '', raw_sql, flags=re.IGNORECASE|re.DOTALL) + cleaned = re.sub(r'^.*?(?=SELECT)', '', raw_sql, flags=re.IGNORECASE | re.DOTALL) # 提取第一个完整SQL语句 - match = re.search(r'(SELECT\s.+?;)', cleaned, re.IGNORECASE|re.DOTALL) + match = re.search(r'(SELECT\s.+?;)', cleaned, re.IGNORECASE | re.DOTALL) if match: # 标准化空格和换行 clean_sql = re.sub(r'\s+', ' ', match.group(1)).strip() diff --git a/AI/Text2Sql/Util/__pycache__/Text2SqlUtil.cpython-310.pyc b/AI/Text2Sql/Util/__pycache__/Text2SqlUtil.cpython-310.pyc deleted file mode 100644 index ea6349f8..00000000 Binary files a/AI/Text2Sql/Util/__pycache__/Text2SqlUtil.cpython-310.pyc and /dev/null differ diff --git a/AI/Text2Sql/Util/__pycache__/VannaUtil.cpython-310.pyc b/AI/Text2Sql/Util/__pycache__/VannaUtil.cpython-310.pyc new file mode 100644 index 00000000..0cc2ffe9 Binary files /dev/null and b/AI/Text2Sql/Util/__pycache__/VannaUtil.cpython-310.pyc differ diff --git a/AI/Text2Sql/YunXiao.py b/AI/Text2Sql/YunXiao.py index d3fa248f..662cfc0a 100644 --- a/AI/Text2Sql/YunXiao.py +++ b/AI/Text2Sql/YunXiao.py @@ -5,7 +5,7 @@ from openai import OpenAI from Text2Sql.Util.MarkdownToDocxUtil import markdown_to_docx from Text2Sql.Util.PostgreSQLUtil import PostgreSQLUtil from Text2Sql.Util.SaveToExcel import save_to_excel -from Text2Sql.Util.Text2SqlUtil import * +from Text2Sql.Util.VannaUtil import * from Util.EchartsUtil import * @@ -16,7 +16,7 @@ from Util.EchartsUtil import * 3、应该有类似于 保存为用例,查询历史等功能,让用户方便利旧。 ''' if __name__ == "__main__": - vn = DeepSeekVanna() + vn = VannaUtil() # 开始训练 print("开始训练...") diff --git a/AI/__pycache__/Config.cpython-310.pyc b/AI/__pycache__/Config.cpython-310.pyc index 9c09d663..689b1e93 100644 Binary files a/AI/__pycache__/Config.cpython-310.pyc and b/AI/__pycache__/Config.cpython-310.pyc differ