@mi8y/cap-agents-aicore-vectorstore
A LangChain vector store backed by SAP AI Core Document Grounding: the collection holds the documents and makes the embeddings, and the CAP application stores no vectors of its own.
@mi8y/cap-agents-cds-vectorstore@mi8y/cap-agents-cds-vectorstoreA LangChain vector store whose documents and embeddings are CDS entities, so retrieval runs as a CDS query against the database the CAP service is already bound to.independent, cap keeps documents in the CAP database; AICoreVectorStore points at a Document Grounding collection in SAP AI CoreSAP AI CoreSAP's AI service on BTP: the runtime for AI assets, and through the Generative AI Hub inside it the access to foundation models, the orchestration service with its templating, masking, filtering and grounding modules, the Prompt Registry and Document Grounding.sap official, btp instead, so there is no CDS persistence model to deploy and no embeddings implementation to supply. Each addDocuments() call creates one Grounding document with a UUID v7 and makes every LangChain document a chunk under it, and a retrieved chunk comes back as one LangChain document with document and chunk metadata merged and the collection, document and chunk identifiers under metadata.grounding. Filtering takes SAP AI Core's own retrieval fields, documentMetadata, chunkMetadata, dataRepositoryMetadata, filter and scoringConfiguration, rather than the Mongo-style operators the CDS store accepts, and the adapter pins the collection ID, the vector repository type and the chunk count whatever the filter says. It stops at the collection's contents: delete() needs one parent Grounding document ID and removes every chunk under it, a single chunk cannot be deleted through the adapter, collection lifecycle stays outside it, and similaritySearchVectorWithScore() is unsupported because Grounding takes a text query rather than a caller's vector.
Facts
Where it sits
Who is behind it
In the atlas: maintains 6, contributes to 6@anselm94Mi8Y TechnologiesMi8Y TechnologiesMaintains this
In the atlas: maintains 6@mi8ymaintainers
Before choosing this
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 3from Retrieval-augmented generationCovered SAP materials or a covered CAP customer application are included in training data, model development or model refinement.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
Retrieval and inference are not automatically AI training. The section becomes relevant if the indexed or retrieved covered material is instead used for training, developing or refining the model or system.
SAP Developer License Agreement 3.2 CAP →What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
- Runtime
- Node.js
As a package
- Declared for
- >=10
- Type declarations
- declared
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Grounding a model's answer in data retrieved at question time
AI runtime on BTP with the Generative AI Hub
Download
Install
npm add @mi8y/cap-agents-aicore-vectorstoreDerived from the package name. No recipe recorded; the README has the configuration.
Where it sits in your app
Download
README
quoted from mi8y/cap-agents-addons under MIT, read@mi8y/cap-agents-aicore-vectorstore
A LangChain VectorStore for SAP CAP applications backed by the SAP AI Core Document Grounding service.
SAP AI Core owns document storage, embedding, and retrieval. The package therefore needs no CDS persistence model or client-side LangChain embeddings implementation.
Installation
npm install @mi8y/cap-agents-aicore-vectorstore
Requires:
@sap/cds >= 10@langchain/core >= 1- An existing SAP AI Core Document Grounding collection
- SAP AI Core credentials through a service binding or a configured SAP Cloud SDK destination
Configuration
collectionId is required and must be the Grounding collection ID, not its human-readable title.
import { AICoreVectorStore } from "@mi8y/cap-agents-aicore-vectorstore";
const vectorStore = new AICoreVectorStore({
collectionId: "2b0f4d00-0000-0000-0000-000000000000",
aiResourceGroup: "default",
destination: {
destinationName: "aicore",
useCache: true,
},
});
Options:
collectionId: string— required Grounding collection ID.aiResourceGroup?: string— value of theAI-Resource-Groupheader; defaults todefault.destination?: object— optional destination configuration. When omitted, the SAP AI SDK uses its default connection, such as an AI Core service binding.destinationName: string— SAP Cloud SDK destination name.useCache?: boolean— whether the SAP Cloud SDK destination cache should be used.
A CAP application can keep these values under cds.requires:
{
"cds": {
"requires": {
"cap-agents-aicore-vectorstore": {
"collectionId": "2b0f4d00-0000-0000-0000-000000000000",
"aiResourceGroup": "default",
"destination": {
"destinationName": "aicore",
"useCache": true
}
}
}
}
}
And then you can use the configuration to instantiate the AICoreVectorStore as shown below:
import cds from "@sap/cds";
import { AICoreVectorStore } from "@mi8y/cap-agents-aicore-vectorstore";
const config = cds.env.requires["cap-agents-aicore-vectorstore"];
export const vectorStore = new AICoreVectorStore(config);
Add documents
LangChain and Document Grounding use different document models:
- A LangChain document corresponds to a Grounding chunk.
- Grounding chunks are grouped into Grounding documents.
- Grounding documents belong to a collection.
Each non-empty addDocuments() call creates one Grounding document with a random UUID v7. Every supplied LangChain document becomes a chunk in that parent document. If a LangChain Document.id is present, it is used as the Grounding chunk ID.
import { Document } from "@langchain/core/documents";
const groundingDocumentIds = await vectorStore.addDocuments([
new Document({
id: "cap-overview",
pageContent: "SAP CAP is a framework for enterprise applications.",
metadata: { source: "guide.md", topic: "cap" },
}),
new Document({
id: "cap-services",
pageContent: "CAP services are described using CDS.",
metadata: { source: "guide.md", topic: "services" },
}),
]);
Document metadata is stored on its corresponding chunk. Embeddings are generated server-side according to the collection configuration. The returned IDs are the Grounding document IDs reported by the update API, not the input chunk IDs. Passing an empty array returns an empty array without calling the API.
Search and retrievers
const results = await vectorStore.similaritySearch("What is SAP CAP?", 4);
const scoredResults = await vectorStore.similaritySearchWithScore(
"What is SAP CAP?",
4,
);
const retriever = vectorStore.asRetriever({ k: 4 });
const documents = await retriever.invoke("What is SAP CAP?");
A retrieved Grounding chunk becomes one LangChain document. The LangChain document ID is the parent Grounding document ID. Grounding document metadata and chunk metadata are merged, and identifiers are added under metadata.grounding:
{
collectionId: "2b0f4d00-0000-0000-0000-000000000000",
collectionTitle: "CAP documentation",
documentId: "0195f4c0-0000-7000-8000-000000000000",
chunkId: "cap-overview",
}
When document and chunk metadata use the same key, chunk metadata takes precedence. The returned score uses postProcessingScore, then aggregatedScore, then denseRetrievalScore; it falls back to 0 when no score is available.
Queries must not be empty, and k must be a positive integer.
Metadata filters
Filtering uses SAP AI Core's native retrieval filter structures rather than Mongo-style operators:
const documents = await vectorStore.similaritySearch("leave policy", 4, {
documentMetadata: [
{
key: "country",
value: ["US"],
},
],
chunkMetadata: [
{
key: "language",
value: ["en"],
},
],
});
The filter accepts the following SAP AI Core retrieval fields:
documentMetadatachunkMetadatadataRepositoryMetadatafilterscoringConfiguration
The adapter always enforces its configured collection ID, the vector repository type, the langchain-search filter ID, and searchConfiguration.maxChunkCount based on k. These fields cannot be overridden through the supplied filter.
Metadata conversion
Grounding represents every metadata value as string[]. Ingestion converts values as follows:
- Strings remain strings.
- Numbers, booleans, and bigints use
String(value). - Arrays are converted element by element.
- Objects and
nulluse JSON serialization. undefinedproperties are omitted.
On retrieval, a single value becomes a string and multiple values remain an array. Values are not automatically converted back to numbers, booleans, or objects.
Delete documents
Deletion requires one explicit parent Grounding document ID:
await vectorStore.delete({ documentId: groundingDocumentIds[0] });
Deleting a Grounding document removes all chunks associated with it. Individual chunks cannot be deleted through this adapter. Calling delete() without a documentId throws, preventing accidental collection-wide deletion. Collection lifecycle operations remain outside the LangChain vector-store adapter.
Static helpers
The static helpers follow the conventional LangChain signatures:
const fromTexts = await AICoreVectorStore.fromTexts(
texts,
metadata,
embeddings,
config,
);
const fromDocuments = await AICoreVectorStore.fromDocuments(
documents,
embeddings,
config,
);
The embeddings argument is required by the LangChain API but ignored by this implementation because Document Grounding generates embeddings server-side. Both helpers create a vector store and immediately add the supplied content.
Vector operations
addVectors(vectors, documents) ignores the supplied vectors and delegates the documents to addDocuments() so that embeddings are generated server-side.
similaritySearchVectorWithScore() is unsupported because Document Grounding accepts text queries rather than caller-provided query vectors. Use similaritySearch(), similaritySearchWithScore(), or a LangChain retriever instead.
License
History
Others providing
Compare all 9 on the RAG on CDS page →- SAP AI CoreSAP AI CoreSAP's AI service on BTP: the runtime for AI assets, and through the Generative AI Hub inside it the access to foundation models, the orchestration service with its templating, masking, filtering and grounding modules, the Prompt Registry and Document Grounding.sap official, btpAI runtime on BTP with the Generative AI Hub
- SAP HANA CloudSAP HANA CloudThe managed database under most of this: CAP's default target, the store Datasphere and Analytics Cloud sit on, and a service with plans and components.sap official, btpManaged SAP HANA database service on BTP
- @cap-js/ai@cap-js/aiOut-of-the-box value-help recommendations powered by SAP RPT-1, SAP AI Core as a standard CAP service, and an experimental local embedding model behind SQLite's vector functions.sap official, capValue-help recommendations and SAP AI Core as a CAP service
- cap-llm-plugincap-llm-pluginGenerative AI in a CAP application with the sensitive fields anonymised through SAP HANA before the prompt leaves, so the model never sees the confidential half.independent, capGenerative AI in CAP with fields anonymised through SAP HANA
- @mi8y/cap-agents-cds-vectorstore@mi8y/cap-agents-cds-vectorstoreA LangChain vector store whose documents and embeddings are CDS entities, so retrieval runs as a CDS query against the database the CAP service is already bound to.independent, capLangChain vector store with CDS entities for embeddings
- @sap/cds@sap/cdsThe CAP Node.js runtime, which compiles the CDS model, serves the services declared in it, answers generic requests before any handler runs, and loads every cds-plugin.sap official, capCAP Node.js runtime
- @saptarishi/cds-plugin-llm@saptarishi/cds-plugin-llmA CAP service kind that puts eleven model providers behind one chat, stream, embed and batch interface, so which backend a service calls is a profile in package.json rather than a change to the handler.independent, capCAP service kind putting eleven model providers behind one API
- @saptarishi/cds-plugin-vector-hana@saptarishi/cds-plugin-vector-hanaVector storage and similarity search on SAP HANA from CAP, packaged as a plugin so the embedding column and the query are modelled rather than hand-written.independent, capVector storage and similarity search on SAP HANA from CAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
History in the atlas
- First seen.
For your agent
- Ref
artifact:mi8y-cap-agents-aicore-vectorstore- JSON
- /artifacts/mi8y-cap-agents-aicore-vectorstore.json
- MCP
- Connecting an agent