Add map linking file name and link so that users can click the cited article and be taken to a link, when publicly available.

#4
Files changed (1) hide show
  1. knowledge_base.py +108 -0
knowledge_base.py CHANGED
@@ -208,6 +208,98 @@ def source_title(filename):
208
  return f"Document {name}"
209
  return name
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
  # ----------------------------------------------------------------------
213
  # Embedding (Gemini) with batching + disk cache
@@ -331,6 +423,22 @@ class KnowledgeBase:
331
  except Exception:
332
  return False
333
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  # ---- retrieve ----
335
  def retrieve(self, client, query, k=TOP_K, embed_batch=_embed_batch):
336
  if not self.ready:
 
208
  return f"Document {name}"
209
  return name
210
 
211
+ # ----------------------------------------------------------------------
212
+ # Participant-facing source links
213
+ # ----------------------------------------------------------------------
214
+ # Keyed by the exact filename used in the RAG corpus.
215
+ # If a source has a public/participant-accessible URL, add it here.
216
+ # If it does not, leave it out or set it to None; its citation will remain
217
+ # plain text rather than clickable.
218
+
219
+ SOURCE_REGISTRY = {
220
+ "Autologous Stem Cell Transplant for Multiple Myeloma (IMF, 2026).pdf":
221
+ "https://www.myeloma.org/autologous-stem-cell-transplant",
222
+ "Bispecific Therapies for Multiple Myeloma (International Myeloma Foundation, 2026).pdf":
223
+ "https://www.myeloma.org/emerging-therapies/bispecific-therapies",
224
+ "Blood Protein Tests for Multiple Myeloma (IMF, 2025).pdf":
225
+ "https://www.myeloma.org/blood-protein-testing",
226
+ "Bone Marrow Tests for Multiple Myeloma (IMF, 2025).pdf":
227
+ "https://www.myeloma.org/bone-marrow-tests",
228
+ "CAR T-Cell Therapy for Multiple Myeloma (International Myeloma Foundation, 2024).pdf":
229
+ "https://www.myeloma.org/emerging-therapies/car-t-cell-therapy",
230
+ "Comprehensive Molecular Profiling of Multiple Myeloma by African and European Ancestry (Manojlovic et al., 2017).pdf":
231
+ "https://journals.plos.org/plosgenetics/article?id=10.1371/journal.pgen.1007087",
232
+ "Durie-Salmon Staging for Multiple Myeloma (IMF, 2026).pdf":
233
+ "https://www.myeloma.org/durie-salmon-staging",
234
+ "FDA Approval of Teclistamab Plus Daratumumab for Relapsed Multiple Myeloma (2026).pdf":
235
+ "https://www.fda.gov/drugs/resources-information-approved-drugs/fda-approves-teclistamab-combination-daratumumab-hyaluronidase-fihj-relapsed-or-refractory-multiple",
236
+ "First-Line Treatment for Multiple Myeloma (IMF, 2026).pdf":
237
+ "https://www.myeloma.org/frontline-treatment-options",
238
+ "Genetic Heterogeneity and Drug Resistance in Relapsed Multiple Myeloma (Vo et al., 2022).pdf":
239
+ "https://www.nature.com/articles/s41467-022-31430-0",
240
+ "Genetic Heterogeneity in Multiple Myeloma and Targeted Therapy (Lohr et al., 2014).pdf":
241
+ "https://www.cell.com/cancer-cell/fulltext/S1535-6108(13)00542-4?_returnURL=https%3A%2F%2Flinkinghub.elsevier.com%2Fretrieve%2Fpii%2FS1535610813005424%3Fshowall%3Dtrue",
242
+ "Immunocytokine Therapy for Multiple Myeloma (International Myeloma Foundation, 2026).pdf":
243
+ "https://www.myeloma.org/emerging-therapies/immunocytokine-therapy",
244
+ "Initial Genome Sequencing of Multiple Myeloma (Chapman et al., 2011).pdf":
245
+ "https://www.nature.com/articles/nature09837",
246
+ "ISS and R-ISS Staging for Multiple Myeloma (IMF, 2026).pdf":
247
+ "https://www.myeloma.org/international-staging-system-iss-reivised-iss-r-iss",
248
+ "Kidney Function Tests for Multiple Myeloma (IMF, 2025).pdf":
249
+ "https://www.myeloma.org/myeloma-kidney-tests",
250
+ "M-Protein Tests for Multiple Myeloma (IMF, 2026).pdf":
251
+ "https://www.myeloma.org/monoclonal-protein-tests",
252
+ "Maintenance Therapy for Multiple Myeloma (IMF, 2024).pdf":
253
+ "https://www.myeloma.org/maintenance-therapy",
254
+ "Mayo Clinic mSMART Relapsed Myeloma Treatment Guidelines, Version 9 (2026).pdf":
255
+ "https://static1.squarespace.com/static/5b44f08ac258b493a25098a3/t/69b45653e3e1365b6857a106/1773426259531/03_13_26_v9+Relapsed+MM+mSMART%2BRelapsedMM.pdf",
256
+ "MGUS, Smoldering Myeloma, and Active Myeloma (IMF, 2026).pdf":
257
+ "https://www.myeloma.org/what-are-mgus-smm-mm",
258
+ "Minimal Residual Disease in Multiple Myeloma (IMF).pdf":
259
+ "https://www.myeloma.org/videos/minimal-residual-disease-mrd",
260
+ "Multiple Myeloma Autologous Stem Cell Transplantation Patient Toolkit (MMRF, 2026).pdf":
261
+ "https://themmrf.org/wp-content/uploads/2026/03/Autologous-Stem-Cell-Transplantation-patient_toolkit-2026.pdf",
262
+ "Multiple Myeloma Blood Tests (IMF, 2026).pdf":
263
+ "https://www.myeloma.org/multiple-myeloma-blood-tests",
264
+ "Multiple Myeloma Complications (IMF, 2025).pdf":
265
+ "https://www.myeloma.org/medical-conditions",
266
+ "Multiple Myeloma Diagnosis and Treatment (Mayo Clinic, 2024).pdf":
267
+ "https://www.mayoclinic.org/diseases-conditions/multiple-myeloma/diagnosis-treatment/drc-20353383",
268
+ "Multiple Myeloma FAQ (IMF, 2026).pdf":
269
+ "https://www.myeloma.org/myeloma-cancer-questions",
270
+ "Multiple Myeloma Imaging Studies (IMF, 2025).pdf":
271
+ "https://www.myeloma.org/multiple-myeloma-imaging-studies",
272
+ "Multiple Myeloma Immunotherapy Patient Toolkit (MMRF, 2026).pdf":
273
+ "https://themmrf.org/wp-content/uploads/2026/03/Immunotherapy-patient_toolkit-2026.pdf",
274
+ "Multiple Myeloma Overview (IMF, 2026).pdf":
275
+ "https://www.myeloma.org/what-is-multiple-myeloma",
276
+ "Multiple Myeloma Relapse (IMF, 2025).pdf":
277
+ "https://www.myeloma.org/treatment/relapse-definition",
278
+ "Multiple Myeloma Signs and Diagnosis (IMF, 2025).pdf":
279
+ "https://www.myeloma.org/newly-diagnosed/do-you-have-myeloma",
280
+ "Multiple Myeloma Staging and Risk Stratification (IMF, 2019).pdf":
281
+ "https://www.myeloma.org/multiple-myeloma/multiple-myeloma-prognosis-staging",
282
+ "Multiple Myeloma Testing (IMF, 2026).pdf":
283
+ "https://www.myeloma.org/multiple-myeloma-tests",
284
+ "Multiple Myeloma Testing, Staging and Prognosis (IMF, 2025).pdf":
285
+ "https://www.myeloma.org/tests-staging",
286
+ "NCCN Multiple Myeloma Patient Guidelines (2026).pdf":
287
+ "https://www.nccn.org/patients/guidelines/content/PDF/myeloma-patient.pdf",
288
+ "Perspectives on the Risk-Stratified Treatment of Multiple Myeloma (Davies et al., 2022).pdf":
289
+ "https://pmc.ncbi.nlm.nih.gov/articles/PMC9894570/",
290
+ "Quality of Life in Longitudinal Multiple Myeloma Studies (Nielsen et al., 2017).pdf":
291
+ "https://onlinelibrary.wiley.com/doi/10.1111/ejh.12882",
292
+ "Quality of Life in Multiple Myeloma Treatment (Sonneveld et al., 2013).pdf":
293
+ "https://www.nature.com/articles/leu2013185",
294
+ "Questions to Ask Your Myeloma Doctor (IMF).pdf":
295
+ "https://www.myeloma.org/resource-library/tip-card-ask-your-doctor",
296
+ "Routine Health Screenings for Myeloma Patients (IMF, 2021).pdf":
297
+ "https://www.myeloma.org/health-screenings",
298
+ "The Role of Minimal Residual Disease Testing in Myeloma Treatment Selection and Drug Development (Anderson et al., 2017).pdf":
299
+ "https://aacrjournals.org/clincancerres/article/23/15/3980/257045/The-Role-of-Minimal-Residual-Disease-Testing-in",
300
+ "Types of Multiple Myeloma (IMF, 2025).pdf":
301
+ "https://www.myeloma.org/types-of-myeloma",
302
+ }
303
 
304
  # ----------------------------------------------------------------------
305
  # Embedding (Gemini) with batching + disk cache
 
423
  except Exception:
424
  return False
425
 
426
+ def source_link_map(self):
427
+ """
428
+ Map the human-readable document titles used in chatbot citations
429
+ to participant-accessible URLs.
430
+
431
+ Sources without a URL remain plain-text citations.
432
+ """
433
+ links = {}
434
+
435
+ for source in self.sources:
436
+ url = SOURCE_REGISTRY.get(source)
437
+ if url:
438
+ links[source_title(source)] = url
439
+
440
+ return links
441
+
442
  # ---- retrieve ----
443
  def retrieve(self, client, query, k=TOP_K, embed_batch=_embed_batch):
444
  if not self.ready: