Installation

Install the screen template by running the following command:

npx shadcn add https://registry.samplehc.com/r/legacy-document-reasoning.json

The screen file will be added at screens/legacy-document-reasoning-screen.tsx.

Usage

Required Props

NameTypeDescription
resultIdstringThe async result ID returned from a document reasoning API call

Example

workflow.py
from workflows_py.workflow import ScreenStep, Step, Workflow
from client_manager import SampleHealthcareClient

workflow = Workflow(...)

def reason_document(ctx):
    client = SampleHealthcareClient()
    document = ctx.get_step_result("document-upload")["document"]
    response = client.v2.documents.legacy.reason(
        documents=[{"id": document["id"], "fileName": document["fileName"]}],
        task={
            "id": "reasoning-task-1",
            "description": "Extract key medical information from the document",
            "label": "Medical Information Extraction",
            "type": "reasoning"
        }
    )
    return response.async_result_id

workflow.then(
  # See: Document Upload Screen template
  ScreenStep( 
    "document-upload",
    screen_path="./screens/document-upload-screen.tsx",
  )
).then(
  Step(
    "reason-document",
    reason_document,
  )
)
.then(
    ScreenStep(
        "document-reasoning",
        screen_path="./screens/legacy-document-reasoning-screen.tsx",
        get_props=lambda ctx: {"resultId": ctx.get_step_result("reason-document")},
    )
)

Returns

The screen returns comprehensive information about the reasoning tasks and their answers:

NameTypeDescription
tasksarrayArray of task objects that were processed
initial_answersarrayArray of initial answers generated by the AI for each task
initial_answers[].answerobjectRich text content of the initial AI-generated answer
final_answersarrayArray of final answers after user review and editing
final_answers[].answerobjectRich text content of the final user-reviewed answer

Preview