Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
import requests
|
| 5 |
+
ares_api = os.getenv("ARES_API")
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
headers = {
|
| 10 |
+
"x-api-key": ares_api,
|
| 11 |
+
"content-type": "application/json"
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def inference(query):
|
| 17 |
+
payload = { "query": [query] }
|
| 18 |
+
response = requests.post(url, json=payload, headers=headers)
|
| 19 |
+
response_text=response.json().get('data').get('response_text')
|
| 20 |
+
urls=response.json().get('data').get('web_url')
|
| 21 |
+
return response_text, urls
|
| 22 |
+
|
| 23 |
+
iface = gr.Interface(fn=inference, inputs="text", outputs=["html","json"])
|
| 24 |
+
iface.launch()
|