Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
-
import
|
2 |
import requests
|
3 |
|
|
|
4 |
def query(data):
|
5 |
headers = {
|
6 |
"Content-Type": "application/json",
|
@@ -16,13 +17,19 @@ def query(data):
|
|
16 |
result = response.json()
|
17 |
return result.get("generated_text", "No response")
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
layout="vertical",
|
24 |
-
title="Hugging Face Chatbot",
|
25 |
-
description="Enter a message to chat with the model.",
|
26 |
-
)
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
import requests
|
3 |
|
4 |
+
# Function to query the Hugging Face model
|
5 |
def query(data):
|
6 |
headers = {
|
7 |
"Content-Type": "application/json",
|
|
|
17 |
result = response.json()
|
18 |
return result.get("generated_text", "No response")
|
19 |
|
20 |
+
# Streamlit app
|
21 |
+
def main():
|
22 |
+
st.title("Hugging Face Chatbot")
|
23 |
+
st.write("Enter a message to chat with the model:")
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
# Input text box
|
26 |
+
user_input = st.text_area("Your Message", "")
|
27 |
+
|
28 |
+
if st.button("Submit"):
|
29 |
+
if user_input:
|
30 |
+
st.write("User: ", user_input)
|
31 |
+
response = query(user_input)
|
32 |
+
st.write("Chatbot: ", response)
|
33 |
+
|
34 |
+
if __name__ == "__main__":
|
35 |
+
main()
|