Skip to content

How to implement the ReAct pattern with the OpenAI tools agent? #17451

Closed Answered by ZmeiGorynych
ZmeiGorynych asked this question in Q&A
Discussion options

You must be logged in to vote

OK, figured it out, need to combine a RunnableParallel with a RunnableLambda to mash the outputs together, see below.
The only problem left is that the thought is not printed to console even in verbose mode, but hey there's always Langsmith :)

react_prompt = ChatPromptTemplate.from_template(
    """
Answer the following questions as best you can. You have access to the following tools:
{tools}, 
either during this invocation or later. 

If you have access to any tools right now, your response MUST be a tool call unless the last input 
message contains the words "Final Answer". If it does, just repeat it.

If you don't have access to any tools right now, your reply must begin with "Thought…

Replies: 6 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@ZmeiGorynych
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@abhimalamkar
Comment options

@ZmeiGorynych
Comment options

Answer selected by ZmeiGorynych
Comment options

You must be logged in to vote
1 reply
@ZmeiGorynych
Comment options

Comment options

You must be logged in to vote
3 replies
@ZmeiGorynych
Comment options

@thanhtrung5763
Comment options

@ZmeiGorynych
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants