File size: 485 Bytes
4d65ce5
 
cdafe00
4d65ce5
 
 
744ed73
4d65ce5
 
 
 
744ed73
1
2
3
4
5
6
7
8
9
10
11
12
from agents import Runner
from openai.types.responses import ResponseTextDeltaEvent
    # This takes the query and brings the answer

async def run_query(agent, query: str):
    """
    Run a streamed query on the agent and yield response chunks.
    """
    response = Runner.run_streamed(agent, query)
    async for event in response.stream_events():
        if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
            yield event.data.delta