template.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. Question: {{query}}
  33. Thought: {{agent_scratchpad}}"""
  34. ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES = """Observation: {{observation}}
  35. Thought:"""
  36. ENGLISH_REACT_CHAT_PROMPT_TEMPLATES = """Respond to the human as helpfully and accurately as possible.
  37. {{instruction}}
  38. You have access to the following tools:
  39. {{tools}}
  40. Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).
  41. Valid "action" values: "Final Answer" or {{tool_names}}
  42. Provide only ONE action per $JSON_BLOB, as shown:
  43. ```
  44. {
  45. "action": $TOOL_NAME,
  46. "action_input": $ACTION_INPUT
  47. }
  48. ```
  49. Follow this format:
  50. Question: input question to answer
  51. Thought: consider previous and subsequent steps
  52. Action:
  53. ```
  54. $JSON_BLOB
  55. ```
  56. Observation: action result
  57. ... (repeat Thought/Action/Observation N times)
  58. Thought: I know what to respond
  59. Action:
  60. ```
  61. {
  62. "action": "Final Answer",
  63. "action_input": "Final response to human"
  64. }
  65. ```
  66. 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:.
  67. """
  68. ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES = ""
  69. REACT_PROMPT_TEMPLATES = {
  70. 'english': {
  71. 'chat': {
  72. 'prompt': ENGLISH_REACT_CHAT_PROMPT_TEMPLATES,
  73. 'agent_scratchpad': ENGLISH_REACT_CHAT_AGENT_SCRATCHPAD_TEMPLATES
  74. },
  75. 'completion': {
  76. 'prompt': ENGLISH_REACT_COMPLETION_PROMPT_TEMPLATES,
  77. 'agent_scratchpad': ENGLISH_REACT_COMPLETION_AGENT_SCRATCHPAD_TEMPLATES
  78. }
  79. }
  80. }