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

Add list of hooks and tools when fetching plugins #457

Merged
merged 5 commits into from
Sep 18, 2023

Conversation

zAlweNy26
Copy link
Member

@zAlweNy26 zAlweNy26 commented Sep 18, 2023

Description

In this way, you can visualize in the frontend or from a generic client, the used hooks by each plugin and their priority, for a better understanding of the flow of the plugins you installed. You can also see the tools created by the plugins.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

@pieroit
Copy link
Member

pieroit commented Sep 18, 2023

This is a good idea thanks
What about adding the tools?

@zAlweNy26
Copy link
Member Author

I thought about that too, but... who cares about the tools names? The description of the plugin should already answer a hypothetical question like "how do I trigger this plugin?", or am I wrong?

@zAlweNy26 zAlweNy26 changed the title Add used_hooks when fetching plugins Add used_hooks and used_tools when fetching plugins Sep 18, 2023
@@ -40,6 +40,8 @@ async def get_available_plugins(
# get manifest
manifest = deepcopy(p.manifest) # we make a copy to avoid modifying the plugin obj
manifest["active"] = p.id in active_plugins # pass along if plugin is active or not
manifest["used_hooks"] = [{ "name": hook.name, "priority": hook.priority } for hook in p.hooks]
manifest["used_tools"] = [tool.func.__name__ for tool in p.tools]
Copy link
Member Author

Choose a reason for hiding this comment

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

Also added tools, should the entry be called used_tools, tools or created_tools?

@zAlweNy26
Copy link
Member Author

I was thinking about changing the data structure in this way, where the key is the priority:

{
  "0": ["hook name 1", "hook name 2"],
  "1": ["hook name 3", "hook name 4"]
}

(Suggested by the Cat 😉)

@pieroit
Copy link
Member

pieroit commented Sep 18, 2023

I was thinking about changing the data structure in this way, where the key is the priority:

{
  "0": ["hook name 1", "hook name 2"],
  "1": ["hook name 3", "hook name 4"]
}

(Suggested by the Cat 😉)

The previous was better, because it makes no assumptions on ordering or indexing.
Two keys tools and hooks with a list of dicta inside

@zAlweNy26 zAlweNy26 changed the title Add used_hooks and used_tools when fetching plugins Add list of hooks and tools when fetching plugins Sep 18, 2023
@pieroit pieroit merged commit 8926196 into cheshire-cat-ai:develop Sep 18, 2023
1 check failed
@zAlweNy26 zAlweNy26 deleted the more-plugin-infos branch September 18, 2023 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants