Spaces:
Runtime error
Runtime error
File size: 767 Bytes
a8841fa dab1ed6 b7d7bd0 dab1ed6 a8841fa dab1ed6 a8841fa dab1ed6 a8841fa dab1ed6 a8841fa dab1ed6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import os
import requests
import gradio as gr
# Define function to query the AI model
def query(payload):
token = os.getenv("HF_TOKEN", None)
headers = {"Authorization": f"Bearer {token}"}
API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# Create Gradio interface
def chat(input_text):
data = query({"inputs": input_text, "parameters": {"do_sample": False}})
return data[0]['generated_text']
input_text = gr.Textbox(lines=7, label="Input Text")
output_text = gr.Textbox(label="Model Response")
gr.Interface(fn=chat, inputs=input_text, outputs=output_text, title="AI Chat", description="Chat with AI model").launch()
|