Update Home.py
Browse files
Home.py
CHANGED
|
@@ -1,22 +1,29 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_option_menu import option_menu
|
|
|
|
| 3 |
|
|
|
|
| 4 |
|
| 5 |
-
def homepage():
|
| 6 |
-
st.write("Timeline")
|
| 7 |
-
# allmessages =[]
|
| 8 |
-
if "messages" not in st.session_state:
|
| 9 |
-
st.session_state.messages = []
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
def chat():
|
| 18 |
-
st.
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
# def invoke_document():
|
| 22 |
# st.write("Invoke Document")
|
|
@@ -44,11 +51,11 @@ def chat():
|
|
| 44 |
def dashboard():
|
| 45 |
|
| 46 |
with st.sidebar:
|
| 47 |
-
selected = option_menu(None, [
|
| 48 |
-
icons=[
|
| 49 |
-
if selected == 'Home':
|
| 50 |
-
|
| 51 |
-
|
| 52 |
chat()
|
| 53 |
elif selected == 'Logout':
|
| 54 |
st.session_state.user = None
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from streamlit_option_menu import option_menu
|
| 3 |
+
from transformers import pipeline, Conversation
|
| 4 |
|
| 5 |
+
pipe = pipeline(task="conversational", model="microsoft/DialoGPT-medium")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
# def homepage():
|
| 9 |
+
# st.write("Timeline")
|
| 10 |
+
# # allmessages =[]
|
| 11 |
+
# if "messages" not in st.session_state:
|
| 12 |
+
# st.session_state.messages = []
|
| 13 |
+
|
| 14 |
+
# if usrmsg := st.chat_input("Share a thought"):
|
| 15 |
+
# st.session_state.messages.append(usrmsg)
|
| 16 |
+
# with st.chat_message("user"):
|
| 17 |
+
# st.session_state.messages
|
| 18 |
|
| 19 |
|
| 20 |
def chat():
|
| 21 |
+
if query := st.chat_input("Enter your message"):
|
| 22 |
+
uquery = Conversation(query)
|
| 23 |
+
response = pipe(uquery)
|
| 24 |
+
with st.chat_message("assistant"):
|
| 25 |
+
response.generated_responses[-1]
|
| 26 |
+
|
| 27 |
|
| 28 |
# def invoke_document():
|
| 29 |
# st.write("Invoke Document")
|
|
|
|
| 51 |
def dashboard():
|
| 52 |
|
| 53 |
with st.sidebar:
|
| 54 |
+
selected = option_menu(None, [Chat', "Logout"],
|
| 55 |
+
icons=[π¬', "π"])
|
| 56 |
+
# if selected == 'Home':
|
| 57 |
+
# homepage()
|
| 58 |
+
if selected == 'Chat':
|
| 59 |
chat()
|
| 60 |
elif selected == 'Logout':
|
| 61 |
st.session_state.user = None
|