# NVIDIA Auto Ontology

Ask questions through an NVIDIA Auto Ontology semantic layer, look up business terms, ground NL-to-SQL, and give agents governed business data.

Source: https://glamorous-boar.cloudvent.net/auto-ontology/

---

[NVIDIA Auto Ontology](https://github.com/NVIDIA/auto-ontology) (Apache-2.0) ingests a source database, compiles a **semantic layer** (business terms, the columns behind them, SQL measures and relationships) and answers questions with a text-to-SQL agent grounded in that layer. AgenticMind integrates it as an **adapter**: its nodes call a deployed instance's public gateway API; nothing is re-implemented.

## What a semantic layer adds

Raw schemas say `ord_stat = 'X'`; business people say *cancelled orders*. A semantic layer maps business vocabulary to data (terms, synonyms, measures like *revenue = sum(quantity × unit_price) excluding cancelled*), so text-to-SQL is grounded in agreed definitions instead of guessing from column names. See [Glossary: semantic layer](/learn/glossary/#semantic-layer).

## Nodes

| Node | Does | Gateway API |
|---|---|---|
| **Auto Ontology** | Connection + capability check: reachable, token valid, semantic layer compiled. Outputs an `Ontology` handle and `status`. | `GET /api/health`, `GET /api/semantic-compilation/status` |
| **Ontology Term Search** | Business terms by name. | `GET /api/terms` |
| **Ontology Term Details** | One term: tables, related terms, SQL measures. | `GET /api/terms/{id}`, `…/sql-attributes` |
| **Ontology Context** | Terms a question mentions, as text context, e.g. for NL-to-SQL. | the two above |
| **Ask Auto Ontology** | Question → answer, SQL, rows and agent steps (streamed into the trace). Same result shape as NL-to-SQL, so Chat shows SQL and rows. | `POST /api/chat/completions` (SSE) |
| **Auto Ontology Tool** | Gives an Agent `search_terms` and `ask_question`. | the above |

## Setting it up

Auto Ontology is a service stack (Next.js gateway on :3000, FastAPI backend and ingestion service, Postgres with pgvector) that needs Docker and NVIDIA model endpoints (an NVIDIA API key from build.nvidia.com).

1. Clone the pinned commit (`778ccdef75536bee5653306f8ded655924e4ada8`) outside version control, `cp .env.example .env`, and set the model keys, new passwords, `AUTH_SECRET` and `CONNECTION_STRINGS`. For the sample data, mount a read-only copy of `examples/data/sales.sqlite` at `/data` and set `CONNECTION_STRINGS=sqlite:////data/sales.sqlite`.
2. `docker compose up -d --build`, open http://localhost:3000, sign in as the admin, turn on **Settings → Semantic Compilation** and wait for *Semantic compilation is ready*.
3. Mint a token under the user menu → **API Tokens** and put it in AgenticMind's `.env` as `AUTO_ONTOLOGY_API_KEY`.
4. In AgenticMind: **New** → *Ask Auto Ontology*, then **Run → Status**, then ask in **Chat**.

## Security notes

- Always use the gateway (:3000). The internal FastAPI port trusts an identity header without verifying it; the adapter never talks to it.
- A token acts with its owner's role: mint it for a least-privileged user.
- Without Vault, connection credentials added in the Auto Ontology UI are stored unencrypted in its Postgres.

## Pinned and contract-tested

Upstream publishes no releases, so the adapter pins a commit (gateway OpenAPI 1.3.0). The operations it uses are vendored as a contract, and tests run every client call through a fake gateway that rejects any method, path, parameter or body not declared in the pinned spec. A breaking upstream change fails the contract tests instead of failing at runtime.

## Troubleshooting

- **Questions time out and Auto Ontology logs show embedding retries:** NVIDIA's hosted embedding model may be overloaded. Set `EMBED_MODEL` in Auto Ontology's `.env` to another hosted embedding model (`nvidia/nemotron-3-embed-1b` worked in testing), then recompile (`POST /api/semantic-compilation/reset`, restart).
- **`ONTOLOGY_NOT_READY`:** the semantic layer is not compiled yet.
- **`ONTOLOGY_UNREACHABLE`:** the deployment is not running or the URL is wrong (use port 3000).

Error codes: `ONTOLOGY_NOT_CONFIGURED`, `ONTOLOGY_UNREACHABLE`, `ONTOLOGY_UNAVAILABLE`, `ONTOLOGY_TIMEOUT`, `ONTOLOGY_UNAUTHORIZED`, `ONTOLOGY_FORBIDDEN`, `ONTOLOGY_NOT_FOUND`, `ONTOLOGY_TERM_NOT_FOUND`, `ONTOLOGY_NOT_READY`, `ONTOLOGY_BUSY`, `ONTOLOGY_ANSWER_FAILED`, `ONTOLOGY_API_ERROR`.
