Skip to content

Commit d34a081

Browse files
committed
chore(internal): format some docstrings
1 parent 18191da commit d34a081

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/openai/resources/beta/chat/completions.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,17 @@ def parse(
7878
from pydantic import BaseModel
7979
from openai import OpenAI
8080
81+
8182
class Step(BaseModel):
8283
explanation: str
8384
output: str
8485
86+
8587
class MathResponse(BaseModel):
8688
steps: List[Step]
8789
final_answer: str
8890
91+
8992
client = OpenAI()
9093
completion = client.beta.chat.completions.parse(
9194
model="gpt-4o-2024-08-06",
@@ -184,12 +187,12 @@ def stream(
184187
185188
```py
186189
with client.beta.chat.completions.stream(
187-
model='gpt-4o-2024-08-06',
190+
model="gpt-4o-2024-08-06",
188191
messages=[...],
189192
) as stream:
190193
for event in stream:
191-
if event.type == 'content.delta':
192-
print(event.content, flush=True, end='')
194+
if event.type == "content.delta":
195+
print(event.content, flush=True, end="")
193196
```
194197
195198
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).
@@ -287,14 +290,17 @@ async def parse(
287290
from pydantic import BaseModel
288291
from openai import AsyncOpenAI
289292
293+
290294
class Step(BaseModel):
291295
explanation: str
292296
output: str
293297
298+
294299
class MathResponse(BaseModel):
295300
steps: List[Step]
296301
final_answer: str
297302
303+
298304
client = AsyncOpenAI()
299305
completion = await client.beta.chat.completions.parse(
300306
model="gpt-4o-2024-08-06",
@@ -393,12 +399,12 @@ def stream(
393399
394400
```py
395401
async with client.beta.chat.completions.stream(
396-
model='gpt-4o-2024-08-06',
402+
model="gpt-4o-2024-08-06",
397403
messages=[...],
398404
) as stream:
399405
async for event in stream:
400-
if event.type == 'content.delta':
401-
print(event.content, flush=True, end='')
406+
if event.type == "content.delta":
407+
print(event.content, flush=True, end="")
402408
```
403409
404410
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).

0 commit comments

Comments
 (0)