llm_prompts_bak.yaml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # 提示词配置文件
  2. # 包含所有LLM交互使用的提示词模板
  3. # 用于customllm/base_llm_chat.py
  4. sql_generation:
  5. # SQL生成的初始提示词
  6. initial_prompt: |
  7. You are a {dialect} expert.
  8. Please help to generate a SQL query to answer the question. Your response should ONLY be based on the given context and follow the response guidelines and format instructions.
  9. # SQL生成的响应指南
  10. response_guidelines: |
  11. ===Response Guidelines
  12. 1. If the provided context is sufficient, please generate a valid SQL query without any explanations for the question.
  13. 2. If the provided context is almost sufficient but requires knowledge of a specific string in a particular column, please generate an intermediate SQL query to find the distinct strings in that column. Prepend the query with a comment saying intermediate_sql
  14. 3. If the provided context is insufficient, please explain why it can't be generated.
  15. 4. **Context Understanding**: If the question follows [CONTEXT]...[CURRENT] format, replace pronouns in [CURRENT] with specific entities from [CONTEXT].
  16. - Example: If context mentions 'Nancheng Service Area has the most stalls', and current question is 'How many dining stalls does this service area have?',
  17. interpret it as 'How many dining stalls does Nancheng Service Area have?'
  18. 5. Please use the most relevant table(s).
  19. 6. If the question has been asked and answered before, please repeat the answer exactly as it was given before.
  20. 7. Ensure that the output SQL is {dialect}-compliant and executable, and free of syntax errors.
  21. 8. 在生成 SQL 查询时,如果出现 ORDER BY 子句,请遵循以下规则:
  22. - 对所有的排序字段(如聚合字段 SUM()、普通列等),请在 ORDER BY 中显式添加 NULLS LAST。
  23. - 不论是否使用 LIMIT,只要排序字段存在,都必须添加 NULLS LAST,以防止 NULL 排在结果顶部。
  24. - 示例参考:
  25. - ORDER BY total DESC NULLS LAST
  26. - ORDER BY zf_order DESC NULLS LAST
  27. - ORDER BY SUM(c.customer_count) DESC NULLS LAST
  28. 9. 【重要】请在SQL查询中为所有SELECT的列都使用中文别名:
  29. - 每个列都必须使用 AS 中文别名 的格式,没有例外
  30. - 包括原始字段名也要添加中文别名,例如:SELECT gender AS 性别, card_category AS 卡片类型
  31. - 计算字段也要有中文别名,例如:SELECT COUNT(*) AS 持卡人数
  32. - 中文别名要准确反映字段的业务含义
  33. chart_generation:
  34. # 中文图表指令
  35. chinese_chart_instructions: |
  36. 使用中文创建图表,要求:
  37. 1. 根据用户问题和数据内容,为图表生成有意义的中文标题
  38. 2. 根据数据列的实际含义,为X轴和Y轴生成准确的中文标签
  39. 3. 如果有图例,确保图例标签使用中文
  40. 4. 所有文本(包括标题、轴标签、图例、数据标签等)都必须使用中文
  41. 5. 标题应该简洁明了地概括图表要展示的内容
  42. 6. 轴标签应该准确反映对应数据列的业务含义
  43. 7. 选择最适合数据特点的图表类型(柱状图、折线图、饼图等)
  44. # 系统消息模板
  45. system_message_template: |
  46. 用户问题:'{question}'
  47. 以下是回答用户问题的pandas DataFrame数据:
  48. {sql_part}
  49. DataFrame结构信息:
  50. {df_metadata}
  51. # 用户消息模板
  52. user_message_template: |
  53. 请为这个DataFrame生成Python Plotly可视化代码。要求:
  54. 1. 假设数据存储在名为'df'的pandas DataFrame中
  55. 2. 如果DataFrame只有一个值,使用Indicator图表
  56. 3. 只返回Python代码,不要任何解释
  57. 4. 代码必须可以直接运行
  58. {chinese_chart_instructions}
  59. 特别注意:
  60. - 不要使用'图表标题'、'X轴标签'、'Y轴标签'这样的通用标签
  61. - 要根据实际数据内容和用户问题生成具体、有意义的中文标签
  62. - 例如:如果是性别统计,X轴可能是'性别',Y轴可能是'人数'或'占比'
  63. - 标题应该概括图表的主要内容,如'男女持卡比例分布'
  64. 数据标签和悬停信息要求:
  65. - 不要使用%{text}这样的占位符变量
  66. - 使用具体的数据值和中文单位,例如:text=df['列名'].astype(str) + '人'
  67. - 悬停信息要清晰易懂,使用中文描述
  68. - 确保所有显示的文本都是实际的数据值,不是变量占位符
  69. question_generation:
  70. # 根据SQL生成问题的提示词
  71. system_prompt: |
  72. 请你根据下方SQL语句推测用户的业务提问,只返回清晰的自然语言问题,不要包含任何解释或SQL内容,也不要出现表名,问题要使用中文,并以问号结尾。
  73. chat_with_llm:
  74. # 聊天对话的默认系统提示词
  75. default_system_prompt: |
  76. 你是一个友好的AI助手,请用中文回答用户的问题。
  77. question_merge:
  78. # 问题合并的系统提示词
  79. system_prompt: |
  80. 你的目标是将一系列相关的问题合并成一个单一的问题。如果第二个问题与第一个问题无关且完全独立,则返回第二个问题。
  81. 只返回新的合并问题,不要添加任何额外的解释。该问题理论上应该能够用一个SQL语句来回答。
  82. 请用中文回答。
  83. summary_generation:
  84. # 摘要生成的系统消息
  85. system_message_template: |
  86. 你是一个专业的数据分析助手。用户提出了问题:'{question}'
  87. 以下是查询结果的 pandas DataFrame 数据:{df_markdown}
  88. 请用中文进行思考和分析,并用中文回答。
  89. # 摘要生成的用户提示词
  90. user_instructions: |
  91. 请基于用户提出的问题,简要总结这些数据。要求:
  92. 1. 只进行简要总结,不要添加额外的解释
  93. 2. 如果数据中有数字,请保留适当的精度