Skip to content

Commit 530ddb6

Browse files
committed
Add last missing coverage
1 parent 2baf6da commit 530ddb6

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
interactions:
2+
- request:
3+
headers:
4+
accept:
5+
- application/json
6+
accept-encoding:
7+
- gzip, deflate
8+
connection:
9+
- keep-alive
10+
content-length:
11+
- '144'
12+
content-type:
13+
- application/json
14+
host:
15+
- api.openai.com
16+
method: POST
17+
parsed_body:
18+
messages:
19+
- content: What is the capital of Mexico?
20+
role: user
21+
model: gpt-4o
22+
stream: true
23+
stream_options:
24+
include_usage: true
25+
uri: https://api.openai.com/v1/chat/completions
26+
response:
27+
body:
28+
string: |+
29+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"GmahJEMIl7nQy4"}
30+
31+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":"The"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"pIfys15QtbIy6"}
32+
33+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" capital"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"vUl7M9hs"}
34+
35+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" of"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"4esBSFkNdPBkg"}
36+
37+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" Mexico"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"WswOcLSG4"}
38+
39+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" is"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"wrbY70akMp6ru"}
40+
41+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" Mexico"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"17213oGdV"}
42+
43+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":" City"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"XEAeN8ajbAt"}
44+
45+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{"content":"."},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"CBIatQSGHvp1Ckv"}
46+
47+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}],"usage":null,"obfuscation":"yu1bsKEkrP"}
48+
49+
data: {"id":"chatcmpl-COrTbn1vT5ddb2i6ZlOOM8Q6pOvBa","object":"chat.completion.chunk","created":1760041471,"model":"gpt-4o-2024-08-06","service_tier":"default","system_fingerprint":"fp_cbf1785567","choices":[],"usage":{"prompt_tokens":14,"completion_tokens":8,"total_tokens":22,"prompt_tokens_details":{"cached_tokens":0,"audio_tokens":0},"completion_tokens_details":{"reasoning_tokens":0,"audio_tokens":0,"accepted_prediction_tokens":0,"rejected_prediction_tokens":0}},"obfuscation":""}
50+
51+
data: [DONE]
52+
53+
headers:
54+
access-control-expose-headers:
55+
- X-Request-ID
56+
alt-svc:
57+
- h3=":443"; ma=86400
58+
connection:
59+
- keep-alive
60+
content-type:
61+
- text/event-stream; charset=utf-8
62+
openai-organization:
63+
- user-xgcwoiiqpw3hpu7oxktn2g9g
64+
openai-processing-ms:
65+
- '275'
66+
openai-project:
67+
- proj_nKlzMl1B51a3SCL1Rndf7JTx
68+
openai-version:
69+
- '2020-10-01'
70+
strict-transport-security:
71+
- max-age=31536000; includeSubDomains; preload
72+
transfer-encoding:
73+
- chunked
74+
status:
75+
code: 200
76+
message: OK
77+
version: 1
78+
...

tests/test_prefect.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from pydantic_ai import (
1616
Agent,
1717
AgentRunResult,
18+
AgentRunResultEvent,
1819
AgentStreamEvent,
1920
ExternalToolset,
2021
FunctionToolset,
@@ -706,6 +707,14 @@ async def test_prefect_agent_run_stream(allow_model_requests: None):
706707
)
707708

708709

710+
async def test_prefect_agent_run_stream_events(allow_model_requests: None):
711+
"""Test that agent.run_stream_events() works."""
712+
events = [event async for event in simple_prefect_agent.run_stream_events('What is the capital of Mexico?')]
713+
assert events == snapshot(
714+
[AgentRunResultEvent(result=AgentRunResult(output='The capital of Mexico is Mexico City.'))]
715+
)
716+
717+
709718
async def test_prefect_agent_iter(allow_model_requests: None):
710719
"""Test that agent.iter() works."""
711720
outputs: list[str] = []

0 commit comments

Comments
 (0)