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

Chat with non-embedding db #89

Merged
merged 4 commits into from
Nov 1, 2024
Merged

Chat with non-embedding db #89

merged 4 commits into from
Nov 1, 2024

Conversation

CahidArda
Copy link
Contributor

@CahidArda CahidArda commented Oct 30, 2024

Fixes two functionality for usage with non-embedding Vector Index:

  • It was only possible to upsert without data. Vectors without data are not usable in chat. Now it's possible to pass a text with your embedding:
await ragChat.context.addMany([
  {
    id: 1,
    type: "embedding",
    data: [1, 1, 0],
    text: "first embedding", // NEW
    options: { namespace },
  },
  {
    id: 2,
    type: "embedding",
    data: [1, 0, 1],
    text: "second embedding", // NEW
    options: { namespace },
  },
]);

text is added to the data field of the index.

  • adding embedding option in chat to make it possible to query a non-embedding index with your own embedding
await ragChat.chat("hello world!", {
  embedding: [0, 0, 0.5], // NEW
  onContextFetched,
  namespace,
});

Fixes

index.addMany is fixed with Promise.all

Copy link

linear bot commented Oct 30, 2024

async addMany(args: AddContextPayload[] | string[]) {
return args.map((data) => this.add(data));
return Promise.all(args.map((data) => this.add(data)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have a batch option? Why do we do it 1 by 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

presumably it was done to avoid refactoring the save method which formats the AddContextPayload and makes the upsert. To batch in addMany, we would have to split the save method into two and call the first half in addMany.

If would prefer to do this another PR if that's okay with you

@CahidArda CahidArda merged commit 47e0853 into master Nov 1, 2024
10 checks passed
@CahidArda CahidArda deleted the DX-1398 branch November 1, 2024 13:50
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

Successfully merging this pull request may close these issues.

2 participants