@chainlink/mcp-server
Version:
Prototype MCP Server for CLL
72 lines • 3.03 kB
JavaScript
"use strict";
/**
* @fileoverview Vector database schema definitions and interfaces
*
* Defines the structure for document storage in the vector database using
* Apache Arrow schema format. Supports configurable embedding dimensions
* for different providers and includes metadata for document management.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.CCIPDocTableSchema = exports.EMBEDDING_DIMENSIONS = void 0;
exports.createCCIPDocTableSchema = createCCIPDocTableSchema;
const apache_arrow_1 = require("apache-arrow");
/** Metadata structure for document entries */
const metadataStruct = new apache_arrow_1.Struct([
new apache_arrow_1.Field("sourceDocId", new apache_arrow_1.Utf8(), true),
new apache_arrow_1.Field("sourceDocFilename", new apache_arrow_1.Utf8(), true),
new apache_arrow_1.Field("sourceDocHash", new apache_arrow_1.Utf8(), true),
new apache_arrow_1.Field("product", new apache_arrow_1.Utf8(), true), // ccip, functions, etc.
]);
/**
* Embedding dimensions by provider
*
* Defines the vector dimensions for different embedding providers.
* These must match the actual dimensions output by each provider's models.
*
* @constant EMBEDDING_DIMENSIONS
*/
exports.EMBEDDING_DIMENSIONS = {
/** OpenAI text-embedding-3-small dimensions */
openai: 1536,
/** Ollama nomic-embed-text dimensions */
ollama: 768,
};
/**
* Create a vector field with configurable dimensions
*
* @param dimensions - Number of dimensions for the embedding vectors
* @returns Apache Arrow Field configured for vector storage
*/
function createVectorField(dimensions) {
return new apache_arrow_1.Field("vector", new apache_arrow_1.FixedSizeList(dimensions, new apache_arrow_1.Field("item", new apache_arrow_1.Float32())), false);
}
/**
* Create schema for CCIP document table with configurable vector dimensions
*
* The schema includes all necessary fields for document storage:
* - Unique chunk identifier
* - Metadata (source, product)
* - Vector embedding (configurable dimensions)
* - Chunk type and content
* - Content hash for deduplication
*
* @param embeddingDimensions - Number of dimensions for embedding vectors
* @returns Apache Arrow Schema for document table
*/
function createCCIPDocTableSchema(embeddingDimensions) {
return new apache_arrow_1.Schema([
new apache_arrow_1.Field("chunkId", new apache_arrow_1.Utf8(), false),
new apache_arrow_1.Field("metadata", metadataStruct, false),
createVectorField(embeddingDimensions),
new apache_arrow_1.Field("chunkType", new apache_arrow_1.Utf8(), false),
new apache_arrow_1.Field("chunkText", new apache_arrow_1.Utf8(), false),
new apache_arrow_1.Field("chunkHash", new apache_arrow_1.Utf8(), false),
]);
}
/**
* Default schema for backwards compatibility (OpenAI dimensions)
*
* @constant CCIPDocTableSchema
*/
exports.CCIPDocTableSchema = createCCIPDocTableSchema(exports.EMBEDDING_DIMENSIONS.openai);
//# sourceMappingURL=schema.js.map