firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to integrate, test, and deploy sophisticated AI features to Firebase or Google Cloud.
Apache License 2.0
607 stars 74 forks source link

[JS] Retrieve function not working as expected #212

Closed Champkinz closed 3 months ago

Champkinz commented 3 months ago

Describe the bug When i try to follow the documentation on the Firebase genkit plugin, i get the below error

The code to use:

const docs = await retrieve({
  retriever: yourRetrieverRef,
  query: 'look for something',
  config: { limit: 5 },
});

The error:

Cannot read properties of undefined (reading 'where') TypeError: Cannot read properties of undefined (reading 'where') at /Users/abc/abc/abc/abc/ai-functions/node_modules/@genkit-ai/firebase/lib/firestoreRetriever.js:110:35 at Generator.next () at fulfilled (/Users/abc/abc/abc/abc/ai-functions/node_modules/@genkit-ai/firebase/lib/firestoreRetriever.js:33:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

To Reproduce

Expected behavior

Runtime (please complete the following information):

Node version

Additional context So the correct way to use this by passing the below code, instead of whats shown on the documentation

const docs = await retrieve({
  retriever: yourRetrieverRef,
  query: 'look for something',
  options: { limit: 5 },
});

i just want to know if the documentation is wrong in this scenario or am i doing something wrong ?

ssbushi commented 3 months ago

Hi @Champkinz

Thanks for catching this bug -- you're right, this is a bug in the documentation, the correct field name for retriever options should be options. Do you still run into this issue after applying the above fix?

pavelgj commented 3 months ago

The fix is now released in 0.5.1, please give it another try.

Champkinz commented 3 months ago

Hi @Champkinz

Thanks for catching this bug -- you're right, this is a bug in the documentation, the correct field name for retriever options should be options. Do you still run into this issue after applying the above fix?

Yes, when i add options it works fine.

Thank you for the release.