Spaces:
Runtime error
Runtime error
notSoNLPnerd
commited on
Commit
•
1c101d7
1
Parent(s):
94aee35
fixed buttons
Browse files- app.py +3 -3
- utils/constants.py +5 -1
- utils/ui.py +4 -8
app.py
CHANGED
@@ -2,7 +2,8 @@ import streamlit as st
|
|
2 |
from utils.backend import (get_plain_pipeline, get_retrieval_augmented_pipeline,
|
3 |
get_web_retrieval_augmented_pipeline)
|
4 |
from utils.ui import set_q1, set_q2, set_q3, set_q4, set_q5, left_sidebar, right_sidebar, main_column
|
5 |
-
from utils.constants import QUERIES, PLAIN_GPT_ANS, GPT_WEB_RET_AUG_ANS, GPT_LOCAL_RET_AUG_ANS
|
|
|
6 |
|
7 |
st.set_page_config(
|
8 |
page_title="Retrieval Augmentation with Haystack",
|
@@ -17,7 +18,6 @@ st.markdown("Ask a question about the collapse of the Silicon Valley Bank (SVB).
|
|
17 |
col_1, col_2 = st.columns([4, 2], gap="small")
|
18 |
with col_1:
|
19 |
run_pressed, placeholder_plain_gpt, placeholder_retrieval_augmented = main_column()
|
20 |
-
print(f"Run value: {st.session_state.get('run', 'not found')}")
|
21 |
|
22 |
with col_2:
|
23 |
right_sidebar()
|
@@ -31,7 +31,7 @@ if st.session_state.get('query') and run_pressed:
|
|
31 |
answers = p1.run(ip)
|
32 |
placeholder_plain_gpt.markdown(answers['results'][0])
|
33 |
|
34 |
-
if st.session_state.get("query_type",
|
35 |
with st.spinner(
|
36 |
'Loading Retrieval Augmented pipeline that can fetch relevant documents from local data store... '
|
37 |
'\n This may take a few mins and might also fail if OpenAI API server is down.'):
|
|
|
2 |
from utils.backend import (get_plain_pipeline, get_retrieval_augmented_pipeline,
|
3 |
get_web_retrieval_augmented_pipeline)
|
4 |
from utils.ui import set_q1, set_q2, set_q3, set_q4, set_q5, left_sidebar, right_sidebar, main_column
|
5 |
+
from utils.constants import (QUERIES, PLAIN_GPT_ANS, GPT_WEB_RET_AUG_ANS, GPT_LOCAL_RET_AUG_ANS,
|
6 |
+
BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG)
|
7 |
|
8 |
st.set_page_config(
|
9 |
page_title="Retrieval Augmentation with Haystack",
|
|
|
18 |
col_1, col_2 = st.columns([4, 2], gap="small")
|
19 |
with col_1:
|
20 |
run_pressed, placeholder_plain_gpt, placeholder_retrieval_augmented = main_column()
|
|
|
21 |
|
22 |
with col_2:
|
23 |
right_sidebar()
|
|
|
31 |
answers = p1.run(ip)
|
32 |
placeholder_plain_gpt.markdown(answers['results'][0])
|
33 |
|
34 |
+
if st.session_state.get("query_type", BUTTON_LOCAL_RET_AUG) == BUTTON_LOCAL_RET_AUG:
|
35 |
with st.spinner(
|
36 |
'Loading Retrieval Augmented pipeline that can fetch relevant documents from local data store... '
|
37 |
'\n This may take a few mins and might also fail if OpenAI API server is down.'):
|
utils/constants.py
CHANGED
@@ -2,9 +2,13 @@ QUERIES = [
|
|
2 |
"Did SVB collapse?",
|
3 |
"Why did SVB collapse?",
|
4 |
"What does SVB failure mean for our economy?",
|
5 |
-
"Who is responsible for
|
6 |
"When did SVB collapse?"
|
7 |
]
|
8 |
PLAIN_GPT_ANS = "Answer with plain GPT"
|
9 |
GPT_LOCAL_RET_AUG_ANS = "Answer with Retrieval Augmented GPT (Static news dataset)"
|
10 |
GPT_WEB_RET_AUG_ANS = "Answer with Retrieval Augmented GPT (Web Search)"
|
|
|
|
|
|
|
|
|
|
2 |
"Did SVB collapse?",
|
3 |
"Why did SVB collapse?",
|
4 |
"What does SVB failure mean for our economy?",
|
5 |
+
"Who is responsible for SVB collapse?",
|
6 |
"When did SVB collapse?"
|
7 |
]
|
8 |
PLAIN_GPT_ANS = "Answer with plain GPT"
|
9 |
GPT_LOCAL_RET_AUG_ANS = "Answer with Retrieval Augmented GPT (Static news dataset)"
|
10 |
GPT_WEB_RET_AUG_ANS = "Answer with Retrieval Augmented GPT (Web Search)"
|
11 |
+
|
12 |
+
|
13 |
+
BUTTON_LOCAL_RET_AUG = "Retrieval Augmented (Static news dataset)"
|
14 |
+
BUTTON_WEB_RET_AUG = "Retrieval Augmented with Web Search"
|
utils/ui.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
|
4 |
-
from .constants import QUERIES, PLAIN_GPT_ANS, GPT_WEB_RET_AUG_ANS, GPT_LOCAL_RET_AUG_ANS
|
|
|
5 |
|
6 |
|
7 |
def set_question():
|
@@ -27,6 +28,7 @@ def set_q4():
|
|
27 |
def set_q5():
|
28 |
st.session_state['query'] = QUERIES[4]
|
29 |
|
|
|
30 |
def main_column():
|
31 |
placeholder = st.empty()
|
32 |
with placeholder:
|
@@ -40,7 +42,7 @@ def main_column():
|
|
40 |
run_pressed = st.button("Run", key="run")
|
41 |
|
42 |
st.write(" ")
|
43 |
-
st.radio("Answer Type:", (
|
44 |
|
45 |
# st.sidebar.selectbox(
|
46 |
# "Example Questions:",
|
@@ -62,16 +64,10 @@ def main_column():
|
|
62 |
|
63 |
def right_sidebar():
|
64 |
st.markdown("<h5> Example questions </h5>", unsafe_allow_html=True)
|
65 |
-
# c1, c2, c3, c4, c5 = st.columns(5)
|
66 |
-
# with c1:
|
67 |
st.button(QUERIES[0], on_click=set_q1)
|
68 |
-
# with c2:
|
69 |
st.button(QUERIES[1], on_click=set_q2)
|
70 |
-
# with c3:
|
71 |
st.button(QUERIES[2], on_click=set_q3)
|
72 |
-
# with c4:
|
73 |
st.button(QUERIES[3], on_click=set_q4)
|
74 |
-
# with c5:
|
75 |
st.button(QUERIES[4], on_click=set_q5)
|
76 |
|
77 |
|
|
|
1 |
import streamlit as st
|
2 |
from PIL import Image
|
3 |
|
4 |
+
from .constants import (QUERIES, PLAIN_GPT_ANS, GPT_WEB_RET_AUG_ANS, GPT_LOCAL_RET_AUG_ANS,
|
5 |
+
BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG)
|
6 |
|
7 |
|
8 |
def set_question():
|
|
|
28 |
def set_q5():
|
29 |
st.session_state['query'] = QUERIES[4]
|
30 |
|
31 |
+
|
32 |
def main_column():
|
33 |
placeholder = st.empty()
|
34 |
with placeholder:
|
|
|
42 |
run_pressed = st.button("Run", key="run")
|
43 |
|
44 |
st.write(" ")
|
45 |
+
st.radio("Answer Type:", (BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG), key="query_type")
|
46 |
|
47 |
# st.sidebar.selectbox(
|
48 |
# "Example Questions:",
|
|
|
64 |
|
65 |
def right_sidebar():
|
66 |
st.markdown("<h5> Example questions </h5>", unsafe_allow_html=True)
|
|
|
|
|
67 |
st.button(QUERIES[0], on_click=set_q1)
|
|
|
68 |
st.button(QUERIES[1], on_click=set_q2)
|
|
|
69 |
st.button(QUERIES[2], on_click=set_q3)
|
|
|
70 |
st.button(QUERIES[3], on_click=set_q4)
|
|
|
71 |
st.button(QUERIES[4], on_click=set_q5)
|
72 |
|
73 |
|