langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
35.67k stars 4.24k forks source link

Plugins not picked up #4776

Open ar-or opened 4 days ago

ar-or commented 4 days ago

Bug Description

Plugins in services/plugins are ignored

Reproduction

  1. Create a file my_plugin.py with the content below (or in fact any content)
  2. Put it into services/plugins/
  3. Start the application
  4. Observe the code in the plugin not being executed. Neither global code in the file, nor class instantiated

Expected behavior

Plugin code executed

Who can help?

@italojohnny

Operating System

ubuntu docker

Langflow Version

1.1.0

Python Version

3.12

Screenshot

No response

Flow File

from loguru import logger
from langflow.services.plugins.base import BasePlugin, CallbackPlugin

logger.info("plugin loaded")

class MyPlugin(BasePlugin):
    def initialize(self) -> None:
        logger.info('initialize')

    def teardown(self) -> None:
        logger.info('teardown')

    def get(self):
        logger.info('get')

    def get_callback(self, _id: str | None = None):
        logger.debug("Initializing callback")
        return None
dosubot[bot] commented 4 days ago

To ensure that your plugin in Langflow is recognized and executed, you should verify the following:

  1. File Placement: Make sure your my_plugin.py file is correctly placed in the services/plugins directory. The PluginService class is responsible for loading plugins from this directory, so the file must be in the correct location.

  2. File Naming: Ensure that your plugin file is not named base.py, service.py, factory.py, or __init__.py, as these files are skipped during the plugin loading process [1].

  3. Class Definition: Your plugin class should be a subclass of BasePlugin and not be CallbackPlugin or BasePlugin itself. The PluginService looks for classes that are subclasses of BasePlugin to instantiate and register them [1].

  4. Error Logs: Check the logs for any error messages. Langflow uses the loguru logger to output error messages if there are issues loading a plugin. This can provide insights into what might be going wrong [1].

  5. Python Version: Ensure compatibility with the Python version you are using. While your setup mentions Python 3.12, verify that all dependencies and the Langflow version you are using are compatible with this Python version.

If all these conditions are met and the issue persists, reviewing the logs for any specific error messages during the plugin loading process can help identify the problem.

To continue talking to Dosu, mention @dosu.

italojohnny commented 1 day ago

Hello friend, how are you?

The plugin concept became obsolete as Langflow evolved, and we stopped using it. To prevent others from mistakenly attempting to use the plugin service, I created this PR #4826 to remove all the code related to it.

ar-or commented 1 day ago

That's actually disappointing, because there is no other way to expand langflow's global functionality without building it from source code, and even that wouldn't guarantee forward compatibility.

italojohnny commented 13 hours ago

Could you describe how you used this feature? Maybe I can help you find other ways to achieve your goals or even brainstorm new features for Langflow.