Spaces:
Runtime error
Runtime error
File size: 854 Bytes
03b119a dab1ed6 b7d7bd0 03b119a a8841fa 03b119a a8841fa 03b119a |
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 27 |
import streamlit as st
import requests
# Set up Hugging Face API details
headers = {"Authorization": f"Bearer {HF_TOKEN}"}
API_URL = "https://api-inference.huggingface.co/models/facebook/bart-large-cnn"
# Function to query the Hugging Face model
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
# Streamlit UI
st.title("Chat App with Hugging Face")
user_input = st.text_input("You:", "")
if st.button("Send"):
if user_input.strip() != "":
# Query Hugging Face model
data = query({"inputs": user_input, "parameters": {"do_sample": False}})
# Display response
if data and "summary_text" in data[0]:
st.text_area("Bot:", value=data[0]["summary_text"], height=150)
else:
st.error("No response from the model")
|