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")},
)
)