Spaces:
Sleeping
Sleeping
Update test_openai.py
Browse files- test_openai.py +18 -0
test_openai.py
CHANGED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai import OpenAI
|
2 |
+
import certifi
|
3 |
+
import httpx
|
4 |
+
|
5 |
+
|
6 |
+
client = OpenAI(
|
7 |
+
api_key="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"
|
8 |
+
)
|
9 |
+
|
10 |
+
completion = client.chat.completions.create(
|
11 |
+
model="gpt-4o-mini",
|
12 |
+
store=True,
|
13 |
+
messages=[
|
14 |
+
{"role": "user", "content": "write a haiku about ai"}
|
15 |
+
]
|
16 |
+
)
|
17 |
+
|
18 |
+
print(completion.choices[0].message);
|