Python report parser with a PyO3 Rust helper backend. The Python layer forwards
normalized report text to a configurable LLM API and validates the response with
Pydantic models that mirror the concepts in lx-data-models/STANDARD.md.
from report_parser import LLMConfig, ReportParser
parser = ReportParser(
LLMConfig(
provider="openai-compatible",
base_url="https://api.example.test",
model="your-model",
api_key="...",
)
)
result = parser.parse("Gastroscopy performed. Polyp removed from antrum.")
print(result.summary.narrative)
print(result.model_dump_json(indent=2))To return only a table row with the report name and summarized contents:
row = parser.parse_summary_table_row(
"Gastroscopy performed. Polyp removed from antrum.",
report_name="gastroscopy.txt",
)
print(row.model_dump())
# {"report_name": "gastroscopy.txt", "summarized_contents": "..."}The CLI exposes the same compact shape:
report-parser ./report.txt --tableTo classify each row of a legacy .xls workbook through the remote Ollama
generate API and write a returned workbook with an added yes/no column:
report-parser ~/Desktop/Name.xls \
--raw-prompt \
--transport ssh-curl \
--ssh-host gs-02 \
--base-url http://172.16.255.22:11434 \
--endpoint-path /api/generate \
--model gemma4:e2b \
--skip-header \
--result-column-header lesionThe default output path is ~/Desktop/Name_With_Results.xls. Use
--xls-column A or --xls-column 1 if only one workbook column contains the
report text; otherwise each row is joined into the prompt.
Environment based configuration is available through:
REPORT_PARSER_LLM_PROVIDERREPORT_PARSER_LLM_TRANSPORTREPORT_PARSER_LLM_SSH_HOSTREPORT_PARSER_LLM_BASE_URLREPORT_PARSER_LLM_MODELREPORT_PARSER_LLM_API_KEYREPORT_PARSER_LLM_ENDPOINT_PATH
The default provider shape is Ollama-compatible because the referenced Nix
environment already includes ollama, but both Ollama and OpenAI-compatible
chat completion APIs are supported.
The Rust crate lives in rust/report_parser_rust_backend and exposes:
normalize_report_textextract_report_sectionsreport_text_statsbuild_report_promptextract_json_object
The Python package falls back to pure Python helpers if the extension has not been built yet.