Skip to content
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

fix(py): Removing circular dependencies on Genkit in Plugin API #2041

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kirgrim
Copy link
Contributor

@kirgrim kirgrim commented Feb 20, 2025

Description:

  • unchained registry from veneer, making it standalone class container
  • removed Genkit Veneer references from Plugin API
  • moved implementation of registering model to Registry

Checklist (if applicable):

@kirgrim kirgrim force-pushed the hrymailo/fix/fixing-circular-import-issue-for-plugin-api branch from 95e3251 to ecdc389 Compare February 20, 2025 10:56
Args:
veneer: requested `genkit.veneer.Genkit` instance
Entrypoint for initializing the plugin instance in Genkit
Returns:
None
"""
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I'm thinking about implementing the initialization here, but leaving _register_model() empty. I would create abstract methods for:

  • register_models()
  • register_indexers()
  • register_retrievers()
  • register_embedders()

and etc

Copy link
Contributor

Choose a reason for hiding this comment

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

Let me try to create the PR with how I see it as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here I'm thinking about implementing the initialization here, but leaving _register_model() empty. I would create abstract methods for:

  • register_models()
  • register_indexers()
  • register_retrievers()
  • register_embedders()

and etc

Idea of making register_model singular is in abstracting a logic of registry attachment. We attach to registry per each model, thus it is still required. But it may make sense to define register_models, although i am afraid not every plugin has multiple models

)
cls.register_action(action=action)

@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the rationale behind using a classmethod here?

Each Genkit instance composes its own registry instance no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is the rationale behind using a classmethod here?

Each Genkit instance composes its own registry instance no?

no, it is defined on the class-level

Copy link
Contributor

Choose a reason for hiding this comment

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

And should we have more than one Genkit class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And should we have more than one Genkit class?

makes no sense - polymorphic behaviour will be granted by the plugins api

@kirgrim kirgrim requested review from yesudeep and Irillit February 21, 2025 02:48
@kirgrim kirgrim force-pushed the hrymailo/fix/fixing-circular-import-issue-for-plugin-api branch from ecdc389 to 92e3b7d Compare February 21, 2025 14:52
@kirgrim kirgrim force-pushed the hrymailo/fix/fixing-circular-import-issue-for-plugin-api branch from 92e3b7d to 508cd50 Compare February 21, 2025 15:21
@kirgrim kirgrim requested review from Irillit and pavelgj February 21, 2025 15:22
@kirgrim
Copy link
Contributor Author

kirgrim commented Feb 21, 2025

@pavelgj please take a look, it seems like we may remove this circular dependency as there is single registry per class. Is it intended/allowed/makes sense to have multiple instances of Genkit veneer instantiated during the runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants