-
Notifications
You must be signed in to change notification settings - Fork 46
Description
What motivated you to submit this feature request?
Currently the types with-in the SDK are super limited. In addition in real-time / run time there isn't any additional schema validation for metadata fields.
The object type is used all over and can actually create a symblence of safety that is not accurate and doesn't exist.
It would be truly type-safe to use something like unknown that doesn't provide a false sense of (type) safety 😆
Describe the solution you'd like
Integrate with a schema lib i.e. zod or a general use one i.e. typeschema/xsschema.
Use that to enforce the types at run time and in addition provide true type-safety.
i.e.
const FoobarSchema = z.object({ ... });
const idx = pinecone.getIndex('foobar', { schema: FoobarSchema })Describe alternatives you've considered
I already created an internal wrapper:
import { z } from 'zod';
import { defineIndex } from '../core/pinecone-index';
export default defineIndex({
name: 'github-content',
fields: {
text: 'content',
},
schema: z.object({
ownerId: z.number(),
owner: z.string(),
repoId: z.number(),
repo: z.string(),
path: z.string(),
extension: z.string(),
content: z.string(),
}),
filters: z.object({
ownerId: z.number(),
repoId: z.number(),
}),
model: 'llama-text-embed-v2',
});This by default is injecting some type-safety for a handful of the functions but it seems a bit heavy when we could integrate directly into pinecone native
Additional context
My main use case is integrating with VoltAgent (I'm a core contributor) and using with-in our agents & workflows.
I'm happy to take a stab at this but only if its of interest to the pinecone team.