acecalisto3 commited on
Commit
0ce6bf2
Β·
1 Parent(s): 9bdade4

Update pages/botsify.py

Browse files
Files changed (1) hide show
  1. pages/botsify.py +5 -3
pages/botsify.py CHANGED
@@ -2,6 +2,10 @@ import streamlit as st
2
  from streamlit_chat import message
3
  from transformers import AutoTokenizer, AutoModelForCausalLM
4
 
 
 
 
 
5
  if 'conversation' not in st.session_state:
6
  st.session_state['conversation'] = None
7
  if 'messages' not in st.session_state:
@@ -15,7 +19,7 @@ st.markdown("<h1 style='text-align: center;'>πŸ’» ChatterBot</h1>", unsafe_allow
15
  st.subheader("How Can I Help You Today? πŸ€–")
16
 
17
  st.sidebar.title("πŸ˜ŽπŸ—οΈ")
18
- st.session_state['model_name'] = st.sidebar.text_input("Hugging Face Model Name", value="microsoft/DialoGPT-medium")
19
  summarise_button = st.sidebar.button("Summarise the conversation", key="summarise")
20
  st.sidebar.image('./chatbot.jpg', width=300, use_column_width=True)
21
  if summarise_button:
@@ -24,8 +28,6 @@ if summarise_button:
24
  def get_response(userInput):
25
 
26
  if st.session_state['conversation'] is None:
27
- tokenizer = AutoTokenizer.from_pretrained(st.session_state['model_name'])
28
- model = AutoModelForCausalLM.from_pretrained(st.session_state['model_name'])
29
  st.session_state['conversation'] = ""
30
 
31
  input_ids = tokenizer.encode(userInput + tokenizer.eos_token, return_tensors="pt")
 
2
  from streamlit_chat import message
3
  from transformers import AutoTokenizer, AutoModelForCausalLM
4
 
5
+ # Define the tokenizer and model
6
+ tokenizer = AutoTokenizer.from_pretrained(st.session_state['model_name'])
7
+ model = AutoModelForCausalLM.from_pretrained(st.session_state['model_name'])
8
+
9
  if 'conversation' not in st.session_state:
10
  st.session_state['conversation'] = None
11
  if 'messages' not in st.session_state:
 
19
  st.subheader("How Can I Help You Today? πŸ€–")
20
 
21
  st.sidebar.title("πŸ˜ŽπŸ—οΈ")
22
+ st.session_state['model_name'] = st.sidebar.text_input("Current Model", value="microsoft/DialoGPT-medium")
23
  summarise_button = st.sidebar.button("Summarise the conversation", key="summarise")
24
  st.sidebar.image('./chatbot.jpg', width=300, use_column_width=True)
25
  if summarise_button:
 
28
  def get_response(userInput):
29
 
30
  if st.session_state['conversation'] is None:
 
 
31
  st.session_state['conversation'] = ""
32
 
33
  input_ids = tokenizer.encode(userInput + tokenizer.eos_token, return_tensors="pt")