Spaces:
Running
Running
bot
Browse files- __pycache__/config.cpython-311.pyc +0 -0
- app.py +30 -43
- rag/__pycache__/rag_pipeline.cpython-311.pyc +0 -0
- utils/__pycache__/prompts.cpython-311.pyc +0 -0
- utils/prompts.py +0 -31
__pycache__/config.cpython-311.pyc
CHANGED
Binary files a/__pycache__/config.cpython-311.pyc and b/__pycache__/config.cpython-311.pyc differ
|
|
app.py
CHANGED
@@ -1,11 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
from rag.rag_pipeline import RAGPipeline
|
4 |
-
from utils.prompts import highlight_prompt, evidence_based_prompt
|
5 |
-
from utils.prompts import (
|
6 |
-
sample_questions,
|
7 |
-
)
|
8 |
-
|
9 |
from config import STUDY_FILES
|
10 |
|
11 |
# Cache for RAG pipelines
|
@@ -22,7 +18,7 @@ def get_rag_pipeline(study_name):
|
|
22 |
return rag_cache[study_name]
|
23 |
|
24 |
|
25 |
-
def
|
26 |
rag = get_rag_pipeline(study_name)
|
27 |
|
28 |
if prompt_type == "Highlight":
|
@@ -32,9 +28,7 @@ def query_rag(study_name: str, question: str, prompt_type: str) -> str:
|
|
32 |
else:
|
33 |
prompt = None
|
34 |
|
35 |
-
|
36 |
-
response = rag.query(question, prompt_template=prompt)
|
37 |
-
|
38 |
return response.response
|
39 |
|
40 |
|
@@ -48,55 +42,48 @@ def get_study_info(study_name):
|
|
48 |
return "Invalid study name"
|
49 |
|
50 |
|
51 |
-
def update_sample_questions(study_name):
|
52 |
-
return gr.Dropdown(choices=sample_questions.get(study_name, []), interactive=True)
|
53 |
-
|
54 |
-
|
55 |
with gr.Blocks() as demo:
|
56 |
gr.Markdown("# RAG Pipeline Demo")
|
57 |
|
58 |
with gr.Row():
|
59 |
study_dropdown = gr.Dropdown(
|
60 |
-
choices=list(STUDY_FILES.keys()),
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
study_dropdown.change(get_study_info, inputs=[study_dropdown], outputs=[study_info])
|
65 |
-
|
66 |
-
with gr.Row():
|
67 |
-
question_input = gr.Textbox(label="Enter your question")
|
68 |
-
sample_question_dropdown = gr.Dropdown(
|
69 |
-
choices=[], label="Sample Questions", interactive=True
|
70 |
)
|
71 |
-
|
72 |
-
study_dropdown.change(
|
73 |
-
update_sample_questions,
|
74 |
-
inputs=[study_dropdown],
|
75 |
-
outputs=[sample_question_dropdown],
|
76 |
-
)
|
77 |
-
sample_question_dropdown.change(
|
78 |
-
lambda x: x, inputs=[sample_question_dropdown], outputs=[question_input]
|
79 |
-
)
|
80 |
|
81 |
prompt_type = gr.Radio(
|
82 |
-
[
|
83 |
-
"Default",
|
84 |
-
"Highlight",
|
85 |
-
"Evidence-based",
|
86 |
-
],
|
87 |
label="Prompt Type",
|
88 |
value="Default",
|
89 |
)
|
90 |
|
91 |
-
|
|
|
|
|
92 |
|
93 |
-
|
|
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
99 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
if __name__ == "__main__":
|
102 |
demo.launch(share=True, debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
import json
|
3 |
from rag.rag_pipeline import RAGPipeline
|
4 |
+
from utils.prompts import highlight_prompt, evidence_based_prompt, sample_questions
|
|
|
|
|
|
|
|
|
5 |
from config import STUDY_FILES
|
6 |
|
7 |
# Cache for RAG pipelines
|
|
|
18 |
return rag_cache[study_name]
|
19 |
|
20 |
|
21 |
+
def chat_function(message, history, study_name, prompt_type):
|
22 |
rag = get_rag_pipeline(study_name)
|
23 |
|
24 |
if prompt_type == "Highlight":
|
|
|
28 |
else:
|
29 |
prompt = None
|
30 |
|
31 |
+
response = rag.query(message, prompt_template=prompt)
|
|
|
|
|
32 |
return response.response
|
33 |
|
34 |
|
|
|
42 |
return "Invalid study name"
|
43 |
|
44 |
|
|
|
|
|
|
|
|
|
45 |
with gr.Blocks() as demo:
|
46 |
gr.Markdown("# RAG Pipeline Demo")
|
47 |
|
48 |
with gr.Row():
|
49 |
study_dropdown = gr.Dropdown(
|
50 |
+
choices=list(STUDY_FILES.keys()),
|
51 |
+
label="Select Study",
|
52 |
+
value=list(STUDY_FILES.keys())[0],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
)
|
54 |
+
study_info = gr.Markdown()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
prompt_type = gr.Radio(
|
57 |
+
["Default", "Highlight", "Evidence-based"],
|
|
|
|
|
|
|
|
|
58 |
label="Prompt Type",
|
59 |
value="Default",
|
60 |
)
|
61 |
|
62 |
+
chatbot = gr.Chatbot()
|
63 |
+
msg = gr.Textbox()
|
64 |
+
clear = gr.Button("Clear")
|
65 |
|
66 |
+
def user(user_message, history):
|
67 |
+
return "", history + [[user_message, None]]
|
68 |
|
69 |
+
def bot(history, study_name, prompt_type):
|
70 |
+
user_message = history[-1][0]
|
71 |
+
bot_message = chat_function(user_message, history, study_name, prompt_type)
|
72 |
+
history[-1][1] = bot_message
|
73 |
+
return history
|
74 |
+
|
75 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
76 |
+
bot, [chatbot, study_dropdown, prompt_type], chatbot
|
77 |
)
|
78 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
79 |
+
|
80 |
+
study_dropdown.change(
|
81 |
+
fn=get_study_info,
|
82 |
+
inputs=study_dropdown,
|
83 |
+
outputs=study_info,
|
84 |
+
).then(lambda: None, None, chatbot, queue=False)
|
85 |
+
|
86 |
+
gr.Examples(examples=sample_questions[list(STUDY_FILES.keys())[0]], inputs=msg)
|
87 |
|
88 |
if __name__ == "__main__":
|
89 |
demo.launch(share=True, debug=True)
|
rag/__pycache__/rag_pipeline.cpython-311.pyc
CHANGED
Binary files a/rag/__pycache__/rag_pipeline.cpython-311.pyc and b/rag/__pycache__/rag_pipeline.cpython-311.pyc differ
|
|
utils/__pycache__/prompts.cpython-311.pyc
CHANGED
Binary files a/utils/__pycache__/prompts.cpython-311.pyc and b/utils/__pycache__/prompts.cpython-311.pyc differ
|
|
utils/prompts.py
CHANGED
@@ -73,16 +73,6 @@ vaccine_coverage_prompt = PromptTemplate(
|
|
73 |
sample_questions = {
|
74 |
"Vaccine Coverage": [
|
75 |
"What are the vaccine coverage rates reported in the study?",
|
76 |
-
"What proportion of vaccines were administered within the recommended age range?",
|
77 |
-
"What is the immunisation uptake reported in the study?",
|
78 |
-
"What are the vaccine drop-out rates mentioned in the document?",
|
79 |
-
"What are the intentions to vaccinate reported in the study?",
|
80 |
-
"How is vaccine confidence described in the document?",
|
81 |
-
"What factors influencing vaccine hesitancy are identified in the study?",
|
82 |
-
"Are there any demographic differences in vaccine coverage or uptake?",
|
83 |
-
"What interventions, if any, were implemented to improve vaccine coverage?",
|
84 |
-
"How does the study address equity in vaccine distribution and access?",
|
85 |
-
"What is the geographical scope of the study (e.g., urban, rural, national)?",
|
86 |
"Are there any reported adverse events following immunization (AEFI)?",
|
87 |
"How does the study account for different vaccine types or schedules?",
|
88 |
"Extract and present in a tabular format the following variables for each vaccine coverage study: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, IMMUNISABLE_DISEASE_UNDER_STUDY, ROUTE_OF_VACCINE_ADMINISTRATION, DURATION_OF_STUDY, DURATION_IN_RELATION_TO_COVID19, VACCINE_COVERAGE_RATES, PROPORTION_ADMINISTERED_WITHIN_RECOMMENDED_AGE, IMMUNISATION_UPTAKE, VACCINE_DROP_OUT_RATES, INTENTIONS_TO_VACCINATE, VACCINE_CONFIDENCE, HESITANCY_FACTORS, DEMOGRAPHIC_DIFFERENCES, INTERVENTIONS, EQUITY_CONSIDERATIONS, GEOGRAPHICAL_SCOPE, AEFI, VACCINE_TYPES, and STUDY_COMMENTS.",
|
@@ -90,16 +80,6 @@ sample_questions = {
|
|
90 |
"Ebola Virus": [
|
91 |
"What is the sample size of the study?",
|
92 |
"What is the type of plasma used in the study?",
|
93 |
-
"What is the dosage and frequency of administration of the plasma?",
|
94 |
-
"Are there any reported side effects?",
|
95 |
-
"What is the change in viral load after treatment?",
|
96 |
-
"How many survivors were there in the intervention group compared to the control group?",
|
97 |
-
"What was the study design (e.g., RCT, observational)?",
|
98 |
-
"What were the inclusion and exclusion criteria for participants?",
|
99 |
-
"Were there any subgroup analyses performed?",
|
100 |
-
"What was the duration of follow-up?",
|
101 |
-
"Were there any reported long-term outcomes or sequelae?",
|
102 |
-
"How was the severity of Ebola virus disease assessed?",
|
103 |
"What biosafety measures were implemented during the study?",
|
104 |
"Were there any ethical considerations or challenges reported?",
|
105 |
"Create a structured table for each Ebola virus study, including the following information: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, SAMPLE_SIZE, PLASMA_TYPE, DOSAGE, FREQUENCY, SIDE_EFFECTS, VIRAL_LOAD_CHANGE, SURVIVAL_RATE, INCLUSION_CRITERIA, EXCLUSION_CRITERIA, SUBGROUP_ANALYSES, FOLLOW_UP_DURATION, LONG_TERM_OUTCOMES, DISEASE_SEVERITY_ASSESSMENT, BIOSAFETY_MEASURES, ETHICAL_CONSIDERATIONS, and STUDY_COMMENTS.",
|
@@ -108,17 +88,6 @@ sample_questions = {
|
|
108 |
"What is the main objective of the study?",
|
109 |
"What is the study design?",
|
110 |
"What disease condition is being studied?",
|
111 |
-
"What are the main outcome measures in the study?",
|
112 |
-
"What is the sensitivity and specificity of the Gene Xpert test?",
|
113 |
-
"How does the cost of the Gene Xpert testing strategy compare to other methods?",
|
114 |
-
"What is the turnaround time for Gene Xpert results compared to conventional methods?",
|
115 |
-
"Are there any reported challenges in implementing Gene Xpert in the study setting?",
|
116 |
-
"How does Gene Xpert performance vary across different sample types or patient populations?",
|
117 |
-
"What quality control measures were implemented in the study?",
|
118 |
-
"Were there any reported equipment failures or technical issues?",
|
119 |
-
"How does the study address the impact of Gene Xpert on patient outcomes or clinical decision-making?",
|
120 |
-
"What training or human resource requirements were reported for Gene Xpert implementation?",
|
121 |
-
"How does the study consider the scalability and sustainability of Gene Xpert use?",
|
122 |
"Extract and present in a tabular format the following variables for each Gene Xpert study: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, DISEASE_CONDITION, OBJECTIVE, OUTCOME_MEASURES, SENSITIVITY, SPECIFICITY, COST_COMPARISON, TURNAROUND_TIME, IMPLEMENTATION_CHALLENGES, PERFORMANCE_VARIATIONS, QUALITY_CONTROL, EQUIPMENT_ISSUES, PATIENT_OUTCOME_IMPACT, TRAINING_REQUIREMENTS, SCALABILITY_CONSIDERATIONS, and STUDY_COMMENTS.",
|
123 |
],
|
124 |
}
|
|
|
73 |
sample_questions = {
|
74 |
"Vaccine Coverage": [
|
75 |
"What are the vaccine coverage rates reported in the study?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
"Are there any reported adverse events following immunization (AEFI)?",
|
77 |
"How does the study account for different vaccine types or schedules?",
|
78 |
"Extract and present in a tabular format the following variables for each vaccine coverage study: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, IMMUNISABLE_DISEASE_UNDER_STUDY, ROUTE_OF_VACCINE_ADMINISTRATION, DURATION_OF_STUDY, DURATION_IN_RELATION_TO_COVID19, VACCINE_COVERAGE_RATES, PROPORTION_ADMINISTERED_WITHIN_RECOMMENDED_AGE, IMMUNISATION_UPTAKE, VACCINE_DROP_OUT_RATES, INTENTIONS_TO_VACCINATE, VACCINE_CONFIDENCE, HESITANCY_FACTORS, DEMOGRAPHIC_DIFFERENCES, INTERVENTIONS, EQUITY_CONSIDERATIONS, GEOGRAPHICAL_SCOPE, AEFI, VACCINE_TYPES, and STUDY_COMMENTS.",
|
|
|
80 |
"Ebola Virus": [
|
81 |
"What is the sample size of the study?",
|
82 |
"What is the type of plasma used in the study?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
"What biosafety measures were implemented during the study?",
|
84 |
"Were there any ethical considerations or challenges reported?",
|
85 |
"Create a structured table for each Ebola virus study, including the following information: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, SAMPLE_SIZE, PLASMA_TYPE, DOSAGE, FREQUENCY, SIDE_EFFECTS, VIRAL_LOAD_CHANGE, SURVIVAL_RATE, INCLUSION_CRITERIA, EXCLUSION_CRITERIA, SUBGROUP_ANALYSES, FOLLOW_UP_DURATION, LONG_TERM_OUTCOMES, DISEASE_SEVERITY_ASSESSMENT, BIOSAFETY_MEASURES, ETHICAL_CONSIDERATIONS, and STUDY_COMMENTS.",
|
|
|
88 |
"What is the main objective of the study?",
|
89 |
"What is the study design?",
|
90 |
"What disease condition is being studied?",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
"Extract and present in a tabular format the following variables for each Gene Xpert study: STUDYID, AUTHOR, YEAR, TITLE, PUBLICATION_TYPE, STUDY_DESIGN, STUDY_AREA_REGION, STUDY_POPULATION, DISEASE_CONDITION, OBJECTIVE, OUTCOME_MEASURES, SENSITIVITY, SPECIFICITY, COST_COMPARISON, TURNAROUND_TIME, IMPLEMENTATION_CHALLENGES, PERFORMANCE_VARIATIONS, QUALITY_CONTROL, EQUIPMENT_ISSUES, PATIENT_OUTCOME_IMPACT, TRAINING_REQUIREMENTS, SCALABILITY_CONSIDERATIONS, and STUDY_COMMENTS.",
|
92 |
],
|
93 |
}
|