You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

prompt_config.py 6.0 kB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # 除 Agent 模板使用 f-string 外,其它均使用 jinja2 格式
  2. PROMPT_TEMPLATES = {
  3. "preprocess_model": {
  4. "default": "你只要回复0 和 1 ,代表不需要使用工具。以下几种问题不需要使用工具:"
  5. "1. 需要联网查询的内容\n"
  6. "2. 需要计算的内容\n"
  7. "3. 需要查询实时性的内容\n"
  8. "如果我的输入满足这几种情况,返回1。其他输入,请你回复0,你只要返回一个数字\n"
  9. "这是我的问题:"
  10. },
  11. "llm_model": {
  12. "default": "{{input}}",
  13. "with_history": "The following is a friendly conversation between a human and an AI. "
  14. "The AI is talkative and provides lots of specific details from its context. "
  15. "If the AI does not know the answer to a question, it truthfully says it does not know.\n\n"
  16. "Current conversation:\n"
  17. "{{history}}\n"
  18. "Human: {{input}}\n"
  19. "AI:",
  20. "rag": "【指令】根据已知信息,简洁和专业的来回答问题。如果无法从中得到答案,请说 “根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。\n\n"
  21. "【已知信息】{{context}}\n\n"
  22. "【问题】{{question}}\n",
  23. "rag_default": "{{question}}",
  24. },
  25. "action_model": {
  26. "GPT-4": "Answer the following questions as best you can. You have access to the following tools:\n"
  27. "The way you use the tools is by specifying a json blob.\n"
  28. "Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).\n"
  29. 'The only values that should be in the "action" field are: {tool_names}\n'
  30. "The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:\n"
  31. "```\n\n"
  32. "{{{{\n"
  33. ' "action": $TOOL_NAME,\n'
  34. ' "action_input": $INPUT\n'
  35. "}}}}\n"
  36. "```\n\n"
  37. "ALWAYS use the following format:\n"
  38. "Question: the input question you must answer\n"
  39. "Thought: you should always think about what to do\n"
  40. "Action:\n"
  41. "```\n\n"
  42. "$JSON_BLOB"
  43. "```\n\n"
  44. "Observation: the result of the action\n"
  45. "... (this Thought/Action/Observation can repeat N times)\n"
  46. "Thought: I now know the final answer\n"
  47. "Final Answer: the final answer to the original input question\n"
  48. "Begin! Reminder to always use the exact characters `Final Answer` when responding.\n"
  49. "Question:{input}\n"
  50. "Thought:{agent_scratchpad}\n",
  51. "ChatGLM3": """You can answer using the tools.Respond to the human as helpfully and accurately as possible.\n
  52. You have access to the following tools:\n
  53. {tools}\n
  54. Use a json blob to specify a tool by providing an action key {tool name}\n
  55. and an action_input key (tool input).\n
  56. Valid "action" values: "Final Answer" or {tool_names}\n
  57. Provide only ONE action per $JSON_BLOB, as shown:\n\n
  58. ```\n
  59. {{{{\n
  60. "action": $TOOL_NAME,\n
  61. "action_input": $INPUT\n
  62. }}}}\n
  63. ```\n\n
  64. Follow this format:\n\n
  65. Question: input question to answer\n
  66. Thought: consider previous and subsequent steps\n
  67. Action:\n
  68. ```\n
  69. $JSON_BLOB\n
  70. ```\n
  71. Observation: action result\n
  72. ... (repeat Thought/Action/Observation N times)\n
  73. Thought: I know what to respond\n
  74. Action:\n
  75. ```\n
  76. {{{{\n
  77. "action": "Final Answer",\n
  78. "action_input": "Final response to human"\n
  79. }}}}\n
  80. Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary.\n
  81. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation:.\n
  82. Question: {input}\n\n
  83. {agent_scratchpad}\n""",
  84. "qwen": "Answer the following questions as best you can. You have access to the following APIs:\n\n"
  85. "{tools}\n\n"
  86. "Use the following format:\n\n"
  87. "Question: the input question you must answer\n"
  88. "Thought: you should always think about what to do\n"
  89. "Action: the action to take, should be one of [{tool_names}]\n"
  90. "Action Input: the input to the action\n"
  91. "Observation: the result of the action\n"
  92. "... (this Thought/Action/Action Input/Observation can be repeated zero or more times)\n"
  93. "Thought: I now know the final answer\n"
  94. "Final Answer: the final answer to the original input question\n\n"
  95. "Format the Action Input as a JSON object.\n\n"
  96. "Begin!\n\n"
  97. "Question: {input}\n\n"
  98. "{agent_scratchpad}\n\n",
  99. "structured-chat-agent": "Respond to the human as helpfully and accurately as possible. You have access to the following tools:\n\n"
  100. "{tools}\n\n"
  101. "Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).\n\n"
  102. 'Valid "action" values: "Final Answer" or {tool_names}\n\n'
  103. "Provide only ONE action per $JSON_BLOB, as shown:\n\n"
  104. '```\n{{\n "action": $TOOL_NAME,\n "action_input": $INPUT\n}}\n```\n\n'
  105. "Follow this format:\n\n"
  106. "Question: input question to answer\n"
  107. "Thought: consider previous and subsequent steps\n"
  108. "Action:\n```\n$JSON_BLOB\n```\n"
  109. "Observation: action result\n"
  110. "... (repeat Thought/Action/Observation N times)\n"
  111. "Thought: I know what to respond\n"
  112. 'Action:\n```\n{{\n "action": "Final Answer",\n "action_input": "Final response to human"\n}}\n\n'
  113. "Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation\n"
  114. "{input}\n\n"
  115. "{agent_scratchpad}\n\n",
  116. # '(reminder to respond in a JSON blob no matter what)'
  117. },
  118. "postprocess_model": {
  119. "default": "{{input}}",
  120. },
  121. }

MindPilot是一个跨平台的多功能智能Agent桌面助手,旨在为用户提供便捷、高效的智能解决方案。通过集成先进的大语言模型作为核心决策引擎,MindPilot能够对用户的任务进行精准分解、规划、执行、反思和总结,确保任务的高效完成。同时提供了高度自定义化的Agent,用户可以根据需求自定义不同身份的Agent,以应对多样化的任务场景,实现个性化的智能服务。在MindSpore和MindNLP的