Streaming the final answer in Create SQL Agent #25525
Unanswered
gformcreation
asked this question in
Q&A
Replies: 1 comment
-
Hey there, @gformcreation! I'm here to assist you with any questions or issues you have. Let's tackle this together! To stream only the final answer from agent_executor = create_sql_agent(
llm,
db=db,
agent_type="openai-tools",
suffix=markdown_prompt + SQL_SUFFIX,
max_iterations=8,
# verbose=True
)
async def process_events():
final_response = ""
async for event in agent_executor.astream_events(
{"input": "Can you get me all the records which consists of high bp, ejection fraction and a death event for me ?."},
version="v1",
):
kind = event["event"]
if kind == "on_chain_end" and event["name"] == "Agent":
final_response = event["data"].get("output", {}).get("output", "")
break
print(final_response)
asyncio.run(process_events()) In this code, the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I'm attempting to stream the final answer from the agent_executor, but the output currently includes all the AI-generated responses, such as the SQL queries, in addition to the final answer. Does anyone have any suggestions on how to address this?
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies
Beta Was this translation helpful? Give feedback.
All reactions