Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 693ba46

Browse files
committed
fix table views in openai-python
1 parent 5135656 commit 693ba46

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

docs/docs/examples/openai-python.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import asyncio
2323
from openai import AsyncOpenAI
2424

2525
# gets API Key from environment variable OPENAI_API_KEY
26-
client = AsyncOpenAI(base_url="http://localhost:3928/v1/", api_key="sk-xxx")
26+
client = AsyncOpenAI(
27+
base_url="http://localhost:3928/v1/",
28+
api_key="sk-xxx"
29+
)
2730

2831

2932
async def main() -> None:
@@ -75,22 +78,16 @@ asyncio.run(main())
7578
```python
7679
from openai import AzureOpenAI
7780

78-
openai.api_key = '...' # Default is environment variable AZURE_OPENAI_API_KEY
81+
openai.api_key = '...' # Default is AZURE_OPENAI_API_KEY
7982

8083
stream = AzureOpenAI(
8184
api_version=api_version,
82-
# https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
8385
azure_endpoint="https://example-endpoint.openai.azure.com",
8486
)
8587

8688
completion = client.chat.completions.create(
8789
model="deployment-name", # e.g. gpt-35-instant
88-
messages=[
89-
{
90-
"role": "user",
91-
"content": "How do I output all files in a directory using Python?",
92-
},
93-
],
90+
messages=[{"role": "user", "content": "Say this is a test"}],
9491
stream=True,
9592
)
9693
for part in stream:
@@ -116,11 +113,15 @@ import asyncio
116113
from openai import AsyncOpenAI
117114

118115
# gets API Key from environment variable OPENAI_API_KEY
119-
client = AsyncOpenAI(base_url="http://localhost:3928/v1/", api_key="sk-xxx")
116+
client = AsyncOpenAI(base_url="http://localhost:3928/v1/",
117+
api_key="sk-xxx")
120118

121119

122120
async def main() -> None:
123-
embedding = await client.embeddings.create(input='Hello How are you?', model='text-embedding-ada-002')
121+
embedding = await client.embeddings.create(
122+
input='Hello How are you?',
123+
model='text-embedding-ada-002'
124+
)
124125
print(embedding)
125126

126127
asyncio.run(main())
@@ -141,7 +142,10 @@ client = AsyncOpenAI(api_key="sk-xxx")
141142

142143

143144
async def main() -> None:
144-
embedding = await client.embeddings.create(input='Hello How are you?', model='text-embedding-ada-002')
145+
embedding = await client.embeddings.create(
146+
input='Hello How are you?',
147+
model='text-embedding-ada-002'
148+
)
145149
print(embedding)
146150

147151
asyncio.run(main())

0 commit comments

Comments
 (0)