Skip to content

FAILED_PRECONDITION Error with RAG Implementation #343

@JGSolutions

Description

@JGSolutions

Describe the bug
Implementing a semantic search for board games using Firestore and the RAG implementation with the retriever based from this article
https://firebase.google.com/docs/genkit/plugins/firebase

I did generate vector embeddings for 60K for the Firestore documents and defined a Flow (as below).
When I increase the limit in the retrieve method I always get this error:
FAILED_PRECONDITION: Generation resulted in no candidates matching provided output schema.

If I submit the same prompt with a limit of 5 instead, it works as expected.

To Reproduce

export const boardGameSuggestionFlow = defineFlow(
    {
        name: "boardGameSuggestionFlow",
        inputSchema: z.string(),
        outputSchema: GamesFlowOutput,
    },
    async (query: string) => {
        const docs = await retrieve({
            retriever: retrieverRef,
            query,
            options: {
                limit: 30, ---> This value always getting an error. If set to 5 it works
            },
        });

        const promptDot = await prompt("boardGameSuggestion");
        const result = await promptDot.generate({
            input: {
                query,
            },
            context: docs, // i always get docs response no matter what prompt i request
        });

        const { games } = result.output() as { games: Games[] };

        return games;
    }
);

Expected behavior
Just get the results as expected with the same query

Runtime (please complete the following information):

  • OS: MacOS - latest version
  • genKit 0.5.2

** Node version

  • node version 20.10.0

Additional context
How does the generate() and LLMs work?
Also takes a very long time to get a response. Is there a way to increase performance?

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingjs

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions