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()