Skip to content

Commit

Permalink
chore(internal): format some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored and stainless-app[bot] committed Aug 8, 2024
1 parent 5f52e47 commit a9b8aa8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/openai/resources/beta/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ def parse(
from pydantic import BaseModel
from openai import OpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = OpenAI()
completion = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
Expand Down Expand Up @@ -184,12 +187,12 @@ def stream(
```py
with client.beta.chat.completions.stream(
model='gpt-4o-2024-08-06',
model="gpt-4o-2024-08-06",
messages=[...],
) as stream:
for event in stream:
if event.type == 'content.delta':
print(event.content, flush=True, end='')
if event.type == "content.delta":
print(event.content, flush=True, end="")
```
When the context manager is entered, a `ChatCompletionStream` instance is returned which, like `.create(stream=True)` is an iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
Expand Down Expand Up @@ -287,14 +290,17 @@ async def parse(
from pydantic import BaseModel
from openai import AsyncOpenAI
class Step(BaseModel):
explanation: str
output: str
class MathResponse(BaseModel):
steps: List[Step]
final_answer: str
client = AsyncOpenAI()
completion = await client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
Expand Down Expand Up @@ -393,12 +399,12 @@ def stream(
```py
async with client.beta.chat.completions.stream(
model='gpt-4o-2024-08-06',
model="gpt-4o-2024-08-06",
messages=[...],
) as stream:
async for event in stream:
if event.type == 'content.delta':
print(event.content, flush=True, end='')
if event.type == "content.delta":
print(event.content, flush=True, end="")
```
When the context manager is entered, an `AsyncChatCompletionStream` instance is returned which, like `.create(stream=True)` is an async iterator. The full list of events that are yielded by the iterator are outlined in [these docs](https://github.com/openai/openai-python/blob/main/helpers.md#chat-completions-events).
Expand Down

0 comments on commit a9b8aa8

Please sign in to comment.