Skip to main content

varga

Two questions about one document. guess_type answers the first from cue phrases and countable evidence, with no model unless two kinds tie. as_schema and structured answer the second against a shape you name or invent.

Install

uv add varga            # doctypes; no model, no network
uv add varga rishi      # ...and a chat for `structured` to ask

There are no extras: structured imports what it needs when it is called.

What is it

INVOICE = '''# INVOICE
Invoice No: ACM-2024-0117
Date: 2024-03-01
Bill to: Contoso GmbH, Berlin
From: Acme Supplies Ltd
Total due: 1,240.00 EUR
Payment terms: net 30
'''
r = guess_type(INVOICE)
r.doctype, r.decisive, round(r.margin, 2)
('invoice', True, 0.4)

decisive is the whole point: it says whether the cues settled it. When two kinds tie, margin is 0 and a caller knows to spend a model call. Nothing else here costs one.

signals(INVOICE).counts
{'money': 1, 'date': 1, 'ref': 1, 'heading': 1, 'org': 2}

What is in it

from dataclasses import fields
[f.name for f in fields(as_schema('invoice'))]
['number',
 'date',
 'due_date',
 'vendor',
 'vendor_tax_id',
 'bill_to',
 'ship_to',
 'currency',
 'subtotal',
 'tax',
 'total',
 'payment_terms',
 'items']

Fifteen shapes are built in: invoice, purchase_order, quote, receipt, catalogue, contract, resume, paper, meeting_notes, id_card, passport, bank_statement, payslip, tax_return, other. Or write one on the spot:

[(f.name, f.type.__name__) for f in fields(as_schema('vendor:str, total:float, items:list'))]
[('vendor', 'str'), ('total', 'float'), ('items', 'list')]

structured(chat, prompt, schema) fills it. It prefers the model’s constrained mode and falls back to a JSON reply when that raises, so a model without tool calling still answers.

structured(..., cite=True) returns {field: {value, quote}}, the quote copied from the document, and locate(fields, pages) turns each quote into the page and block it came from with a string match, not a model.

The doctypes

len(DOCTYPES), sorted(DOCTYPES)

Ten of them are work-product labels: proposal, presentation, requirements_spec, technical_design, regulatory_guidance, procedure, qa_artifact, roadmap, claim, clinical_record, and each is decisive on its own text without a model. Prose that merely borrows the vocabulary scores under 0.2 against every one of them.

Six are sensitive: id_card, passport, bank_statement, payslip, tax_return and clinical_record. They are in SENSITIVE, and guess_type(...).sensitive says when the answer is one of them, so a caller can keep that document on the machine.

What it depends on

fastcore and rahasya, for the honorific-anchored name regex the entity leg shares with the privacy gate. One definition of what a name is.

rishi is needed only by structured, for the chat it is handed and the JSON fallback.

Development

The notebooks in nbs/ are the source; the modules are generated.

pip install -e .
nbdev_prepare

Metadata

Release files for varga 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for varga 0.0.6
File Size Uploaded Provenance Actions
varga-0.0.6.tar.gz 22.4 kB Without provenance Details for varga-0.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for varga 0.0.6
File Interpreter ABI Platform Actions
varga-0.0.6-py3-none-any.whl Python 3 none any Details for varga-0.0.6-py3-none-any.whl

Total release size: 45.7 kB

Release files / varga-0.0.6.tar.gz

Download URL varga-0.0.6.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
340b1b5d484fe7529f8d21d410b2d4e4997fb057dab24aeebd0eaa22d7f85b09
BLAKE2b-256 checksum
How to use checksums
a277bf9a11cbae960bc836df3c33fddedd2c1f7150ff0bd700096005c3f36ede
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / varga-0.0.6-py3-none-any.whl

Download URL varga-0.0.6-py3-none-any.whl
Size 23.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd7ec002fbdeb237f6948aee65ff1946ae4cb9ef866e91903bd2d3d17b4fb006
BLAKE2b-256 checksum
How to use checksums
c4c8da0c206288ee9ae1ad13fcfe269ffceadafe151e828a5748ba22d102b9ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for varga 0.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page