Skip to main content

Healthcare inspared LLM prompts

Project description

MEDPrompt

Prompts, tools, chains and agents for healthcare using LLMs & FHIR. ✍️

Libraries.io SourceRank PyPI download total GitHub tag (latest by date)

About

MEDPrompt is a collection of prompts, tools, chains and agents for medical applications using LangChain and space using Agency. MEDPrompt also includes a collection of templates for using FHIR in LLM prompts (see below). The aim of MEDPrompt is to provide a conceptual framework and a set of tools for building healthcare applications using LLMs. Please read my Blog post. User contributions are highly appreciated!

Terminology

An example (Names correspond to the files in the repository)

Agent

Disclaimer:

This repository is not associated with the Medprompt method of prompting. In this generic repository, I will be trying to implement the method using langchain abstractions. Get in touch to share your thoughts via GitHub discussions. Please submit a PR with a link to the official implementation if any.

FHIR2Text -> Convert FHIR resources to plain text

This repository includes templates for converting FHIR resources into a text representation that can be injected into an LLM prompt. Only relevant information is extracted from the resource with simple transformations using helper functions. 🚒See this example usage.

FHIR2Calculator -> Calculate clinical scores from a FHIR Bundle (Work in progress)

Clinical calculators are tools that help healthcare professionals make medical decisions by providing them with quick and easy access to various medical formulas, scores, and algorithms. Calculations performed by LLMs are not reliable. FHIR2Calculator performs calculations on data fields extracted from a FHIR bundle and outputs the results as plain text that can be injected into LLM prompts.

Healthcare tools and chains for LangChain agents

Tools are functions that Langchain agents can use to carry out tasks based on the tool description. Example usage:

from medprompt.tools import FhirPatientSearchTool
tools = [FhirPatientSearchTool()]

Documentation is in progress. Any help will be highly appreciated.

Documentation & List of Templates

Usage

See Examples folder

  1. Observation
  2. FHIR Bundle More documentation and examples to follow..

Install

  • medprompt for the core package
  • embedding for using RAG with HuggingFace transformers
pip install medprompt
pip install medprompt[embedding]

Install Develop branch

pip install git+https://github.com/dermatologist/medprompt.git

OR
after cloning the repository
pip install -e .[embedding]

Import

from medprompt import MedPrompter
prompt = MedPrompter()
prompt.set_template(
    template_name="fhir_search_oai_chat_v1.json")

print(prompt.get_template_variables())

messages = prompt.generate_prompt(
    {"question": "Find Conditions for patient with first name John?"})

print(messages)

Give us a star ⭐️

If you find this project useful, give us a star. It helps others discover the project.

Contributing

Contributers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

medprompt-0.8.0-py3-none-any.whl (25.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page