I am working with the AgentReact from the Langchain library and I need to access and display the intermediate steps (interactions) in real-time while waiting for the final response. Currently, my code only returns the interactions and the final result after the entire process is completed, which is not ideal for my application.
def question_answer(question: str, agents: AgentExecutor):
list_logs_result = []
answer = agents.invoke({'input': prompt_templates_100.format(question=question)}, )
interactions = format_interactions(answer)
for interaction in interactions:
list_logs_result.append({"log": interaction["log"], "result": interaction["result"]})
return answer["output"], list_logs_result
New contributor
Alex Mon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.