@linhnt/Flower-Seed

0
0
flwr new @linhnt/Flower-Seed

Flower Seed

FLOWER SEED is a federated AI Agent App, improving post-operative outcomes for cataract surgery through federated insights across multiple facilities, without sharing patient records.

Cataract surgery is the most commonly performed operation in the UK, and the data on what goes wrong afterwards sits in separate hospital systems that cannot be pooled. FlowerSeed runs a Flower federation across five sites covering 2,950 synthetic patient episodes. Each site keeps its records in place and uses RAG to retrieve local evidence for the agent, so only model updates ever leave the building. Every hospital gets a view of complication risk that none of them could build alone.

This aligns with the NHS 10 Year Health Plan and its shifts from analogue to digital and from sickness to prevention. Spotting risk factors before surgery means fewer avoidable follow-ups and better sight outcomes for patients.

Implementation and workflow

Please refer to this Github repository for full details: FlowerSeed

Flower AgentApp

This AgentApp uses the OpenAI SDK to send the configured agent.input through Flower Runtime. It republishes every streamed response event to the frontend and prints the final response text.

Flower Runtime supplies the SDK base URL and task token, so the AgentApp does not need provider credentials.

Bundled datasets and structured retrieval

The agent answers questions about four bundled synthetic cataract-surgery datasets through structured retrieval, not vector RAG: deterministic, typed tools compute exact counts and rates directly from the data files, so there is no embedding index, no similarity search, and no model-generated SQL or Python.

HospitalFileRowsComplication rate
H1 Moorfields Eye Hospital (London, UK)data/H1_moorfields_eye_hospital.json45023.33%
H2 Manchester Royal Eye Hospital (Manchester, UK)data/H2_manchester_royal_eye_hospital.json40029.75%
H3 Aberdeen Royal Infirmary (Aberdeen, UK)data/H3_aberdeen_royal_infirmary_eye_outpatient_department.json30028.33%
SAUH St. Aldgate's University Hospitaldata/sauh_cataract_synthetic_1.json12008.92%

Flower's FAB format v1 only bundles py/toml/md/yaml/json/jsonl files, and flwr app publish caps uploads at roughly 1 MiB, so the agent loads columnar JSON copies of the source CSVs produced by data/convert_to_json.py (rerun it after regenerating the CSVs). Each file holds constants (columns that never vary), columns, and rows of values; the encoding is lossless and values are restored to their original strings at load time.

H1–H3 share one schema. SAUH uses its own 36-column schema; at load time its values are mapped onto the shared vocabulary where the mapping is unambiguous (sex, surgery type, IOL type, diabetes/hypertension/glaucoma/uveitis/prior surgery flags, postop complication type, first surgery date; "any complication" = intraop or postop). Fields SAUH does not have (smoking status, ASA grade, comorbidities, complication severity, anaesthesia subtype, surgeon grade) are never guessed: a cohort query filtering on them excludes SAUH and reports it under hospitals_excluded. data/metadata.json currently describes only H1–H3, so the dataset file contents are treated as the source of truth.

The local tools (defined in agent/data_tools.py):

  • describe_datasets — data dictionary: which hospitals, fields, intraoperative/postoperative complication conditions, and cohort filters exist.
  • list_hospital_summaries — patient counts, surgery-date ranges, and complication counts/rates per hospital.
  • query_cohort — aggregate counts, complication rate, severity distribution, and optional grouped results for a filtered cohort. Supported filters: hospitals, age range, sex, smoking status, ASA grades, comorbidities, clinical 0/1 flags, surgery type, anaesthesia type, surgeon grade, IOL type, and complication severity. Never returns patient rows.
  • get_patient — exactly one synthetic record by patient ID (e.g. H1-0001, SAUH-00001). SAUH records include their native fields (ethnicity, IMD quintile, endothelial cell density, etc.); these are returned by patient lookup but are not all cohort filters yet.

In addition to the tools, a compact dataset briefing (hospital counts, complication rates, and the full field/condition inventory, computed deterministically at run start) is injected into the model's instructions on every call, so the model understands the knowledge-base context before answering or choosing tools; the tools then supply exact numbers.

Web connectors (web_search, web_fetch) remain available for external background knowledge, which the agent may combine with dataset results as long as exact counts and rates come from the local tools.

Example prompts:

Compare complication rates across the four hospitals.
What is the complication rate for diabetic patients over 70 at H1 and SAUH?
Show me patient SAUH-00001.

All records are synthetic and must never be treated as medical advice or real hospital evidence.

Build

Install the project and build its Flower App Bundle (FAB):

uv sync
uv run flwr build

Customize and run

Edit agent/agent_app.py to change the model or add your agent logic. Then log in and run the app on SuperGrid:

uv run flwr login supergrid
uv run flwr run . supergrid --stream

Override the default input for a run with:

uv run flwr run . supergrid \
  --run-config 'agent.input="Explain agent harness in one paragraph."' \
  --stream

Learn more

See the Flower Agent documentation for more tutorials and guides.