h2o-api / app.py
DylanWolf's picture
Update app.py
936423c
raw
history blame
918 Bytes
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()