lingyit1108 commited on
Commit
9b5e886
β€’
1 Parent(s): 69e20d0

added more questions

Browse files
database/mock_qna.sqlite CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:66df2080ffb3456c39b4bf554effc49266e957e63792ce12a4f11cb991f369fd
3
- size 20480
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d2a27be7e05ba8545ed59d9f364028d86130cfb2460c74fa71fa16dd3b214e30
3
+ size 40960
database/mock_qna_source.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c80d88333c3b9fb2a700d49113d2ba3fef7cc671c11b640168c389bef411bc05
3
- size 7624
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0794f608da3a328f2d089cdcfa3c69a9e4b9fb60911dd16492de014fd45c4671
3
+ size 25530
notebooks/003_create_mock_qna.ipynb CHANGED
@@ -77,6 +77,16 @@
77
  "qna_data[:3]"
78
  ]
79
  },
 
 
 
 
 
 
 
 
 
 
80
  {
81
  "cell_type": "code",
82
  "execution_count": null,
 
77
  "qna_data[:3]"
78
  ]
79
  },
80
+ {
81
+ "cell_type": "code",
82
+ "execution_count": null,
83
+ "id": "3f804c2a-6f64-4af2-a030-7fac1248835b",
84
+ "metadata": {},
85
+ "outputs": [],
86
+ "source": [
87
+ "qna_data[\"chapter\"].value_counts()"
88
+ ]
89
+ },
90
  {
91
  "cell_type": "code",
92
  "execution_count": null,
raw_documents/qna.txt CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:59cc1b620ccad1393fc4311e91e538774ac76149a42bd2391af7c855895d80bc
3
- size 56746
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da72ca56312ecb78d7cf6c9288b16a520baa2286136b4677cf09f36ee4f07b36
3
+ size 56792
streamlit_app.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  import pandas as pd
6
  import base64
7
  from io import BytesIO
 
8
 
9
  import chromadb
10
  from llama_index.core import (
@@ -28,7 +29,7 @@ import nest_asyncio
28
  nest_asyncio.apply()
29
 
30
  # App title
31
- st.set_page_config(page_title="🐻🍯 Study Bear")
32
  openai_api = os.getenv("OPENAI_API_KEY")
33
 
34
  # "./raw_documents/HI_Knowledge_Base.pdf"
@@ -38,6 +39,7 @@ input_files = ["./raw_documents/HI Chapter Summary Version 1.3.pdf",
38
  embedding_model = "BAAI/bge-small-en-v1.5"
39
  persisted_vector_db = "./models/chroma_db"
40
  fine_tuned_path = "local:models/fine-tuned-embeddings"
 
41
  system_content = (
42
  "You are a helpful study assistant. "
43
  "You do not respond as 'User' or pretend to be 'User'. "
@@ -88,9 +90,10 @@ introduction_line = (
88
  "- Etc ... \n"
89
  " \n"
90
  "For examples, you could ask me \n"
 
91
  "- *How many chapters are there in textbook 'Health Insurance 7th Edition'?* \n"
92
  "- *Can you list all the chapters by name and its number for me?* \n"
93
- "- *Please extract the important key concept from chapter 1 into 10 bullet points* \n"
94
  "- *Please ask me a question so that I can tell if I have enough understanding about Chapter 2* \n"
95
  )
96
 
@@ -158,6 +161,7 @@ if "qna_answer" not in st.session_state:
158
  st.session_state.qna_answer = None
159
 
160
  def clear_chat_history():
 
161
  st.session_state.messages = [{"role": "assistant",
162
  "content": introduction_line,
163
  "type": "text"}]
@@ -169,8 +173,20 @@ def clear_chat_history():
169
  system_content=system_content,
170
  persisted_vector_db=persisted_vector_db)
171
  chat_engine.reset()
 
 
 
 
 
 
 
 
 
 
 
172
 
173
  st.sidebar.button("Clear Chat History", on_click=clear_chat_history)
 
174
  if st.sidebar.button("I want to submit a feedback!"):
175
  st.session_state.feedback = True
176
  st.session_state.feedback_key += 1 # overwrite feedback component
 
5
  import pandas as pd
6
  import base64
7
  from io import BytesIO
8
+ import sqlite3
9
 
10
  import chromadb
11
  from llama_index.core import (
 
29
  nest_asyncio.apply()
30
 
31
  # App title
32
+ st.set_page_config(page_title="πŸ»πŸ“š Study Bear 🍯")
33
  openai_api = os.getenv("OPENAI_API_KEY")
34
 
35
  # "./raw_documents/HI_Knowledge_Base.pdf"
 
39
  embedding_model = "BAAI/bge-small-en-v1.5"
40
  persisted_vector_db = "./models/chroma_db"
41
  fine_tuned_path = "local:models/fine-tuned-embeddings"
42
+ questionaire_db_path = "./database/mock_qna.sqlite"
43
  system_content = (
44
  "You are a helpful study assistant. "
45
  "You do not respond as 'User' or pretend to be 'User'. "
 
90
  "- Etc ... \n"
91
  " \n"
92
  "For examples, you could ask me \n"
93
+ "- *How many modules I have to take to become an insurance agent in Singapore?* \n"
94
  "- *How many chapters are there in textbook 'Health Insurance 7th Edition'?* \n"
95
  "- *Can you list all the chapters by name and its number for me?* \n"
96
+ "- *Please extract the important key concept from chapter 1 - overview of healthcare environment in singapore, into 10 bullet points* \n"
97
  "- *Please ask me a question so that I can tell if I have enough understanding about Chapter 2* \n"
98
  )
99
 
 
161
  st.session_state.qna_answer = None
162
 
163
  def clear_chat_history():
164
+
165
  st.session_state.messages = [{"role": "assistant",
166
  "content": introduction_line,
167
  "type": "text"}]
 
173
  system_content=system_content,
174
  persisted_vector_db=persisted_vector_db)
175
  chat_engine.reset()
176
+ st.toast("yumyum, what was I saying again? πŸ»πŸ’¬", icon="🍯")
177
+
178
+ def clear_question_history():
179
+
180
+ con = sqlite3.connect(questionaire_db_path)
181
+ cur = con.cursor()
182
+ sql_string = "DELETE FROM answer_tbl"
183
+ res = cur.execute(sql_string)
184
+ con.commit()
185
+ con.close()
186
+ st.toast("the tale of one thousand and one questions, reset! 🧨🧨", icon="πŸ“")
187
 
188
  st.sidebar.button("Clear Chat History", on_click=clear_chat_history)
189
+ st.sidebar.button("Clear Question History", on_click=clear_question_history)
190
  if st.sidebar.button("I want to submit a feedback!"):
191
  st.session_state.feedback = True
192
  st.session_state.feedback_key += 1 # overwrite feedback component