Skip to content

Commit f2f41ff

Browse files
committed
fix(ai): update matching OpenAI specs
1 parent f3d95b0 commit f2f41ff

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

ai-data/generative-apis/api-cli/using-chat-api.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

ai-data/generative-apis/how-to/query-language-models.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ response = client.chat.completions.create(
139139
)
140140

141141
for 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

172173
asyncio.run(main())
173174
```

ai-data/generative-apis/how-to/query-vision-models.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ response = client.chat.completions.create(
201201
)
202202

203203
for 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

237238
asyncio.run(main())
238239
```

0 commit comments

Comments
 (0)