Spaces:
Sleeping
Sleeping
File size: 615 Bytes
36df9c4 d54668f e458622 36df9c4 ddfb683 36df9c4 d54668f 36df9c4 d54668f 36df9c4 d54668f e458622 d54668f 36df9c4 d54668f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import gradio as gr
import requests
import os
API_URL = "AIzaSyDFEsGucsM9q_3w5mtG0FhNeOnJND7ZMSc"
headers = {
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}",
"Content-Type": "application/json"
}
def respond(message, history):
payload = {
"inputs": f"You are a sports assistant. Answer this clearly: {message}"
}
response = requests.post(API_URL, headers=headers, json=payload)
result = response.json()
if isinstance(result, list):
return result[0]["generated_text"]
else:
return "Error: " + str(result)
demo = gr.ChatInterface(respond)
demo.launch() |