DylanWolf commited on
Commit
936423c
·
1 Parent(s): 94e7944

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -10
app.py CHANGED
@@ -1,6 +1,7 @@
1
- import gradio as gr
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
- iface = gr.Interface(
20
- fn=query,
21
- inputs=gr.inputs.Textbox(label="Input"),
22
- outputs=gr.outputs.Textbox(label="Output"),
23
- layout="vertical",
24
- title="Hugging Face Chatbot",
25
- description="Enter a message to chat with the model.",
26
- )
27
 
28
- iface.launch(server_port=8889)
 
 
 
 
 
 
 
 
 
 
 
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()