notSoNLPnerd commited on
Commit
c95b10f
1 Parent(s): 3514dd3
Files changed (3) hide show
  1. app.py +3 -4
  2. utils/constants.py +4 -4
  3. utils/ui.py +10 -10
app.py CHANGED
@@ -1,9 +1,8 @@
1
  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
- BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG)
7
 
8
  st.set_page_config(
9
  page_title="Retrieval Augmentation with Haystack",
@@ -13,7 +12,7 @@ left_sidebar()
13
 
14
  st.markdown("<center> <h2> Reduce Hallucinations with Retrieval Augmentation </h2> </center>", unsafe_allow_html=True)
15
 
16
- st.markdown("Ask a question about the collapse of the Silicon Valley Bank (SVB).", unsafe_allow_html=True)
17
 
18
  col_1, col_2 = st.columns([4, 2], gap="small")
19
  with col_1:
 
1
  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 left_sidebar, right_sidebar, main_column
5
+ from utils.constants import BUTTON_LOCAL_RET_AUG
 
6
 
7
  st.set_page_config(
8
  page_title="Retrieval Augmentation with Haystack",
 
12
 
13
  st.markdown("<center> <h2> Reduce Hallucinations with Retrieval Augmentation </h2> </center>", unsafe_allow_html=True)
14
 
15
+ st.markdown("<center>Ask a question about the collapse of the Silicon Valley Bank (SVB).</center>", unsafe_allow_html=True)
16
 
17
  col_1, col_2 = st.columns([4, 2], gap="small")
18
  with col_1:
utils/constants.py CHANGED
@@ -6,9 +6,9 @@ QUERIES = [
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"
 
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
@@ -49,16 +49,16 @@ def main_column():
49
  # QUERIES,
50
  # key='q_drop_down', on_change=set_question)
51
 
52
- st.markdown(f"<h5> {PLAIN_GPT_ANS} </h5>", unsafe_allow_html=True)
53
  placeholder_plain_gpt = st.empty()
54
- placeholder_plain_gpt.text_area(f" ", placeholder="The answer will appear here.",
55
  key=PLAIN_GPT_ANS, height=1, label_visibility='collapsed')
56
  if st.session_state.get("query_type", BUTTON_LOCAL_RET_AUG) == BUTTON_LOCAL_RET_AUG:
57
- st.markdown(f"<h5> {GPT_LOCAL_RET_AUG_ANS} </h5>", unsafe_allow_html=True)
58
  else:
59
- st.markdown(f"<h5>{GPT_WEB_RET_AUG_ANS} </h5>", unsafe_allow_html=True)
60
  placeholder_retrieval_augmented = st.empty()
61
- placeholder_retrieval_augmented.text_area(f" ", placeholder="The answer will appear here.",
62
  key=GPT_LOCAL_RET_AUG_ANS, height=1, label_visibility='collapsed')
63
 
64
  return run_pressed, placeholder_plain_gpt, placeholder_retrieval_augmented
@@ -66,11 +66,11 @@ def main_column():
66
 
67
  def right_sidebar():
68
  st.markdown("<h5> Example questions </h5>", unsafe_allow_html=True)
69
- st.button(QUERIES[0], on_click=set_q1)
70
- st.button(QUERIES[1], on_click=set_q2)
71
- st.button(QUERIES[2], on_click=set_q3)
72
- st.button(QUERIES[3], on_click=set_q4)
73
- st.button(QUERIES[4], on_click=set_q5)
74
 
75
 
76
  def left_sidebar():
 
49
  # QUERIES,
50
  # key='q_drop_down', on_change=set_question)
51
 
52
+ st.markdown(f"<h5>{PLAIN_GPT_ANS}</h5>", unsafe_allow_html=True)
53
  placeholder_plain_gpt = st.empty()
54
+ placeholder_plain_gpt.text_area(f" ", placeholder="The answer will appear here.", disabled=True,
55
  key=PLAIN_GPT_ANS, height=1, label_visibility='collapsed')
56
  if st.session_state.get("query_type", BUTTON_LOCAL_RET_AUG) == BUTTON_LOCAL_RET_AUG:
57
+ st.markdown(f"<h5>{GPT_LOCAL_RET_AUG_ANS}</h5>", unsafe_allow_html=True)
58
  else:
59
+ st.markdown(f"<h5>{GPT_WEB_RET_AUG_ANS}</h5>", unsafe_allow_html=True)
60
  placeholder_retrieval_augmented = st.empty()
61
+ placeholder_retrieval_augmented.text_area(f" ", placeholder="The answer will appear here.", disabled=True,
62
  key=GPT_LOCAL_RET_AUG_ANS, height=1, label_visibility='collapsed')
63
 
64
  return run_pressed, placeholder_plain_gpt, placeholder_retrieval_augmented
 
66
 
67
  def right_sidebar():
68
  st.markdown("<h5> Example questions </h5>", unsafe_allow_html=True)
69
+ st.button(QUERIES[0], on_click=set_q1, use_container_width=True)
70
+ st.button(QUERIES[1], on_click=set_q2, use_container_width=True)
71
+ st.button(QUERIES[2], on_click=set_q3, use_container_width=True)
72
+ st.button(QUERIES[3], on_click=set_q4, use_container_width=True)
73
+ st.button(QUERIES[4], on_click=set_q5, use_container_width=True)
74
 
75
 
76
  def left_sidebar():