Skip to main content

Semantic data model for LLM-consumable data catalog - shared contract across Nomox services.

Project description

Nomox Semantic Model

The shared knowledge contract between every Nomox service. Describes what data exists (physical layer) and what it means (ontology), and ties the two together so an agent can move from a natural-language concept all the way down to a specific column in a specific table.

Installation

pip install git+https://${GITHUB_TOKEN}@github.com/Nomox-ai/semantics-model.git

Pin to a tag for reproducible installs:

pip install git+https://${GITHUB_TOKEN}@github.com/Nomox-ai/semantics-model.git@v0.1.0

Quickstart

from uuid import uuid4
from nomox_semantics import (
    SemanticCatalog, DataSource, SourceType, Table, Column, ColumnDataType,
    Entity, EntityAttribute, EntityTableMapping, AttributeRole, SemanticType,
)

# 1. Physical layer — what exists in the database
src   = DataSource(slug="prod", name="Prod", source_type=SourceType.POSTGRES)
users = Table(source_id=src.id, schema_name="public", table_name="users")
ltv   = Column(table_id=users.id, source_id=src.id, column_name="ltv_cents",
               ordinal_position=1, data_type=ColumnDataType.BIGINT, raw_data_type="bigint")

# 2. Semantic layer — what the data means in business terms
customer = Entity(
    slug="customer", name="Customer", plural_name="Customers",
    aliases=["user", "account holder"],                      # for natural-language matching
    table_mappings=[EntityTableMapping(table_id=users.id, source_id=src.id)],  # entity -> table
)

# An EntityAttribute binds a business field to a physical column
ltv_attr = EntityAttribute(
    entity_id=customer.id, column_id=ltv.id, source_id=src.id,
    name="lifetime_value", display_name="Lifetime Value",
    role=AttributeRole.MEASURE, default_aggregation="SUM",   # tells the query engine it's aggregatable
    semantic_type=SemanticType.CURRENCY, unit="EUR",         # values are EUR, not raw cents
)

# 3. Assemble the catalog — the root object every Nomox service consumes
catalog = SemanticCatalog(organisation_id=uuid4(), name="Acme")
catalog.sources[src.id] = src
catalog.tables[users.id] = users
catalog.columns[ltv.id] = ltv
catalog.entities[customer.id] = customer
catalog.attributes[ltv_attr.id] = ltv_attr

Documentation

See docs/ for the full design documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nomox_semantics-0.1.0.tar.gz (49.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nomox_semantics-0.1.0-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file nomox_semantics-0.1.0.tar.gz.

File metadata

  • Download URL: nomox_semantics-0.1.0.tar.gz
  • Upload date:
  • Size: 49.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nomox_semantics-0.1.0.tar.gz
Algorithm Hash digest
SHA256 debfb4a3b58e4982791c916a8d20bcd4734e81ab7a87be5a98f7e871912cd14f
MD5 987ca3b2459fad670ca57cde58694b8d
BLAKE2b-256 1d56396cb854cc74ec7bacad4f36df9736b58c5d6504f3a993d18439816b776c

See more details on using hashes here.

Provenance

The following attestation bundles were made for nomox_semantics-0.1.0.tar.gz:

Publisher: publish.yml on Nomox-ai/semantics-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nomox_semantics-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nomox_semantics-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for nomox_semantics-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5df4892004272667618ae03595369cea8a152cf9ca0d9946d72681e74d79602c
MD5 e8030e87aa60021c199d4b760ed9827f
BLAKE2b-256 5404091cefa21b9f24c01540a0f3f7027b738ce5518f838fde17a25ac03708aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for nomox_semantics-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Nomox-ai/semantics-model

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page