Spaces:
Build error
Build error
Download app.py from ndhek/test-space: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/spaces/ndhek/test-space/resolve/main/app.py
- Command line
-
hf download hf://spaces/ndhek/test-space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ndhek/test-space/resolve/main/app.py
702 Bytes
| import gradio as gr | |
| import os | |
| from openai import AzureOpenAI | |
| def get_resp(question): | |
| response = client.chat.completions.create(model="gpt4-o", messages=[ | |
| { | |
| "role": "user", | |
| "content": [ | |
| {"type": "text", "text": question}, | |
| ], | |
| } | |
| ], | |
| max_tokens=600, | |
| ) | |
| return response.choices[0].message.content | |
| API_KEY = os.getenv('API_KEY') #gpt4o | |
| ENDPOINT = os.getenv('ENDPOINT') | |
| client = AzureOpenAI( | |
| azure_endpoint=ENDPOINT, | |
| api_key=API_KEY, | |
| api_version="2024-02-15-preview" | |
| ) | |
| response= get_resp("Hello") | |
| print(response) | |
| def greet(name): | |
| return "Hello " + name + "!!" | |
| demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
| demo.launch() | |