Manith Marapperuma commited on
Commit
41ddf12
·
verified ·
1 Parent(s): 01a2606

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -19
app.py CHANGED
@@ -1,29 +1,17 @@
1
- import streamlit as st
2
  from transformers import pipeline, Conversation
 
3
 
4
  chatbot = pipeline(model="facebook/blenderbot-400M-distill")
5
 
 
 
 
6
  def vanilla_chatbot(message, history):
7
- conversation = Conversation(text=message, past_user_inputs=history)
8
  conversation = chatbot(conversation)
9
 
10
  return conversation.generated_responses[-1]
11
 
12
- # Replace the gradio interface with Streamlit components
13
- st.title("Streamlit Chatbot")
14
- st.write("Enter text to start chatting.")
15
-
16
- # Add a text input and button for the user to submit their message
17
- user_input = st.text_input("")
18
- submit_button = st.button("Submit")
19
-
20
- # Store the chat history in a list
21
- history = []
22
 
23
- # Handle the user's message submission
24
- if submit_button:
25
- message = user_input
26
- response = vanilla_chatbot(message, history)
27
- st.write(f"Bot: {response}")
28
- history.append(message)
29
- history.append(response)
 
 
1
  from transformers import pipeline, Conversation
2
+ import gradio as gr
3
 
4
  chatbot = pipeline(model="facebook/blenderbot-400M-distill")
5
 
6
+ message_list = []
7
+ response_list = []
8
+
9
  def vanilla_chatbot(message, history):
10
+ conversation = Conversation(text=message, past_user_inputs=message_list, generated_responses=response_list)
11
  conversation = chatbot(conversation)
12
 
13
  return conversation.generated_responses[-1]
14
 
15
+ demo_chatbot = gr.ChatInterface(vanilla_chatbot, title="Vanilla Chatbot", description="Enter text to start chatting.")
 
 
 
 
 
 
 
 
 
16
 
17
+ demo_chatbot.launch()