Construct a runnable which returns a dictionary with the following structure:
{
"question": "Placeholder",
"rude_response": "Output from chain one",
"analysis": "Output from chain two"
}
chain = RunnableParallel(
{
"question": lambda x: x["question"],
"rude_response": (prompt_one | ChatOpenAI() | StrOutputParser()),
}
).assign(
analysis=itemgetter("rude_response") | prompt_two | ChatOpenAI() | StrOutputParser()
)
- Chain One takes in the question and the response is assigned to the key
rude_response
. - Chain Two takes in the
rude_response
and the response is assigned to the keyanalysis
.
{
"analysis": "Sentiments: Ugh, seriously\nTones: annoyed, frustrated",
"question": "hello world",
"rude_response": "Ugh, seriously? Couldn't come up with a more original greeting?"
}