Skip to content

refactor(js/ai): moved generate api into ai package to enable use with middleware#5042

Open
pavelgj wants to merge 4 commits intopj/gm-refactor-pluginsfrom
pj/gm-refactor-generate-api-into-ai
Open

refactor(js/ai): moved generate api into ai package to enable use with middleware#5042
pavelgj wants to merge 4 commits intopj/gm-refactor-pluginsfrom
pj/gm-refactor-generate-api-into-ai

Conversation

@pavelgj
Copy link
Copy Markdown
Member

@pavelgj pavelgj commented Apr 1, 2026

GenkitAI APIs were refactored/moved unchanged into the ai package. This is necessary so that we can pass AI APIs into the middleware at runtime. Imagine usecases like context compression or request classification which require access to llms.

Checklist (if applicable):

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the GenkitAI class to encapsulate core AI functionalities such as embedding, generation, and operation management. The Genkit class has been refactored to extend GenkitAI, inheriting these methods and reducing code duplication across the codebase. Feedback was provided regarding a misleading parameter name in the generateStream method to improve consistency with the generate method and the underlying implementation.

O extends z.ZodTypeAny = z.ZodTypeAny,
CustomOptions extends z.ZodTypeAny = typeof GenerationCommonConfigSchema,
>(
parts:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The parameter name parts is misleading here as the type is GenerateOptions | PromiseLike<GenerateOptions>. It should be renamed to opts or options to match the generate method and the implementation.

Suggested change
parts:
opts:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant