template.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
  2. {{instruction}}
  3. You have access to the following tools:
  4. {{tools}}
  5. Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
  6. Valid "action" values: "Final Answer" or {{tool_names}}
  7. Provide only ONE action per $JSON_BLOB, as shown:
  8. ```
  9. {
  10. "action": $TOOL_NAME,
  11. "action_input": $ACTION_INPUT
  12. }
  13. ```
  14. Follow this format:
  15. Question: input question to answer
  16. Thought: consider previous and subsequent steps
  17. Action:
  18. ```
  19. $JSON_BLOB
  20. ```
  21. Observation: action result
  22. ... (repeat Thought/Action/Observation N times)
  23. Thought: I know what to respond
  24. Action:
  25. ```
  26. {
  27. "action": "Final Answer",
  28. "action_input": "Final response to human"
  29. }
  30. ```
  31. 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:.
  32. {{historic_messages}}
  33. Question: {{query}}
  34. {{agent_scratchpad}}
  35. Thought:""" # noqa: E501
  36. ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES = """Observation: {{observation}}
  37. Thought:"""
  38. ENGLISH_REACT_CHAT_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
  39. {{instruction}}
  40. You have access to the following tools:
  41. {{tools}}
  42. Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
  43. Valid "action" values: "Final Answer" or {{tool_names}}
  44. Provide only ONE action per $JSON_BLOB, as shown:
  45. ```
  46. {
  47. "action": $TOOL_NAME,
  48. "action_input": $ACTION_INPUT
  49. }
  50. ```
  51. Follow this format:
  52. Question: input question to answer
  53. Thought: consider previous and subsequent steps
  54. Action:
  55. ```
  56. $JSON_BLOB
  57. ```
  58. Observation: action result
  59. ... (repeat Thought/Action/Observation N times)
  60. Thought: I know what to respond
  61. Action:
  62. ```
  63. {
  64. "action": "Final Answer",
  65. "action_input": "Final response to human"
  66. }
  67. ```
  68. 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:.
  69. """ # noqa: E501
  70. ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES = ""
  71. REACT_PROMPT_TEMPLATES = {
  72. "english": {
  73. "chat": {
  74. "prompt": ENGLISH_REACT_CHAT_PROMPT_TEMPLATES,
  75. "agent_scratchpad": ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES,
  76. },
  77. "completion": {
  78. "prompt": ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES,
  79. "agent_scratchpad": ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES,
  80. },
  81. }
  82. }