Spaces:
Sleeping
Sleeping
John Graham Reynolds
commited on
Commit
·
769696c
1
Parent(s):
d9ea188
clean up app comments
Browse files- src/streamlit_app.py +3 -8
src/streamlit_app.py
CHANGED
|
@@ -2,9 +2,6 @@ import streamlit as st
|
|
| 2 |
from chain import GlossaryChain
|
| 3 |
|
| 4 |
MODEL_AVATAR_URL= "./mistral.jpeg"
|
| 5 |
-
MAX_CHAT_TURNS = 10 # limit this for preliminary testing
|
| 6 |
-
MSG_MAX_TURNS_EXCEEDED = f"Sorry! The Mistral AI🦜🇫🇷🚀 playground is limited to {MAX_CHAT_TURNS} turns in a single history. Click the 'Clear Chat' button or refresh the page to start a new conversation."
|
| 7 |
-
|
| 8 |
EXAMPLE_PROMPTS = [
|
| 9 |
"How is a data lake used at Vanderbilt University Medical Center?",
|
| 10 |
"In a table, what are some of the greatest hurdles to healthcare in the United States?",
|
|
@@ -13,7 +10,6 @@ EXAMPLE_PROMPTS = [
|
|
| 13 |
"Write a short story about a country concert in Nashville, Tennessee.",
|
| 14 |
"Tell me about maximum out-of-pocket costs for healthcare in the United States.",
|
| 15 |
]
|
| 16 |
-
|
| 17 |
TITLE = "Mistral AI🇫🇷 + LangChain🦜 + FAISS📘: VUMC Glossary Chatbot"
|
| 18 |
DESCRIPTION= """Welcome to the Mistral AI🇫🇷 + LangChain🦜 + FAISS📘: VUMC Glossary Chatbot! \n
|
| 19 |
|
|
@@ -31,7 +27,6 @@ On the left is a sidebar of **Examples**; click any of these examples to issue t
|
|
| 31 |
|
| 32 |
Please provide any additional, larger feedback, ideas, or issues to the email: **johngrahamreynolds@gmail.com**. Happy chatting!"""
|
| 33 |
|
| 34 |
-
GENERAL_ERROR_MSG = "An error occurred. Please refresh the page to start a new conversation."
|
| 35 |
|
| 36 |
st.set_page_config(layout="wide")
|
| 37 |
|
|
@@ -54,7 +49,7 @@ def clear_chat_history():
|
|
| 54 |
|
| 55 |
st.button('Clear Chat', on_click=clear_chat_history)
|
| 56 |
|
| 57 |
-
#
|
| 58 |
chain = GlossaryChain()
|
| 59 |
|
| 60 |
def last_role_is_user():
|
|
@@ -63,8 +58,8 @@ def last_role_is_user():
|
|
| 63 |
def get_last_question():
|
| 64 |
return st.session_state["messages"][-1]["content"]
|
| 65 |
|
| 66 |
-
#
|
| 67 |
-
#
|
| 68 |
def handle_user_input(user_input):
|
| 69 |
with history:
|
| 70 |
response_content = ""
|
|
|
|
| 2 |
from chain import GlossaryChain
|
| 3 |
|
| 4 |
MODEL_AVATAR_URL= "./mistral.jpeg"
|
|
|
|
|
|
|
|
|
|
| 5 |
EXAMPLE_PROMPTS = [
|
| 6 |
"How is a data lake used at Vanderbilt University Medical Center?",
|
| 7 |
"In a table, what are some of the greatest hurdles to healthcare in the United States?",
|
|
|
|
| 10 |
"Write a short story about a country concert in Nashville, Tennessee.",
|
| 11 |
"Tell me about maximum out-of-pocket costs for healthcare in the United States.",
|
| 12 |
]
|
|
|
|
| 13 |
TITLE = "Mistral AI🇫🇷 + LangChain🦜 + FAISS📘: VUMC Glossary Chatbot"
|
| 14 |
DESCRIPTION= """Welcome to the Mistral AI🇫🇷 + LangChain🦜 + FAISS📘: VUMC Glossary Chatbot! \n
|
| 15 |
|
|
|
|
| 27 |
|
| 28 |
Please provide any additional, larger feedback, ideas, or issues to the email: **johngrahamreynolds@gmail.com**. Happy chatting!"""
|
| 29 |
|
|
|
|
| 30 |
|
| 31 |
st.set_page_config(layout="wide")
|
| 32 |
|
|
|
|
| 49 |
|
| 50 |
st.button('Clear Chat', on_click=clear_chat_history)
|
| 51 |
|
| 52 |
+
# construct the chain
|
| 53 |
chain = GlossaryChain()
|
| 54 |
|
| 55 |
def last_role_is_user():
|
|
|
|
| 58 |
def get_last_question():
|
| 59 |
return st.session_state["messages"][-1]["content"]
|
| 60 |
|
| 61 |
+
# If the assistant is the last message, we need to prompt the user
|
| 62 |
+
# If user is the last message, we need to retry the assistant.
|
| 63 |
def handle_user_input(user_input):
|
| 64 |
with history:
|
| 65 |
response_content = ""
|