eosphoros-ai / DB-GPT

AI Native Data App Development framework with AWEL(Agentic Workflow Expression Language) and Agents
http://docs.dbgpt.cn
MIT License
13.63k stars 1.82k forks source link

[Bug] [ChatData] In version 5.6 deployed by docker compose, when using chatdata, the Chinese annotation information of table_info is not read out and spliced ​​into prompt. #1575

Closed cattlesheep closed 3 months ago

cattlesheep commented 5 months ago

Search before asking

Operating system information

Linux

Python version information

=3.11

DB-GPT version

latest release

Related scenes

Installation Information

Device information

Device:GPU:-GPU count:1 -GPU Memory 40G

Models information

LLM:moonshot-v1-8k Embedding model:bge-large-zh-v1.5

What happened

我的MYSQL建表语句如下: create table if not exists yuanling.park_passenger_flow ( id int not null comment '索引ID' primary key, park text null comment '公园名称', region_id int null comment '区域ID', leave_num int null comment '离园总人数', uint text null comment '人数单位', monitor_date text null comment '监测日期,日期格示例如:2024年5月9日,范围是[2024年5月9日-2024年5月16日]', visitos_num int null comment '入园总人数', current_people_num int null comment '当前在公园的人数,即time_period时间段的客流量', time_period text null comment '时间段,时间格式示例如:2024-5-09 00,代表2024年5月9日0点', monitor_time text null comment '监测时间点,时间格式示例如:0:00:01' ); 其中每列都有中文注释,但是log日志打印出来的提示词中,并无中文注释,只有表名和列名,导致SQL效果不好。 日志信息如下: {'model': 'moonshot_proxyllm', 'messages': [ModelMessage(role='system', content='\n请根据用户选择的数据库和该库的部分可用表结构定义来回答用户问题.\n数据库名:\n yuanling\n表结构定义:\n [(\'park_passenger_flow(id,park,region_id,leave_num,uint,monitor_date,visitos_num,current_people_num,time_period,monitor_time)\',)]\n\n约束:\n 1. 请根据用户问题理解用户意图,使用给出表结构定义创建一个语法正确的 mysql sql,如果不需要sql,则直接回答用户问题。\n 2. 除非用户在问题中指定了他希望获得的具体数据行数,否则始终将查询限制为最多 50 个结果。\n 3. 只能使用表结构信息中提供的表来生成 sql,如果无法根据提供的表结构中生成 sql ,请说:“提供的表结构信息不足以生成 sql 查询。” 禁止随意捏造信息。\n 4. 请注意生成SQL时不要弄错表和列的关系\n 5. 请检查SQL的正确性,并保证正确的情况下优化查询性能\n 6.请从如下给出的展示方式种选择最优的一种用以进行数据渲染,将类型名称放入返回要求格式的name参数值种,如果找不到最合适的则使用\'Table\'作为展示方式,可用数据展示方式如下: response_line_chart:used to display comparative trend analysis data\nresponse_pie_chart:suitable for scenarios such as proportion and distribution statistics\nresponse_table:suitable for display with many display columns or non-numeric columns\nresponse_scatter_plot:Suitable for exploring relationships between variables, detecting outliers, etc.\nresponse_bubble_chart:Suitable for relationships between multiple variables, highlighting outliers or special situations, etc.\nresponse_donut_chart:Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc.\nresponse_area_chart:Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc.\nresponse_heatmap:Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc.\n用户问题:\n 中山公园客流情况如何\n请一步步思考并按照以下JSON格式回复:\n "{\n \"thoughts\": \"thoughts summary to say to user\",\n \"sql\": \"SQL Query to run\",\n \"display_type\": \"Data display method\"\n}"\n确保返回正确的json并且可以被Python json.loads方法解析.\n\n', round_index=0), ModelMessage(role='human', content='中山公园客流情况如何', round_index=0)], 'temperature': 0.5, 'max_new_tokens': 1024, 'echo': False, 'span_id': '3986e227-b48c-4729-8221-138117c32df7:c77dbe55-ea77-43ae-87dd-d655403ff912', 'context': {'stream': False, 'cache_enable': False, 'user_name': None, 'sys_code': None, 'conv_uid': None, 'span_id': '3986e227-b48c-4729-8221-138117c32df7:35d777f8-e813-4c5d-8b6d-405011ee67e9', 'chat_mode': 'chat_with_db_execute', 'chat_param': None, 'extra': {}, 'request_id': None}, 'convert_to_compatible_format': False, 'string_prompt': 'system: \n请根据用户选择的数据库和该库的部分可用表结构定义来回答用户问题.\n数据库名:\n yuanling\n表结构定义:\n [(\'park_passenger_flow(id,park,region_id,leave_num,uint,monitor_date,visitos_num,current_people_num,time_period,monitor_time)\',)]\n\n约束:\n 1. 请根据用户问题理解用户意图,使用给出表结构定义创建一个语法正确的 mysql sql,如果不需要sql,则直接回答用户问题。\n 2. 除非用户在问题中指定了他希望获得的具体数据行数,否则始终将查询限制为最多 50 个结果。\n 3. 只能使用表结构信息中提供的表来生成 sql,如果无法根据提供的表结构中生成 sql ,请说:“提供的表结构信息不足以生成 sql 查询。” 禁止随意捏造信息。\n 4. 请注意生成SQL时不要弄错表和列的关系\n 5. 请检查SQL的正确性,并保证正确的情况下优化查询性能\n 6.请从如下给出的展示方式种选择最优的一种用以进行数据渲染,将类型名称放入返回要求格式的name参数值种,如果找不到最合适的则使用\'Table\'作为展示方式,可用数据展示方式如下: response_line_chart:used to display comparative trend analysis data\nresponse_pie_chart:suitable for scenarios such as proportion and distribution statistics\nresponse_table:suitable for display with many display columns or non-numeric columns\nresponse_scatter_plot:Suitable for exploring relationships between variables, detecting outliers, etc.\nresponse_bubble_chart:Suitable for relationships between multiple variables, highlighting outliers or special situations, etc.\nresponse_donut_chart:Suitable for hierarchical structure representation, category proportion display and highlighting key categories, etc.\nresponse_area_chart:Suitable for visualization of time series data, comparison of multiple groups of data, analysis of data change trends, etc.\nresponse_heatmap:Suitable for visual analysis of time series data, large-scale data sets, distribution of classified data, etc.\n用户问题:\n 中山公园客流情况如何\n请一步步思考并按照以下JSON格式回复:\n "{\n \"thoughts\": \"thoughts summary to say to user\",\n \"sql\": \"SQL Query to run\",\n \"display_type\": \"Data display method\"\n}"\n确保返回正确的json并且可以被Python json.loads方法解析.\n\n\nhuman: 中山公园客流情况如何'}

What you expected to happen

同样的表,我尝试了pg和mysql,均未读到列的注释信息。我希望能将列的注释信息能读取,并拼接到提示词中。我在chatdb中问表信息能,查询出相关的注释。 另外还有,当我使用pg的时候,生成的SQL,会拼接dbname.tablename,这不符合pg语法,例如应该是dbname.public.tablename

How to reproduce

https://docs.dbgpt.site/docs/latest/installation/docker_compose

Additional context

No response

Are you willing to submit PR?

github-actions[bot] commented 4 months ago

This issue has been marked as stale, because it has been over 30 days without any activity.

github-actions[bot] commented 3 months ago

This issue bas been closed, because it has been marked as stale and there has been no activity for over 7 days.