ChrisM
ChrisM2w ago

RAG Filter name location is not valid

Hello, In the Document of the RAG component it is statet that not every filter needs to be present when creating a RAG entry. However I came across this in my add where i need to either add no filter values or all of them as undefined or with value. When adding just one filterValues i get : Filter name location is not valid (one of spotId, location, category) This is my RAG setup:
import { RAG } from '@convex-dev/rag';
import { components } from '../_generated/api';
import { textEmbedding } from '../models';

type FilterTypes = {
location?: {
latitude: number;
longitude: number;
} | undefined;
spotId?: string | undefined;
category?: 'spot' | undefined;
};

export type Filter =
| { name: 'location'; value: { latitude: number; longitude: number } | undefined }
| { name: 'spotId'; value: string | undefined }
| { name: 'category'; value: 'spot' | undefined };

export const rag = new RAG<FilterTypes>(components.rag, {
textEmbeddingModel: textEmbedding,
embeddingDimension: 1536,
filterNames: ['spotId', 'location', 'category'],
});
import { RAG } from '@convex-dev/rag';
import { components } from '../_generated/api';
import { textEmbedding } from '../models';

type FilterTypes = {
location?: {
latitude: number;
longitude: number;
} | undefined;
spotId?: string | undefined;
category?: 'spot' | undefined;
};

export type Filter =
| { name: 'location'; value: { latitude: number; longitude: number } | undefined }
| { name: 'spotId'; value: string | undefined }
| { name: 'category'; value: 'spot' | undefined };

export const rag = new RAG<FilterTypes>(components.rag, {
textEmbeddingModel: textEmbedding,
embeddingDimension: 1536,
filterNames: ['spotId', 'location', 'category'],
});
I then cannot do something like this:
const filterValues: Filter[] = [];
filterValues.push({ name: 'spotId', value: args.spotId });

await rag.add(ctx, {
namespace: 'global',
title: args.title,
key: args.title,
filterValues,
text: args.text,
});
const filterValues: Filter[] = [];
filterValues.push({ name: 'spotId', value: args.spotId });

await rag.add(ctx, {
namespace: 'global',
title: args.title,
key: args.title,
filterValues,
text: args.text,
});
Leaving filterValues out works though. Looking forward to a resolution to this! Best regards Chris
1 Reply
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!

Did you find this page helpful?