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
Related skills¶
| 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:
- Set
USERNAMEon the JWT path. teradataml derives it from the active database session when omitted and raisesusername should be passed in the parameters or call create_context() before using set_auth_token().check_configuration()is designed to run beforeconnect(), so the one mechanism with no username was the one most likely to be asked without a session. - A ready-made JWT is stored unvalidated — teradataml's validation call is commented out
upstream — so
set_auth_tokensucceeds 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. SQLState 28000is 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_tokenneeds the NULL-password logon privilege — seeGRANT LOGON).- 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 apip install, and unrelated to theteradatagenaiclient version. cannot import name ... from 'teradataml...'is a version mismatch, not a missing package. teradatagenai imports a teradataml internal this teradataml no longer has (seen: teradatagenai 20.0.0.9 with teradataml 20.0.0.12). tdfs4ds does not pin the pair, since a customer may have to keep a given teradataml. The Vector Store backend, in-database embedding andcheck_configuration()name both installed versions and the two ways out: keep teradataml and%pip install -U teradatagenai(20.0.0.10 works with teradataml 20.0.0.12 and later), or keep teradatagenai and install the teradataml it imports with. A copy in~/.localthat shadows the environment's is flagged. Restart the kernel afterwards.- A collection whose backing object is gone (
collection_<name>_indexdoes not exist) serves nothing, sobuild_vector_index()recreates it. That needs admin rights: when the destroy is refused, the error namesreset_teradata_storefor an admin, or usechromameanwhile.
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:
_inputdataview permanently referencing a garbage-collected ephemeral view —_from_datasets_kwargs()used to builddata=viatdml.DataFrame.from_query("SELECT ... FROM <permanent view>").DataFrame.from_query(...)itself eagerly materializes an ephemeralml___frmqry_v_<id>view and sets_table_nameto it at construction time — beforeteradatagenaiis even called — andteradatagenaibakes whatever_table_nameit receives permanently into the collection'scollection_<name>_inputdataview DDL. Once Vantage garbage-collects the ephemeral view (near-immediately),_inputdata— andcollectionV_<name>, which joins through it — is permanently broken:similarity_search()(and even a plainSELECT COUNT(*)from any client) fails forever withError 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 aDataFrameat 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.search_teradata_indexsilently returning 0 rows on genuine matches —_parse_one()'s_TEXT_KEYSassumed 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_descriptionfor objects/columns,section_contentfor sections). Every hit'stextstayed empty and was silently dropped —similarity_search()itself returned real hits, butsearch_vector_index()returned 0. Fixed: addedbusiness_description/section_contentto_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_datasetsis 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(ortdfs4ds.rebuild_vector_indexing()) wipes and rebuilds: use it after removing documentation (an incremental refresh never deletes rows) or to recover a*_failedcollection. 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
502is correctly classified by_reraise_if_service_downas the service-downRuntimeError— that classification is right; just retry the call (or the wholereset_teradata_store()/build_teradata_index()call) a few seconds later. - A
create_failed/update_failedstatus (via_lookup_store_info(name)['collection_status']) will not resolve on its own — callreset_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. ChangingEMBEDDING_MODEL_MODELre-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 withEMBEDDING_BATCH_DELAYfor 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_PROVIDERselect the LangChain/Chroma path ('openai','vllm','bedrock','azure','gcp','mistralai','litellm').TERADATA_AI_API_TYPEselects the in-databaseTeradataAIpath ('td_hosted','aws','azure','gcp','nim','hugging_face','onnx') and is only consulted whenVECTOR_STORE_BACKEND='teradata'. Setting aTERADATA_AI_API_TYPEvalue like'td_hosted'intoEMBEDDING_MODEL_PROVIDERraises aValueErrorpointing 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 whileVECTOR_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..envfiles only loadTDFS4DS_*-prefixed variables (pertdfs4ds/config.py) — a baretdfs4ds.TERADATA_AI_API_TYPE=...line in.envis silently ignored. Use direct Python attribute assignment in code, orTDFS4DS_TERADATA_AI_API_TYPEin.env.- The Teradata backend's staging/collection-creation calls resolve against the Teradata session's current database at the
teradataml/Vantage level, which must matchtdfs4ds.SCHEMA— setTDFS4DS_TD_DATABASE=<SCHEMA>in.envsotdfs4ds.reconnect_teradata()opens the session on it (or passdatabase=<SCHEMA>, temp_database_name=<SCHEMA>totdml.create_contextby hand; seefs-setup) or expectTDML_2412: Object ... does not existerrors. - The business dictionary must have content before building the index — an empty dictionary yields an empty (but functioning) index. Run
fs-documentfirst. 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=Truealways 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 createdreadycollections intoupdate_failedat a customer site (removed in 0.3.1.228). - Two stores sharing one Vector Store service need different
TERADATA_VECTOR_STORE_PREFIXvalues: collections are named per prefix for the whole service, so the defaulttdfs4dsmakes them overwrite each other's. - Switching
VECTOR_STORE_BACKENDdoes not migrate existing embeddings — rebuild the index after switching. EMBEDDING_MODEL_DIMonly applies to the Chroma/LangChain path; TeradataAI dimensions are model-defined.