Vectorstore Execution
A managed vector database’s operations, executed by the tool runner: the vectorstore kind of tool call.
A managed vectorstore’s database is a service at a host that its owner chooses: a Qdrant Cloud cluster at its
ApiConnection’s url, or Pinecone. Connecting to it from the app or the worker, which hold every credential of the
platform’s and reach its private network, would let a manifest point them at any address. So each operation is
resolved in the app, where the database and the Smarter Secrets are, into a VectorstoreToolCall: the url, the
api key, the index’s name, the operation and its parameters, with every vector already embedded. The tool runner
executes it with execute_vectorstore_call(), in the tool worker, which holds no credential of the platform’s and
reaches no private address (ADR-038, issue #1081).
A self-hosted Qdrant server, which Smarter runs in the cluster, is reached in process, with the same operations
(run_vectorstore_operation() with a client): the tool worker can’t reach the cluster’s private network, by
design. So is a client that a test injects.
The operations are plain functions of the vendor’s client, in QDRANT_OPERATIONS and
PINECONE_OPERATIONS, so that both paths run the same code. Their parameters and results are JSON. Nothing here
reads the database.
Warning
A resolved call holds the api key. It is excluded from repr(). Never log the call’s model_dump().
- smarter.apps.vectorstore.execution.PINECONE_OPERATIONS: dict[str, Callable[[Any, str, dict[str, Any]], JsonValue]] = {'create': <function pinecone_create>, 'create_snapshot': <function pinecone_create_backup>, 'delete': <function pinecone_delete>, 'delete_snapshot': <function pinecone_delete_backup>, 'drop': <function pinecone_drop>, 'exists': <function pinecone_exists>, 'index_ready': <function pinecone_index_ready>, 'query': <function pinecone_query>, 'restore_snapshot': <function pinecone_restore_backup>, 'stats': <function pinecone_stats>, 'upsert': <function pinecone_upsert>}
each a function of a Pinecone client, the index’s name, and its parameters.
{ 'create': <function pinecone_create at 0x7f29feb2bcc0>, 'create_snapshot': <function pinecone_create_backup at 0x7f29feb385c0>, 'delete': <function pinecone_delete at 0x7f29feb38300>, 'delete_snapshot': <function pinecone_delete_backup at 0x7f29feb38720>, 'drop': <function pinecone_drop at 0x7f29feb2be20>, 'exists': <function pinecone_exists at 0x7f29feb2ba00>, 'index_ready': <function pinecone_index_ready at 0x7f29feb2bb60>, 'query': <function pinecone_query at 0x7f29feb38460>, 'restore_snapshot': <function pinecone_restore_backup at 0x7f29feb38880>, 'stats': <function pinecone_stats at 0x7f29feb38040>, 'upsert': <function pinecone_upsert at 0x7f29feb381a0>, }
- Type:
Pinecone’s operations, by name
- smarter.apps.vectorstore.execution.QDRANT_OPERATIONS: dict[str, Callable[[Any, str, dict[str, Any]], JsonValue]] = {'create': <function qdrant_create>, 'create_snapshot': <function qdrant_create_snapshot>, 'delete': <function qdrant_delete>, 'delete_document': <function qdrant_delete_document>, 'delete_snapshot': <function qdrant_delete_snapshot>, 'drop': <function qdrant_drop>, 'exists': <function qdrant_exists>, 'query': <function qdrant_query>, 'restore_snapshot': <function qdrant_restore_snapshot>, 'stats': <function qdrant_stats>, 'upsert': <function qdrant_upsert>}
each a function of a QdrantClient, the collection’s name, and its parameters.
{ 'create': <function qdrant_create at 0x7f29feb2acf0>, 'create_snapshot': <function qdrant_create_snapshot at 0x7f29feb2b480>, 'delete': <function qdrant_delete at 0x7f29feb2b060>, 'delete_document': <function qdrant_delete_document at 0x7f29feb2b1c0>, 'delete_snapshot': <function qdrant_delete_snapshot at 0x7f29feb2b5e0>, 'drop': <function qdrant_drop at 0x7f29feb2ab90>, 'exists': <function qdrant_exists at 0x7f29feb2a980>, 'query': <function qdrant_query at 0x7f29feb2b320>, 'restore_snapshot': <function qdrant_restore_snapshot at 0x7f29feb2b740>, 'stats': <function qdrant_stats at 0x7f29feb2ada0>, 'upsert': <function qdrant_upsert at 0x7f29feb2afb0>, }
- Type:
Qdrant’s operations, by name
- smarter.apps.vectorstore.execution.VECTORSTORE_TOOL_CALL_KIND: Final = 'vectorstore'
The
kindof a managed vector database’s operation, which selectsexecute_vectorstore_call().
- class smarter.apps.vectorstore.execution.VectorstoreToolCall(*, kind='vectorstore', backend, url='', api_key='', index_name, operation, params=<factory>, timeout=30.0)[source]
Bases:
ToolCallA managed vector database’s operation, resolved for execution.
- Variables:
backend (
Literal['qdrant','pinecone']) –qdrantorpinecone.url (
str) – The Qdrant Cloud cluster’s url, from the vectorstore’s ApiConnection. Pinecone’s is its own.api_key (
str) – The database’s api key, from the ApiConnection’s Secret.index_name (
str) – The collection’s or the index’s name.operation – The operation, a key of
QDRANT_OPERATIONSorPINECONE_OPERATIONS.params (
dict[str,JsonValue]) – The operation’s parameters, as JSON, e.g. the vectors to upsert, already embedded.timeout (
float) – Seconds that the operation may take.
- model_config = {'extra': 'forbid', 'frozen': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- smarter.apps.vectorstore.execution.error_of(status_code, message)[source]
The backend error of a failure from the tool worker, by its
status_code(status_of()).- Return type:
VectorStoreBackendError
- smarter.apps.vectorstore.execution.execute_vectorstore_call(call)[source]
Execute a resolved operation of a managed vector database.
- Parameters:
call (
ToolCall) – The call, aVectorstoreToolCall.- Return type:
- Returns:
The operation’s result, as JSON; or a result with a
failure, whosestatus_codesays whether the api key was refused (401), the request would be refused again (422), or the database couldn’t be reached (503).- Raises:
TypeError – If the call isn’t a
VectorstoreToolCall.
- smarter.apps.vectorstore.execution.pinecone_error(operation, error)[source]
Return the backend error of an exception from Pinecone, by whether retrying could help.
- Parameters:
- Return type:
VectorStoreBackendError- Returns:
A credentials error for a refused api key, a rejected error for another request that Pinecone would refuse again, and a connection error for anything else, e.g. a timeout or a 5xx, which may pass.
- smarter.apps.vectorstore.execution.qdrant_error(operation, error)[source]
Return the backend error of an exception from Qdrant.
- smarter.apps.vectorstore.execution.qdrant_filter(metadata_filter)[source]
A Qdrant filter that matches chunks whose metadata has every value of metadata_filter.
- Return type:
Filter|None
- smarter.apps.vectorstore.execution.run_in_process(backend, client, index_name, operation, params)[source]
Run an operation on a client in this process, and raise its errors as backend errors.
- Parameters:
- Return type:
JsonValue- Returns:
The operation’s result.
- Raises:
VectorStoreBackendError – If the operation is unknown, or fails, classified as the vendor’s error says.
- smarter.apps.vectorstore.execution.run_vectorstore_operation(backend, operation, params=None, *, index_name, client=None, url='', api_key='', timeout=30.0)[source]
Run a vector database’s operation: in process on a client, or through the tool runner for a managed database.
- Parameters:
backend (
str) –qdrantorpinecone.operation (
str) – The operation’s name.index_name (
str) – The collection’s or the index’s name.client (
Any) – A client to run it on, in this process: a self-hosted Qdrant server’s, or one that a test injects. None sends the call, withurlandapi_key, to the tool runner.url (
str) – The managed Qdrant Cloud cluster’s url.api_key (
str) – The managed database’s api key.timeout (
float) – Seconds that the operation may take.
- Return type:
JsonValue- Returns:
The operation’s result.
- Raises:
VectorStoreBackendError – If the operation fails, classified as credentials, rejected or connection.