Skip to content

fs-vector-store

Configure, switch, refresh or troubleshoot the vector index of the consumer agent: ChromaDB or the Teradata Enterprise Vector Store.


name: "Feature Store: Vector Store Configuration" description: "Configure, switch, refresh or troubleshoot the consumer agent's vector index — ChromaDB (local/server) or Teradata Enterprise Vector Store. Invoke when the user wants to set up embeddings for the business dictionary, keep the index in step with new documentation, switch vector store backend, configure Teradata in-database embedding (TeradataAI), or diagnose vector index errors. SKIP when the user wants to launch the full chatbot end-to-end (use fs-agent) — this skill covers only the vector store configuration piece." argument-hint: "[vector-backend: chroma|teradata][embedding-provider]" allowed-tools: "Read, Edit, Write, Bash, Glob, Grep"


Generate Python code to configure the tdfs4ds consumer agent's vector index backend — the store that holds embeddings of the business dictionary (objects, sections, columns) for semantic search. Two backends are supported: ChromaDB (default, external to Vantage) and Teradata Enterprise Vector Store (embeddings + index live inside Vantage).

User context: $ARGUMENTS

Step Skill Why
Before fs-setup Establish the Teradata connection first.
Before fs-document The vector index is built from the business dictionary — populate it first, or the index will be empty.
After fs-agent Once the vector store is configured and built, launch the full consumer agent / chatbot.

Demos: demos/notebooks/G2 - Consumer agent.ipynb.

Ask for any missing values before generating code: - Vector backend — 'chroma' (default) or 'teradata'. - Embedding provider (Chroma path, or Teradata path with no in-DB embedding) — 'openai', 'vllm', 'openai-compatible', 'mistralai', 'azure', 'bedrock', 'gcp', or 'litellm'. - Teradata in-DB embedding (Teradata backend only, optional) — TERADATA_AI_API_TYPE: 'td_hosted' (zero-credential, Teradata-hosted), 'aws', 'azure', 'gcp', 'nim', 'hugging_face', or 'onnx'.


Pattern — Option A: ChromaDB (default)

import tdfs4ds

tdfs4ds.VECTOR_STORE_BACKEND = 'chroma'          # default — can be omitted
tdfs4ds.CHROMA_MODE = 'local'                    # 'local' | 'server'
tdfs4ds.CHROMA_PATH = './tdfs4ds_chroma'         # disk path (local mode)
# tdfs4ds.CHROMA_HOST = 'localhost'              # server mode only
# tdfs4ds.CHROMA_PORT = 8000                     # server mode only

# Embedding model — falls back to INSTRUCT_MODEL_* if unset
tdfs4ds.EMBEDDING_MODEL_PROVIDER = '<PROVIDER>'  # 'openai' | 'vllm' | 'azure' | 'bedrock' | ...
tdfs4ds.EMBEDDING_MODEL_URL      = '<URL>'       # None for default OpenAI / Bedrock
tdfs4ds.EMBEDDING_MODEL_API_KEY  = '<API_KEY>'
tdfs4ds.EMBEDDING_MODEL_MODEL    = 'text-embedding-3-small'
tdfs4ds.EMBEDDING_MODEL_DIM      = 1536

from tdfs4ds.agent import build_vector_index
build_vector_index(force_rebuild=False)   # incremental — only new/changed docs

Pattern — Option B: Teradata Enterprise Vector Store

Keeps all three index collections (objects, sections, columns) inside Vantage via langchain_teradata. Requires pip install langchain-teradata.

import tdfs4ds

tdfs4ds.VECTOR_STORE_BACKEND         = 'teradata'
tdfs4ds.TERADATA_VECTOR_STORE_PREFIX = 'tdfs4ds'   # creates tdfs4ds_objects, tdfs4ds_sections, tdfs4ds_columns

# --- Embedding source: pick ONE of the two sub-options below ---

# B1. Teradata-hosted in-database embedding (zero credentials)
tdfs4ds.TERADATA_AI_API_TYPE   = 'td_hosted'
tdfs4ds.TERADATA_AI_MODEL_NAME = 'amazon.titan-embed-text-v2:0'
# Auth is transparent via the active teradataml session — no access_key/region needed.

# B2. Other TeradataAI in-database providers (need credentials/region)
# tdfs4ds.TERADATA_AI_API_TYPE   = 'aws'              # 'aws'|'azure'|'gcp'|'nim'|'hugging_face'|'onnx'
# tdfs4ds.TERADATA_AI_MODEL_NAME = 'amazon.titan-embed-text-v2:0'
# tdfs4ds.TERADATA_AI_REGION     = 'us-east-1'         # aws only
# tdfs4ds.TERADATA_AI_API_BASE   = None                # nim only
# tdfs4ds.TERADATA_AI_ACCESS_KEY = None                # aws only; or TDFS4DS_TERADATA_AI_ACCESS_KEY env var

# B3. Leave TERADATA_AI_API_TYPE unset to reuse the standard LangChain embedding
#     path instead (EMBEDDING_MODEL_PROVIDER='vllm'/'openai-compatible'/etc.) —
#     TeradataVectorStore accepts either embedding object interchangeably.
# tdfs4ds.EMBEDDING_MODEL_PROVIDER = 'vllm'
# tdfs4ds.EMBEDDING_MODEL_URL      = 'https://my-tei-endpoint/v1'

from tdfs4ds.agent import build_vector_index
build_vector_index(force_rebuild=False)   # incremental: update(data_refresh=True), falls back to rebuild
# build_vector_index(force_rebuild=True)  # or: tdfs4ds.rebuild_vector_indexing(force_rebuild=True)
#                                          # full destroy + recreate — removes stale entries

.env variables (either backend)

All of the above can come from a .env file instead of direct assignment — use the TDFS4DS_ prefix, not bare attribute names:

TDFS4DS_VECTOR_STORE_BACKEND=teradata
TDFS4DS_TERADATA_AI_API_TYPE=td_hosted
TDFS4DS_TERADATA_AI_MODEL_NAME=amazon.titan-embed-text-v2:0

# NOT valid — silently ignored by the .env loader (only TDFS4DS_* is read):
# tdfs4ds.TERADATA_AI_API_TYPE=td_hosted

Authentication (Teradata backend only)

The Enterprise Vector Store is a REST service that opens a database session on your behalf, so it needs a credential of its own. tdfs4ds calls teradataml.set_auth_token for you from TDFS4DS_VECTOR_STORE_AUTH_*, trying four mechanisms and taking the first fully configured:

Order Mechanism Variables
1 JWT — a token you already hold BASE_URL + AUTH_TOKEN (+ USERNAME, see below)
2 PAT BASE_URL + PAT_TOKEN + PEM_FILE (+ USERNAME)
3 Basic BASE_URL + USERNAME + PASSWORD
4 OAuth BASE_URL + CLIENT_ID

JWT is tried first because the other three generate a token: an explicitly supplied one must never be silently passed over.

Six things that each cost real debugging time:

  1. Set USERNAME on the JWT path. teradataml derives it from the active database session when omitted and raises username should be passed in the parameters or call create_context() before using set_auth_token(). check_configuration() is designed to run before connect(), so the one mechanism with no username was the one most likely to be asked without a session.
  2. A ready-made JWT is stored unvalidated — teradataml's validation call is commented out upstream — so set_auth_token succeeds with an expired token and the failure surfaces later, at the first call that spends it. check_configuration() reports the token's remaining lifetime for exactly this reason.
  3. SQLState 28000 is not "service down". It means the service was reached and the database refused the credential presented for you. Do not go looking at licensing. Usual causes, in order: an expired token; wrong Basic credentials; a user who cannot log on the way the service logs on for it (set_auth_token needs the NULL-password logon privilege — see GRANT LOGON).
  4. The service version must be >= 2.1.11. An older one is up, accepts the credential, and misbehaves only on write — so nothing read-only will reveal it. It is a Vantage platform component: upgrading is an admin action, not a pip install, and unrelated to the teradatagenai client version.
  5. cannot import name ... from 'teradataml...' is a version mismatch, not a missing package. teradatagenai imports a teradataml internal this teradataml no longer has, so reinstalling the latest versions does not help. check_configuration() names the versions, flags a copy in ~/.local that shadows the environment's, and gives a pair known to work.
  6. A collection whose backing object is gone (collection_<name>_index does not exist) serves nothing, so build_vector_index() recreates it. That needs admin rights: when the destroy is refused, the error names reset_teradata_store for an admin, or use chroma meanwhile.
report = tdfs4ds.check_configuration()   # rows 2 and 3 are auth and service

Pattern — Health check: confirm the Teradata backend actually works

A build_vector_index() call reporting success is not proof the collections hold usable, searchable vectors — writes are asynchronous, and a collection can end up update_failed/create_failed server-side even when the Python call raised no exception. Verify both layers explicitly:

from tdfs4ds.agent.vector_store_teradata import (
    _collection_manager, _store_name, _SOURCES, _is_failed_status,
)

# 1. Collection status — the authoritative signal, not "did the call raise"
mgr = _collection_manager()
rows = mgr.list(return_type='json', page_size=100000)
if isinstance(rows, dict):
    rows = rows.get('collections') or rows.get('data') or list(rows.values())

for source in _SOURCES:
    name = _store_name(source)
    match = [r for r in rows if r.get('collection_name') == name]
    status = match[0].get('collection_status') if match else None
    print(name, '->', status, '(FAILED)' if _is_failed_status(status) else '')

# 2. Real search — the only proof the collection actually contains vectors
from tdfs4ds.agent.vector_index import search_vector_index

hits = search_vector_index('<phrase taken verbatim from a known business-dictionary row>', k=5)
print(len(hits), 'hit(s)')

A *_failed status will not recover on its own — call tdfs4ds.agent.vector_store_teradata.reset_teradata_store(sources=[...]) (admin-only) to destroy and recreate that collection, then rebuild.

See notebook dev/teradata vector store/01 - Setup feature store with data dictionary and vector indexing.ipynb for a full worked example: source data → data dictionary → upload_features(document=True, vector_indexing=True) → health check.

Known bugs fixed (v0.3.1.140) — background if you hit them on an older install

Two real bugs were root-caused via live VCL2 testing and fixed in vector_store_teradata.py. If troubleshooting an install predating 0.3.1.140, check for these first before assuming a new issue:

  1. _inputdata view permanently referencing a garbage-collected ephemeral view — _from_datasets_kwargs() used to build data= via tdml.DataFrame.from_query("SELECT ... FROM <permanent view>"). DataFrame.from_query(...) itself eagerly materializes an ephemeral ml___frmqry_v_<id> view and sets _table_name to it at construction time — before teradatagenai is even called — and teradatagenai bakes whatever _table_name it receives permanently into the collection's collection_<name>_inputdata view DDL. Once Vantage garbage-collects the ephemeral view (near-immediately), _inputdata — and collectionV_<name>, which joins through it — is permanently broken: similarity_search() (and even a plain SELECT COUNT(*) from any client) fails forever with Error 3807 / TDML_2412: Object ... does not exist, not transiently. Fixed: data= is now passed as a plain fully-qualified "schema.view" string naming the permanent view directly — never a DataFrame at all, from_query()-derived or otherwise. If you hit this on an older install, reset_teradata_store() alone does NOT fix it (it just recreates the same broken shape) — you need the code fix, then reset.
  2. search_teradata_index silently returning 0 rows on genuine matches — _parse_one()'s _TEXT_KEYS assumed a generic/Chroma-like hit shape (content/page_content/text/document). A real Teradata hit is flattened differently: the text lives directly under the source's real business-dictionary column name (business_description for objects/columns, section_content for sections). Every hit's text stayed empty and was silently dropped — similarity_search() itself returned real hits, but search_vector_index() returned 0. Fixed: added business_description/section_content to _TEXT_KEYS.

Keeping the index in step with the documentation

The index is a copy of the business dictionary. New or corrected text is searchable only after a refresh:

What wrote the documentation Refreshes the index
tdfs4ds.rebuild_documentation() yes, at the end (rebuild_vector_indexing=True, default)
set_feature/process/dataset/object/deep_table_documentation(...) yes (refresh_index=True, default)
upload_features(..., document=True) / build_dataset(..., document=True) only with vector_indexing=True
document_process, document_process_incremental, document_dataset_incremental, upload_business_dictionary_* no: call build_vector_index(force_rebuild=False)

build_vector_index(force_rebuild=False) is the routine refresh on both backends:

  • Chroma embeds only rows that are new or changed (same text, metadata and embedding model = skipped).
  • Teradata (since 0.3.1.169) refreshes an existing collection in place with update(data_refresh=True); if the service refuses, it falls back to destroy + recreate (admin), and it creates a missing collection. add_datasets is never used for a refresh: it attaches a new source and is always refused for the business-dictionary view already attached. When neither mechanism works the collection stays intact and searchable, and the warning names both failures.
  • force_rebuild=True (or tdfs4ds.rebuild_vector_indexing()) wipes and rebuilds: use it after removing documentation (an incremental refresh never deletes rows) or to recover a *_failed collection. On Teradata it needs admin; a refused destroy falls back to the incremental path with a warning.

Several stores (Chroma, 0.3.3.15+): each feature store has its own collections, <prefix>__<database>__<source> (vector_index.chroma_collection_name), so a store attached read-only (databases_readonly=) can be indexed and searched next to the primary; build_vector_index(stores=[...]) picks the stores, search reads all of them. vector_index.index_freshness(store=None) says, per source and without embedding anything, whether the index is up_to_date, behind (rows documented since the last build), never built, model_changed or unknown (a read-only store); the admin app's Maintenance panel shows it. A row removed from the documentation leaves the Chroma index at the next build.

Checking it: the admin app's Documentation › Coverage panel gives each object's index status (Chroma exact; Teradata inferred from the collection's last update). tdfs4ds.selftest_vector_store() (or check_configuration(selftest=True)) exercises create / search / refresh / search on throwaway objects and reports each step, which is the way to tell a service problem from a configuration one.

Transient 502s / create_failed — retry, don't assume a bug

On this VCL2 test instance, the Vector Store REST gateway occasionally returned a genuine transient 502 Bad Gateway (TDML_2412 ... Response Code: 502, Message: <html>...502 Bad Gateway...) on CollectionManager().list() or Collection.create() calls — unrelated to any code change, and unrelated to the two real bugs above. A collection can also occasionally land in collection_status='create_failed' after a from_datasets() call that otherwise looked like it succeeded (no client-side exception). Both are environmental flakiness on the REST service, not deterministic bugs:

  • A 502 is correctly classified by _reraise_if_service_down as the service-down RuntimeError — that classification is right; just retry the call (or the whole reset_teradata_store()/build_teradata_index() call) a few seconds later.
  • A create_failed/update_failed status (via _lookup_store_info(name)['collection_status']) will not resolve on its own — call reset_teradata_store(sources=[...]) again for just that source to retry the create from scratch.

Don't over-investigate a single 502/*_failed occurrence as a new code bug — confirm it reproduces on a clean retry first.

Collection descriptions

build_teradata_index()/reset_teradata_store() set a fixed, human-readable description= per collection at creation time (_SOURCE_DESCRIPTIONS in vector_store_teradata.py) — visible via CollectionManager().list()'s collection_description field. Descriptions are only set at from_datasets (creation); add_datasets/update() calls on an existing collection don't change it.

Incremental Chroma rebuild and temporary tokens (v0.3.1.215+)

  • build_vector_index(force_rebuild=False) on Chroma embeds only new or changed rows. A row is skipped when its text, metadata and embedding model all match what is stored. Changing EMBEDDING_MODEL_MODEL re-embeds everything. The first build after upgrading re-embeds once.
  • tdfs4ds.EMBEDDING_BATCH_SIZE (default 8) sets how many documents go into each embedding call. Raise it for endpoints that accept larger batches. Pair it with EMBEDDING_BATCH_DELAY for endpoints that throttle.
  • An expired embedding token (for example a Bedrock bearer token) is handled the same way as in documentation: you are prompted for a new token, the client is rebuilt, and the current batch is retried. This does not apply to the Teradata backend, which embeds inside the database with its own credential.

Rules

  • Never mix the two knobs. EMBEDDING_MODEL_PROVIDER/INSTRUCT_MODEL_PROVIDER select the LangChain/Chroma path ('openai', 'vllm', 'bedrock', 'azure', 'gcp', 'mistralai', 'litellm'). TERADATA_AI_API_TYPE selects the in-database TeradataAI path ('td_hosted', 'aws', 'azure', 'gcp', 'nim', 'hugging_face', 'onnx') and is only consulted when VECTOR_STORE_BACKEND='teradata'. Setting a TERADATA_AI_API_TYPE value like 'td_hosted' into EMBEDDING_MODEL_PROVIDER raises a ValueError pointing at the correct variable.
  • INSTRUCT_MODEL_PROVIDER (chat/intent-classification LLM) and the embedding provider are fully independent — e.g. INSTRUCT_MODEL_PROVIDER='bedrock' for chat while VECTOR_STORE_BACKEND='teradata' + TERADATA_AI_API_TYPE='td_hosted' handles embeddings. Match them only if you specifically want the same underlying model family for both.
  • .env files only load TDFS4DS_*-prefixed variables (per tdfs4ds/config.py) — a bare tdfs4ds.TERADATA_AI_API_TYPE=... line in .env is silently ignored. Use direct Python attribute assignment in code, or TDFS4DS_TERADATA_AI_API_TYPE in .env.
  • The Teradata backend's staging/collection-creation calls resolve against the Teradata session's current database at the teradataml/Vantage level, which must match tdfs4ds.SCHEMA — set TDFS4DS_TD_DATABASE=<SCHEMA> in .env so tdfs4ds.reconnect_teradata() opens the session on it (or pass database=<SCHEMA>, temp_database_name=<SCHEMA> to tdml.create_context by hand; see fs-setup) or expect TDML_2412: Object ... does not exist errors.
  • The business dictionary must have content before building the index — an empty dictionary yields an empty (but functioning) index. Run fs-document first.
  • force_rebuild=False (default) is incremental: Chroma skips unchanged rows; Teradata refreshes in place (update(data_refresh=True)), falling back to destroy + recreate. It never deletes a row whose documentation was removed. force_rebuild=True always destroys and recreates — use it after removing documentation or to purge stale entries (admin-only on Teradata). tdfs4ds.rebuild_vector_indexing(force_rebuild=True) is a top-level shortcut for the same full rebuild.
  • Never add an update(update_style=...) pass after a Teradata build: a post-build MAJOR update turned freshly created ready collections into update_failed at a customer site (removed in 0.3.1.228).
  • Two stores sharing one Vector Store service need different TERADATA_VECTOR_STORE_PREFIX values: collections are named per prefix for the whole service, so the default tdfs4ds makes them overwrite each other's.
  • Switching VECTOR_STORE_BACKEND does not migrate existing embeddings — rebuild the index after switching.
  • EMBEDDING_MODEL_DIM only applies to the Chroma/LangChain path; TeradataAI dimensions are model-defined.