nx-terminal / app.py
Emerson-Britto
[up]
ac7c1b1
raw
history blame contribute delete
653 Bytes
from dotenv import load_dotenv
import gradio as gr
import requests
import json
load_dotenv()
from os import getenv
api_key = getenv("API_KEY")
# io = gr.Interface.load("spaces/emee/nexa", api_key=api_key)
def main(text):
try:
result = requests.post("https://emee-nexa.hf.space/run/predict", data=json.dumps({
"fn_index": 0,
"data": [text]
}), headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
})
result = result.json()
return result["data"][0]
except Exception as e:
print(str(e))
return []
nx = gr.Interface(fn=main, inputs="text", outputs="json")
nx.launch()