Skip to main content
Loading navigation

Define LangGraph State Machine for Trial Matching

Prompt source

implementation16 lines5 sectionsNo variables0 checklist items
from typing import TypedDict, List
from langgraph.graph import StateGraph, END
from langchain_openai import ChatOpenAI

class TrialState(TypedDict):
    patient_data: dict
    extracted_biomarkers: dict
    is_eligible: bool
    reasoning: List[str]

workflow = StateGraph(TrialState)

# Define nodes for extraction, verification, and decision
def extract_biomarkers(state: TrialState):
    # Extract hsCRP and IL-6
    return state

workflow.add_node('extract', extract_biomarkers)
workflow.set_entry_point('extract')
# Complete state graph routing