Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,36 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
def greet(name):
|
| 4 |
return "Hello " + name + "!!"
|
| 5 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
import os
|
| 4 |
+
from openai import AzureOpenAI
|
| 5 |
+
|
| 6 |
+
def get_resp(question):
|
| 7 |
+
|
| 8 |
+
response = client.chat.completions.create(model="gpt4-o", messages=[
|
| 9 |
+
{
|
| 10 |
+
"role": "user",
|
| 11 |
+
"content": [
|
| 12 |
+
{"type": "text", "text": question},
|
| 13 |
+
],
|
| 14 |
+
}
|
| 15 |
+
],
|
| 16 |
+
max_tokens=600,
|
| 17 |
+
)
|
| 18 |
+
return response.choices[0].message.content
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
API_KEY = 'a3babad21aee482798891f0e56f538f4' #gpt4o
|
| 22 |
+
ENDPOINT = 'https://invite-instance-openai.openai.azure.com/'
|
| 23 |
+
|
| 24 |
+
client = AzureOpenAI(
|
| 25 |
+
azure_endpoint=ENDPOINT,
|
| 26 |
+
api_key=API_KEY,
|
| 27 |
+
api_version="2024-02-15-preview"
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
response= get_resp("Hello")
|
| 31 |
+
|
| 32 |
+
print(response)
|
| 33 |
+
|
| 34 |
def greet(name):
|
| 35 |
return "Hello " + name + "!!"
|
| 36 |
|