MCPcopy Create free account
hub / github.com/OpenAnonymity/oa-chat / constructor

Method constructor

vector/index.js:71–95  ·  view source on GitHub ↗
(options = {})

Source from the content-addressed store, hash-verified

69
70export class VectorStore {
71 constructor(options = {}) {
72 if (!options.dimension) {
73 throw new Error('VectorStore requires a dimension.');
74 }
75
76 this.name = options.name || 'default';
77 this.dimension = options.dimension;
78 this.metric = normalizeMetric(options.metric);
79 this.normalize = options.normalize ?? (this.metric === 'cosine');
80 this.backendName = typeof options.backend === 'string' ? options.backend : 'custom';
81 this.backend = resolveBackend(options.backend, {
82 ...options,
83 name: this.name,
84 dimension: this.dimension,
85 metric: this.metric,
86 normalize: this.normalize
87 });
88 this.ready = Promise.resolve().then(() => this.backend.init?.({
89 ...options,
90 name: this.name,
91 dimension: this.dimension,
92 metric: this.metric,
93 normalize: this.normalize
94 }));
95 }
96
97 async upsert(items) {
98 await this.ready;

Callers

nothing calls this directly

Calls 3

normalizeMetricFunction · 0.90
resolveBackendFunction · 0.70
initMethod · 0.45

Tested by

no test coverage detected