/medprompt

Collection of prompts, tools, chains and agents for healthcare using LLMs and FHIR.

Primary LanguagePythonApache License 2.0Apache-2.0

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. MEDPrompt also includes a collection of templates for using FHIR in LLM prompts (see below). User contributions are highly appreciated!

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.

Usage

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

Install

pip install medprompt

Install Develop branch

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

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