Spaces:
Runtime error
Runtime error
Yew Chong
commited on
Commit
•
8687f86
1
Parent(s):
e0cfe13
include indexes
Browse files- streamlit/app8.py +42 -9
streamlit/app8.py
CHANGED
@@ -11,6 +11,8 @@ import inspect
|
|
11 |
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
12 |
parentdir = os.path.dirname(currentdir)
|
13 |
sys.path.append(parentdir)
|
|
|
|
|
14 |
|
15 |
## ----------------------------------------------------------------
|
16 |
## LLM Part
|
@@ -52,6 +54,40 @@ os.environ["OPENAI_API_KEY"] = os.environ.get("OPENAI_API_KEY") or st.secrets["O
|
|
52 |
os.environ["FIREBASE_CREDENTIAL"] = os.environ.get("FIREBASE_CREDENTIAL") or st.secrets["FIREBASE_CREDENTIAL"]
|
53 |
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
if "openai_model" not in st.session_state:
|
56 |
st.session_state["openai_model"] = "gpt-3.5-turbo"
|
57 |
|
@@ -61,8 +97,8 @@ if "messages_1" not in st.session_state:
|
|
61 |
if "messages_2" not in st.session_state:
|
62 |
st.session_state.messages_2 = []
|
63 |
|
64 |
-
if "start_time" not in st.session_state:
|
65 |
-
|
66 |
|
67 |
if "active_chat" not in st.session_state:
|
68 |
st.session_state.active_chat = 1
|
@@ -87,7 +123,7 @@ llm_gpt4 = st.session_state.llm_gpt4
|
|
87 |
## ------------------------------------------------------------------------------------------------
|
88 |
## Patient part
|
89 |
|
90 |
-
index_name = "indexes/
|
91 |
|
92 |
if "store" not in st.session_state:
|
93 |
st.session_state.store = db.get_store(index_name, embeddings=embeddings)
|
@@ -158,7 +194,7 @@ sp_mapper = {"human":"student","ai":"patient"}
|
|
158 |
## ------------------------------------------------------------------------------------------------
|
159 |
## ------------------------------------------------------------------------------------------------
|
160 |
## Grader part
|
161 |
-
index_name = "indexes/
|
162 |
|
163 |
# store = FAISS.load_local(index_name, embeddings)
|
164 |
|
@@ -189,7 +225,7 @@ Some additional information that is useful to understand the rubrics:
|
|
189 |
|
190 |
=================================================================
|
191 |
|
192 |
-
|
193 |
Here are the rubrics for grading the student:
|
194 |
<rubrics>
|
195 |
|
@@ -270,8 +306,6 @@ chain2 = st.session_state.chain2
|
|
270 |
# key = os.environ.get("OPENAI_API_KEY")
|
271 |
# client = OpenAI(api_key=key)
|
272 |
|
273 |
-
st.title("UAT for PatientLLM and GraderLLM")
|
274 |
-
st.title("Headache only, for now")
|
275 |
|
276 |
if st.button("Clear History and Memory", type="primary"):
|
277 |
st.session_state.messages_1 = []
|
@@ -398,5 +432,4 @@ if text_prompt:
|
|
398 |
# if st.button("START"):
|
399 |
# count_down(int(time_in_seconds))
|
400 |
# if __name__ == '__main__':
|
401 |
-
# main()
|
402 |
-
|
|
|
11 |
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
12 |
parentdir = os.path.dirname(currentdir)
|
13 |
sys.path.append(parentdir)
|
14 |
+
import db_firestore as db
|
15 |
+
|
16 |
|
17 |
## ----------------------------------------------------------------
|
18 |
## LLM Part
|
|
|
54 |
os.environ["FIREBASE_CREDENTIAL"] = os.environ.get("FIREBASE_CREDENTIAL") or st.secrets["FIREBASE_CREDENTIAL"]
|
55 |
|
56 |
|
57 |
+
|
58 |
+
st.title("UAT for PatientLLM and GraderLLM")
|
59 |
+
|
60 |
+
## Hardcode indexes for now,
|
61 |
+
indexes = """Bleeding
|
62 |
+
ChestPain
|
63 |
+
Dysphagia
|
64 |
+
Headache
|
65 |
+
ShortnessOfBreath
|
66 |
+
Vomiting
|
67 |
+
Warfarin
|
68 |
+
Weakness
|
69 |
+
Weakness2""".split("\n")
|
70 |
+
|
71 |
+
if "selected_index" not in st.session_state:
|
72 |
+
st.session_state.selected_index = 3
|
73 |
+
|
74 |
+
if "index_selectbox" not in st.session_state:
|
75 |
+
st.session_state.index_selectbox = "Headache"
|
76 |
+
|
77 |
+
index_selectbox = st.selectbox("Select index",indexes, index=int(st.session_state.selected_index))
|
78 |
+
|
79 |
+
if index_selectbox != indexes[st.session_state.selected_index]:
|
80 |
+
st.session_state.selected_index = indexes.index(index_selectbox)
|
81 |
+
st.session_state.index_selectbox = index_selectbox
|
82 |
+
del st.session_state["store"]
|
83 |
+
del st.session_state["store2"]
|
84 |
+
del st.session_state["retriever"]
|
85 |
+
del st.session_state["retriever2"]
|
86 |
+
del st.session_state["chain"]
|
87 |
+
del st.session_state["chain2"]
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
if "openai_model" not in st.session_state:
|
92 |
st.session_state["openai_model"] = "gpt-3.5-turbo"
|
93 |
|
|
|
97 |
if "messages_2" not in st.session_state:
|
98 |
st.session_state.messages_2 = []
|
99 |
|
100 |
+
# if "start_time" not in st.session_state:
|
101 |
+
# st.session_state.start_time = None
|
102 |
|
103 |
if "active_chat" not in st.session_state:
|
104 |
st.session_state.active_chat = 1
|
|
|
123 |
## ------------------------------------------------------------------------------------------------
|
124 |
## Patient part
|
125 |
|
126 |
+
index_name = f"indexes/{st.session_state.index_selectbox}/QA"
|
127 |
|
128 |
if "store" not in st.session_state:
|
129 |
st.session_state.store = db.get_store(index_name, embeddings=embeddings)
|
|
|
194 |
## ------------------------------------------------------------------------------------------------
|
195 |
## ------------------------------------------------------------------------------------------------
|
196 |
## Grader part
|
197 |
+
index_name = f"indexes/{st.session_state.index_selectbox}/Rubric"
|
198 |
|
199 |
# store = FAISS.load_local(index_name, embeddings)
|
200 |
|
|
|
225 |
|
226 |
=================================================================
|
227 |
|
228 |
+
e
|
229 |
Here are the rubrics for grading the student:
|
230 |
<rubrics>
|
231 |
|
|
|
306 |
# key = os.environ.get("OPENAI_API_KEY")
|
307 |
# client = OpenAI(api_key=key)
|
308 |
|
|
|
|
|
309 |
|
310 |
if st.button("Clear History and Memory", type="primary"):
|
311 |
st.session_state.messages_1 = []
|
|
|
432 |
# if st.button("START"):
|
433 |
# count_down(int(time_in_seconds))
|
434 |
# if __name__ == '__main__':
|
435 |
+
# main()
|
|