Spaces:
Runtime error
Runtime error
File size: 939 Bytes
a666253 03b119a dab1ed6 b7d7bd0 a666253 03b119a eaaef65 a0e69d5 a666253 03b119a a8841fa 03b119a a8841fa 03b119a a0e69d5 |
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 28 29 30 31 32 33 |
import os
import streamlit as st
import requests
# Set up Hugging Face API details
#token=os.getenv("HF_TOKEN", None)
st.write("Hello")
#st.write(token)
'''
headers = {"Authorization": f"Bearer {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")
''' |