-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explicit return types for plugins that define models, etc #397
Conversation
@@ -120,7 +122,7 @@ export function chromaRetriever< | |||
createCollectionIfMissing?: boolean; | |||
embedder: EmbedderArgument<EmbedderCustomOptions>; | |||
embedderOptions?: z.infer<EmbedderCustomOptions>; | |||
}) { | |||
}): RetrieverAction<z.ZodOptional<typeof ChromaRetrieverOptionsSchema>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a little funky to me. Should we just make this ChromaRetrieverOptionsSchema
?
It looks like we're possibly double-wrapping in an Optional? https://github.com/firebase/genkit/blob/main/js/ai/src/retriever.ts#L164-L168
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I first made these abstractions in js/ai
, I wanted to make as few assumptions as possible. That meant that the options should not be ZodOptional
since we do not know what kind of retriever they are building and what options are required vs optional.
IMO, the /ai
abstractions should not add a .optional()
on the schema and the providers can add them in the custom schema they define (ChromaRetrieverOptionsSchema
in this case).
That being said, this code has through many changes and its evident that it no longer holds to that thought. The problem here does not seem to be double wrapping though -- there is no Optional on the ChromaRetrieverOptionsSchema
object and it is added by RetrieverAction
.
@@ -185,7 +187,7 @@ export function configurePineconeIndexer< | |||
textKey?: string; | |||
embedder: EmbedderArgument<EmbedderCustomOptions>; | |||
embedderOptions?: z.infer<EmbedderCustomOptions>; | |||
}) { | |||
}): IndexerAction<z.ZodOptional<typeof PineconeIndexerOptionsSchema>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seemed a little funky to me. Should we just make this PineconeIndexerOptionsSchema
?
It looks like we're possibly double-wrapping in an Optional? https://github.com/firebase/genkit/blob/main/js/ai/src/embedder.ts#L74-L78
fd6c532
to
e916bc4
Compare
e916bc4
to
d449594
Compare
@pavelgj friendly ping on this one |
I think this will help folks that want to contribute to the plugins with better type safety. I've seen a few errors go by (or almost go by) related to this.