File tree Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Expand file tree Collapse file tree 3 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ Our chat API is OpenAI compatible. Use OpenAI’s [API reference](https://platfo
6767- top_p
6868- max_tokens
6969- stream
70+ - stream_options
7071- presence_penalty
7172- [ response_format] ( /ai-data/generative-apis/how-to/use-structured-outputs )
7273- logprobs
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ response = client.chat.completions.create(
139139)
140140
141141for chunk in response:
142- if chunk.choices[0 ].delta.content:
142+ if chunk.choices and chunk.choices [0 ].delta.content:
143143 print (chunk.choices[0 ].delta.content, end = " " )
144144```
145145
@@ -167,7 +167,8 @@ async def main():
167167 stream = True ,
168168 )
169169 async for chunk in stream:
170- print (chunk.choices[0 ].delta.content, end = " " )
170+ if chunk.choices and chunk.choices[0 ].delta.content:
171+ print (chunk.choices[0 ].delta.content, end = " " )
171172
172173asyncio.run(main())
173174```
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ response = client.chat.completions.create(
201201)
202202
203203for chunk in response:
204- if chunk.choices[0 ].delta.content:
204+ if chunk.choices and chunk.choices [0 ].delta.content:
205205 print (chunk.choices[0 ].delta.content, end = " " )
206206```
207207
@@ -232,7 +232,8 @@ async def main():
232232 stream = True ,
233233 )
234234 async for chunk in stream:
235- print (chunk.choices[0 ].delta.content, end = " " )
235+ if chunk.choices and chunk.choices[0 ].delta.content:
236+ print (chunk.choices[0 ].delta.content, end = " " )
236237
237238asyncio.run(main())
238239```
You can’t perform that action at this time.
0 commit comments