Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ai-data/generative-apis/api-cli/using-chat-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Our chat API is OpenAI compatible. Use OpenAI’s [API reference](https://platfo
- top_p
- max_tokens
- stream
- stream_options
- presence_penalty
- [response_format](/ai-data/generative-apis/how-to/use-structured-outputs)
- logprobs
Expand Down
5 changes: 3 additions & 2 deletions ai-data/generative-apis/how-to/query-language-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ response = client.chat.completions.create(
)

for chunk in response:
if chunk.choices[0].delta.content:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
```

Expand Down Expand Up @@ -167,7 +167,8 @@ async def main():
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content, end="")
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")

asyncio.run(main())
```
5 changes: 3 additions & 2 deletions ai-data/generative-apis/how-to/query-vision-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ response = client.chat.completions.create(
)

for chunk in response:
if chunk.choices[0].delta.content:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
```

Expand Down Expand Up @@ -232,7 +232,8 @@ async def main():
stream=True,
)
async for chunk in stream:
print(chunk.choices[0].delta.content, end="")
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")

asyncio.run(main())
```
Expand Down
Loading