Skip to content

Support alternative embedding APIs #5

Description

@ruckc

It would be beneficial if the embeddings could be exposed as a interface that is passed in... something like this.

interface Embedder {
  async embedTexts(texts: string[]): Promise<number[][]>
}

This would keep vector storage complexity to a minimum by removing embedTexts, embedTextsFn and all associated logic, and put it behind an interface so its trivial to extend and add custom embedding APIs.

import { VectorStorage, OpenAIEmbeddings } from "vector-storage";

// create embeddings instance
const embedder = new OpenAIEmbeddings("your-openai-api-key");

// Create an instance of VectorStorage
const vectorStore = new VectorStorage(embedder);

// Add a text document to the store
await vectorStore.addText("The quick brown fox jumps over the lazy dog.", {
  category: "example",
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions