Skip to content

Commit

Permalink
fix (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
statefb authored Jun 10, 2024
1 parent 7652ed6 commit bffba7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions backend/app/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def format_log_to_str(
intermediate_steps: list[tuple[AgentAction, str]],
observation_prefix: str = "<observation>",
observation_suffix: str = "</observation>",
llm_prefix: str = "<thought>",
llm_suffix: str = "</thought>",
llm_prefix: str = "",
llm_suffix: str = "",
) -> str:
"""Construct the scratchpad that lets the agent continue its thought process."""
thoughts = ""
Expand Down
8 changes: 3 additions & 5 deletions backend/app/agents/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
from langchain_core.output_parsers import BaseOutputParser

FINAL_ANSWER_TAG = "final-answer"
MISSING_THOUGHT_TAG_ERROR_MESSAGE = "Invalid Format: Missing '<thought>' tag"
MISSING_THOUGHT_TAG_ERROR_MESSAGE = "Invalid Format: Missing '<thought></thought>' tag"
MISSING_ACTION_TAG_ERROR_MESSAGE = (
"Invalid Format: Missing '<action>' tag after '<thought>'"
)
MISSING_ACTION_INPUT_TAG_ERROR_MESSAGE = (
"Invalid Format: Missing '<action-input>' tag after '<action>'"
"Invalid Format: Missing '<action></action>' tag after '<thought></thought>'"
)
MISSING_ACTION_INPUT_TAG_ERROR_MESSAGE = "Invalid Format: Missing '<action-input></action-input>' tag after '<action></action>'"


class ReActSingleInputOutputParser(BaseOutputParser):
Expand Down
6 changes: 3 additions & 3 deletions backend/app/agents/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
<action-input>The input to the action. The format of the input must be json format.</action-input>
<observation>The result of the action<observation>
... (this Thought/Action/Action Input/Observation can repeat N times)
<thought>I now know the final answer</thought>
<final-thought>I now know the final answer</final-thought>
<final-answer>The final answer to the original input question. The language of the final answer must be the same language of original input: {input}</final-answer>
</format>
Do not end your output with Thought. Always end with Final Answer or Observation.
Do not make thought empty. Always provide a thought before an action.
<bad-example>
<question>What is the weather in Tokyo?</question>
<thought>I should check the weather in Tokyo.</thought>
<thought>DO NOT LEAVE EMPTY HERE</thought>
</bad-example>
</guidelines>
Expand Down

0 comments on commit bffba7e

Please sign in to comment.