Spaces:
Sleeping
Sleeping
github-actions
commited on
Commit
·
c72a9f3
1
Parent(s):
c13ae5a
Sync updates from source repository
Browse files
app.py
CHANGED
|
@@ -29,7 +29,8 @@ def launch_bot():
|
|
| 29 |
'description': os.environ['description'],
|
| 30 |
'source_data_desc': os.environ['source_data_desc'],
|
| 31 |
'streaming': isTrue(os.environ.get('streaming', False)),
|
| 32 |
-
'prompt_name': os.environ.get('prompt_name', None)
|
|
|
|
| 33 |
})
|
| 34 |
st.session_state.cfg = cfg
|
| 35 |
st.session_state.vq = VectaraQuery(cfg.api_key, cfg.customer_id, cfg.corpus_ids, cfg.prompt_name)
|
|
@@ -60,6 +61,12 @@ def launch_bot():
|
|
| 60 |
if "messages" not in st.session_state.keys():
|
| 61 |
st.session_state.messages = [{"role": "assistant", "content": "How may I help you?"}]
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
# Display chat messages
|
| 64 |
for message in st.session_state.messages:
|
| 65 |
with st.chat_message(message["role"]):
|
|
@@ -70,7 +77,20 @@ def launch_bot():
|
|
| 70 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 71 |
with st.chat_message("user"):
|
| 72 |
st.write(prompt)
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
# Generate a new response if last message is not from assistant
|
| 75 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 76 |
with st.chat_message("assistant"):
|
|
|
|
| 29 |
'description': os.environ['description'],
|
| 30 |
'source_data_desc': os.environ['source_data_desc'],
|
| 31 |
'streaming': isTrue(os.environ.get('streaming', False)),
|
| 32 |
+
'prompt_name': os.environ.get('prompt_name', None),
|
| 33 |
+
'examples': os.environ.get('examples', '')
|
| 34 |
})
|
| 35 |
st.session_state.cfg = cfg
|
| 36 |
st.session_state.vq = VectaraQuery(cfg.api_key, cfg.customer_id, cfg.corpus_ids, cfg.prompt_name)
|
|
|
|
| 61 |
if "messages" not in st.session_state.keys():
|
| 62 |
st.session_state.messages = [{"role": "assistant", "content": "How may I help you?"}]
|
| 63 |
|
| 64 |
+
example_messages = [example.strip() for example in cfg.examples.split(",")]
|
| 65 |
+
example_messages = [em for em in example_messages if len(em)>0]
|
| 66 |
+
if len(example_messages) > 0:
|
| 67 |
+
st.markdown("<h6>Queries To Try:</h6>", unsafe_allow_html=True)
|
| 68 |
+
ex_cols = st.columns(4)
|
| 69 |
+
|
| 70 |
# Display chat messages
|
| 71 |
for message in st.session_state.messages:
|
| 72 |
with st.chat_message(message["role"]):
|
|
|
|
| 77 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 78 |
with st.chat_message("user"):
|
| 79 |
st.write(prompt)
|
| 80 |
+
|
| 81 |
+
# Example prompt
|
| 82 |
+
for i, example in enumerate(example_messages):
|
| 83 |
+
button_pressed = False
|
| 84 |
+
with ex_cols[i]:
|
| 85 |
+
if st.button(example):
|
| 86 |
+
prompt = example
|
| 87 |
+
button_pressed = True
|
| 88 |
+
|
| 89 |
+
if button_pressed:
|
| 90 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 91 |
+
with st.chat_message("user"):
|
| 92 |
+
st.write(prompt)
|
| 93 |
+
|
| 94 |
# Generate a new response if last message is not from assistant
|
| 95 |
if st.session_state.messages[-1]["role"] != "assistant":
|
| 96 |
with st.chat_message("assistant"):
|