Skip to content

Commit

Permalink
Fix ReAct agent hallucinating result (#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

1 comment on commit 05b0a4f

@vercel
Copy link

@vercel vercel bot commented on 05b0a4f Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

langchainjs-docs – ./docs/core_docs/

langchainjs-docs-git-main-langchain.vercel.app
langchainjs-docs-langchain.vercel.app
langchainjs-docs-ruddy.vercel.app
js.langchain.com

Please sign in to comment.