ngmitam commited on
Commit
b6c58fc
·
1 Parent(s): 29c6a9c

Update example questions

Browse files
Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -79,6 +79,14 @@ def display_pdf(pdf):
79
  st.markdown(pdf_display, unsafe_allow_html=True)
80
 
81
 
 
 
 
 
 
 
 
 
82
  def main():
83
  load_dotenv()
84
  if "ggml-gpt4all-j-v1.3-groovy.bin" not in os.listdir("/tmp"):
@@ -86,18 +94,23 @@ def main():
86
  filename="ggml-gpt4all-j-v1.3-groovy.bin", local_dir="/tmp")
87
  st.set_page_config(page_title="Trade Document Chatbot")
88
 
89
- st.header("Choose document")
 
 
90
  for pdf in os.listdir("./docs"):
91
  if st.button(pdf):
92
  with st.spinner("Loading document..."):
 
93
  pdf_text = get_pdf_text(["./docs/"+pdf])
94
  text_chunks = get_text_chunks(pdf_text)
95
  vectorstore = get_vectorstore(text_chunks)
96
  conversation_chain = get_conversation_chain(vectorstore)
97
  st.session_state.conversation = conversation_chain
98
  st.session_state.chat_history = None
99
- st.success("<-- Chat about the document on the left sidebar")
100
- display_pdf(pdf)
 
 
101
 
102
  with st.sidebar:
103
  if "conversation" not in st.session_state:
@@ -107,6 +120,11 @@ def main():
107
  st.header("Query your document")
108
  user_question = st.text_input(
109
  "Ask a question about the document...", disabled=not st.session_state.conversation)
 
 
 
 
 
110
  if user_question and st.session_state.conversation:
111
  user_input(user_question)
112
 
 
79
  st.markdown(pdf_display, unsafe_allow_html=True)
80
 
81
 
82
+ examples = [
83
+ "How climate change impact the world trade in 2022?",
84
+ "What is trade trending in 2022?",
85
+ "What is the impact of covid on trade in 2022?",
86
+ "What is role of WTO in world trade?",
87
+ ]
88
+
89
+
90
  def main():
91
  load_dotenv()
92
  if "ggml-gpt4all-j-v1.3-groovy.bin" not in os.listdir("/tmp"):
 
94
  filename="ggml-gpt4all-j-v1.3-groovy.bin", local_dir="/tmp")
95
  st.set_page_config(page_title="Trade Document Chatbot")
96
 
97
+ if "pdf" not in st.session_state:
98
+ st.session_state.pdf = None
99
+ st.header("Choose document")
100
  for pdf in os.listdir("./docs"):
101
  if st.button(pdf):
102
  with st.spinner("Loading document..."):
103
+ st.session_state.pdf = pdf
104
  pdf_text = get_pdf_text(["./docs/"+pdf])
105
  text_chunks = get_text_chunks(pdf_text)
106
  vectorstore = get_vectorstore(text_chunks)
107
  conversation_chain = get_conversation_chain(vectorstore)
108
  st.session_state.conversation = conversation_chain
109
  st.session_state.chat_history = None
110
+
111
+ if st.session_state.pdf:
112
+ if st.success("<-- Chat about the document on the left sidebar"):
113
+ display_pdf(st.session_state.pdf)
114
 
115
  with st.sidebar:
116
  if "conversation" not in st.session_state:
 
120
  st.header("Query your document")
121
  user_question = st.text_input(
122
  "Ask a question about the document...", disabled=not st.session_state.conversation)
123
+
124
+ if st.session_state.conversation:
125
+ for example in examples:
126
+ if st.button(example):
127
+ user_question = example
128
  if user_question and st.session_state.conversation:
129
  user_input(user_question)
130