Spaces:
Runtime error
Runtime error
File size: 918 Bytes
936423c 3c444c8 936423c 3c444c8 936423c 3c444c8 936423c |
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 34 35 36 |
import streamlit as st
import requests
# Function to query the Hugging Face model
def query(data):
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer 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"
}
response = requests.post(
"https://api-inference.huggingface.co/models/h2oai/h2ogpt-gm-oasst1-en-1024-12b",
headers=headers,
json={"inputs": data}
)
result = response.json()
return result.get("generated_text", "No response")
# Streamlit app
def main():
st.title("Hugging Face Chatbot")
st.write("Enter a message to chat with the model:")
# Input text box
user_input = st.text_area("Your Message", "")
if st.button("Submit"):
if user_input:
st.write("User: ", user_input)
response = query(user_input)
st.write("Chatbot: ", response)
if __name__ == "__main__":
main()
|