Skip to content

Commit

Permalink
Fix ReAct agent hallucinating result (langchain-ai#3341)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd authored Nov 20, 2023
1 parent 01c0165 commit 05b0a4f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions examples/src/agents/mrkl_runnable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ $JSON_BLOB
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question`;
Final Answer: the final answer to the original input question
Action part must be always wrapped in 3 backticks.`;
const SUFFIX = `Begin! Reminder to always use the exact characters \`Final Answer\` when responding.
Thoughts: {agent_scratchpad}`;
const DEFAULT_HUMAN_MESSAGE_TEMPLATE = "Question: {input}";
Expand Down Expand Up @@ -90,7 +92,8 @@ const runnableAgent = RunnableSequence.from([
formatLogToString(i.steps),
},
prompt,
model,
// Important, otherwise the answer is only hallucinated
model.bind({ stop: ["\nObservation"] }),
outputParser,
]);

Expand Down

0 comments on commit 05b0a4f

Please sign in to comment.