MatheusHRV commited on
Commit
90e20f9
·
verified ·
1 Parent(s): 04645e1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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='cognitivecomputations/dolphin-2.6-mistral-7b')
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)