Skip to content

Commit c3e3ce6

Browse files
logankilpatrickmegamanics
authored andcommitted
Update README.md (openai#892)
1 parent d528f83 commit c3e3ce6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ stream = client.chat.completions.create(
9494
messages=[{"role": "user", "content": "Say this is a test"}],
9595
stream=True,
9696
)
97-
for part in stream:
98-
print(part.choices[0].delta.content or "")
97+
for chunk in stream:
98+
if chunk.choices[0].delta.content is not None:
99+
print(chunk.choices[0].delta.content, end="")
99100
```
100101

101102
The async client uses the exact same interface.
@@ -110,8 +111,9 @@ stream = await client.chat.completions.create(
110111
messages=[{"role": "user", "content": "Say this is a test"}],
111112
stream=True,
112113
)
113-
async for part in stream:
114-
print(part.choices[0].delta.content or "")
114+
async for chunk in stream:
115+
if chunk.choices[0].delta.content is not None:
116+
print(chunk.choices[0].delta.content, end="")
115117
```
116118

117119
## Module-level client

0 commit comments

Comments
 (0)