chatLab1 / app.py
peterciank's picture
Update app.py
eaaef65 verified
raw
history blame contribute delete
939 Bytes
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")
'''