MatheusHRV commited on
Commit
2b94a2b
1 Parent(s): 0b3b50c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -41
app.py CHANGED
@@ -1,55 +1,30 @@
1
-
2
  import streamlit as st
 
3
 
 
 
4
 
5
- from langchain.chat_models import ChatOpenAI
6
- from langchain.schema import (
7
- AIMessage,
8
- HumanMessage,
9
- SystemMessage
10
- )
11
-
12
- # From here down is all the StreamLit UI
13
- st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
14
- st.header("IPE Chatbot")
15
-
16
-
17
-
18
- if "sessionMessages" not in st.session_state:
19
- st.session_state.sessionMessages = [
20
- SystemMessage(content="You are customer support chatbot from a website.")
21
- ]
22
-
23
 
 
 
24
 
25
  def load_answer(question):
26
-
27
- st.session_state.sessionMessages.append(HumanMessage(content=question))
28
-
29
- assistant_answer = chat(st.session_state.sessionMessages )
30
-
31
- st.session_state.sessionMessages.append(AIMessage(content=assistant_answer.content))
32
-
33
- return assistant_answer.content
34
-
35
 
36
  def get_text():
37
- input_text = st.text_input("You: ", key= input)
38
  return input_text
39
 
40
-
41
- chat = ChatOpenAI(temperature=0)
42
-
43
-
44
-
45
-
46
- user_input=get_text()
47
- submit = st.button('Generate')
48
 
49
  if submit:
50
-
51
  response = load_answer(user_input)
52
  st.subheader("Answer:")
53
-
54
- st.write(response,key= 1)
55
-
 
 
1
  import streamlit as st
2
+ from transformers import Conversation, pipeline
3
 
4
+ st.set_page_config(page_title="Dolphin Chatbot", page_icon=":robot_face:")
5
+ st.header("Dolphin 2.6 Mistral 7B Chatbot")
6
 
7
+ # Initialize the conversation pipeline with dolphin-2.6-mistral-7b model
8
+ conversational_pipeline = pipeline('conversational', model='google/flan-t5-large')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ if "conversation" not in st.session_state:
11
+ st.session_state.conversation = Conversation()
12
 
13
  def load_answer(question):
14
+ new_user_input = Conversation(text=question)
15
+ st.session_state.conversation.add_user_input(question)
16
+ assistant_answer = conversational_pipeline(st.session_state.conversation)
17
+ st.session_state.conversation = assistant_answer
18
+ return assistant_answer.text
 
 
 
 
19
 
20
  def get_text():
21
+ input_text = st.text_input("You: ", key="input_text")
22
  return input_text
23
 
24
+ user_input = get_text()
25
+ submit = st.button('Generate')
 
 
 
 
 
 
26
 
27
  if submit:
 
28
  response = load_answer(user_input)
29
  st.subheader("Answer:")
30
+ st.write(response)