Commit a3da0196

Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
2023-12-11 18:01:08
docs: small streaming readme improvements (#962)
1 parent dfe1c8d
Changed files (1)
README.md
@@ -97,8 +97,7 @@ stream = client.chat.completions.create(
     stream=True,
 )
 for chunk in stream:
-    if chunk.choices[0].delta.content is not None:
-        print(chunk.choices[0].delta.content)
+    print(chunk.choices[0].delta.content or "", end="")
 ```
 
 The async client uses the exact same interface.
@@ -108,6 +107,7 @@ from openai import AsyncOpenAI
 
 client = AsyncOpenAI()
 
+
 async def main():
     stream = await client.chat.completions.create(
         model="gpt-4",
@@ -115,8 +115,8 @@ async def main():
         stream=True,
     )
     async for chunk in stream:
-        if chunk.choices[0].delta.content is not None:
-            print(chunk.choices[0].delta.content)
+        print(chunk.choices[0].delta.content or "", end="")
+
 
 asyncio.run(main())
 ```