Commit 818344c
authored
This pull request resolves #980
simple code snippet to do tests:
```python
import asyncio
from openai.types.responses import ResponseTextDeltaEvent
from agents import Agent, ModelSettings, Runner, function_tool, set_default_openai_api
set_default_openai_api("chat_completions")
@function_tool
def say_hello():
print("Hello, world!")
return "Hello, world!"
async def main():
agent = Agent(
name="Joker",
instructions="You are a helpful assistant.",
model_settings=ModelSettings(tool_choice="say_hello"),
tools=[say_hello],
)
result = Runner.run_streamed(agent, input="Please tell me 5 jokes.")
async for event in result.stream_events():
if event.type == "raw_response_event" and isinstance(event.data, ResponseTextDeltaEvent):
print(event.data.delta, end="", flush=True)
if __name__ == "__main__":
asyncio.run(main())
```
1 parent 25c61e8 commit 818344c
1 file changed
+17
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
299 | 314 | | |
300 | 315 | | |
301 | 316 | | |
302 | 317 | | |
303 | 318 | | |
304 | 319 | | |
305 | | - | |
306 | | - | |
307 | | - | |
| 320 | + | |
308 | 321 | | |
309 | 322 | | |
310 | 323 | | |
| |||
0 commit comments