Upload gpt.py with huggingface_hub
Browse files
gpt.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from openai import AzureOpenAI
|
| 3 |
+
|
| 4 |
+
client = AzureOpenAI(
|
| 5 |
+
azure_endpoint="https://game1.openai.azure.com/",
|
| 6 |
+
api_key="bda40d2804ef45f2b9ddb4c3bd996aca",
|
| 7 |
+
api_version="2024-02-01",
|
| 8 |
+
# azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
|
| 9 |
+
# api_key=os.getenv("AZURE_OPENAI_API_KEY"),
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
response = client.chat.completions.create(
|
| 13 |
+
model="gpt-4o",
|
| 14 |
+
messages=[
|
| 15 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 16 |
+
{"role": "user", "content": "好困啊"},
|
| 17 |
+
],
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
print(response.choices[0].message.content)
|