JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
about 2 months ago1 views
👨‍💻Programming
known_diseases = list({rec["disease"] for rec in records})

def detect_disease(question, diseases):
    q_lower = question.lower()
    for d in diseases:
        if d.lower() in q_lower:
            return d
    return None

question = "What is the recommended treatment pathway for Hypertension and when should a specialist be involved?"
target_disease = detect_disease(question, known_diseases)

if target_disease:
    retriever = knowledge_base.as_retriever(
        search_kwargs={"k": 6, "filter": {"disease": target_disease}}
    )
else:
    retriever = knowledge_base.as_retriever(search_kwargs={"k": 6})

qa_chain = RetrievalQA.from_chain_type(
    llm,
    retriever=retriever,
    chain_type_kwargs={"prompt": clinical_prompt},
    return_source_documents=True
)
← Back to timeline