Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternative embedding APIs #5

Open
ruckc opened this issue Jun 14, 2023 · 2 comments
Open

Support alternative embedding APIs #5

ruckc opened this issue Jun 14, 2023 · 2 comments

Comments

@ruckc
Copy link

ruckc commented Jun 14, 2023

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",
});
@davidtbo
Copy link

davidtbo commented Jul 3, 2023

I am looking for this as well. My goal is to be able to run a HuggingFace transformer in the background script of a browser plugin with Transformers.js. I would be willing to contribute if pull requests are welcome.

@hamish-later
Copy link

it might also be worth looking into interfacing with the likes of langchain so it can be used there? i know i'd personally get a lot out of that but may be out of scope for what you're planning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants