firebase / genkit

An open source framework for building AI-powered apps with familiar code-centric patterns. Genkit makes it easy to develop, integrate, and test AI features with observability and evaluations. Genkit works with various models and platforms.
Apache License 2.0
812 stars 122 forks source link

[JS] Retrieve function not working as expected #212

Closed Champkinz closed 6 months ago

Champkinz commented 6 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 6 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 6 months ago

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

Champkinz commented 6 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.