File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -108,14 +108,17 @@ from openai import AsyncOpenAI
108
108
109
109
client = AsyncOpenAI()
110
110
111
- stream = await client.chat.completions.create(
112
- model = " gpt-4" ,
113
- messages = [{" role" : " user" , " content" : " Say this is a test" }],
114
- stream = True ,
115
- )
116
- async for chunk in stream:
117
- if chunk.choices[0 ].delta.content is not None :
118
- print (chunk.choices[0 ].delta.content)
111
+ async def main ():
112
+ stream = await client.chat.completions.create(
113
+ model = " gpt-4" ,
114
+ messages = [{" role" : " user" , " content" : " Say this is a test" }],
115
+ stream = True ,
116
+ )
117
+ async for chunk in stream:
118
+ if chunk.choices[0 ].delta.content is not None :
119
+ print (chunk.choices[0 ].delta.content)
120
+
121
+ asyncio.run(main())
119
122
```
120
123
121
124
## Module-level client
You can’t perform that action at this time.
0 commit comments