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

[Feature Request]: Add dependancy injection mechanism into Tool class #278

Closed
davorrunje opened this issue Dec 23, 2024 · 0 comments · Fixed by #320 or #374
Closed

[Feature Request]: Add dependancy injection mechanism into Tool class #278

davorrunje opened this issue Dec 23, 2024 · 0 comments · Fixed by #320 or #374
Assignees
Labels
enhancement New feature or request

Comments

@davorrunje
Copy link
Collaborator

davorrunje commented Dec 23, 2024

Description:

Dependency Injection (DI) is a design pattern that allows for the decoupling of classes and their dependencies, enabling objects to be passed their required services or dependencies from the outside, rather than constructing them internally. This promotes greater flexibility, modularity, and ease of testing, as well as better management of dependencies.

In the context of the AG2 framework (previously AutoGen), tools are designed to be used by large language models (LLMs) to perform specific tasks. For the framework to be scalable and maintainable, it is essential that these tools support Dependency Injection. Currently, the Tool class does not natively support DI, meaning that developers must manually handle dependencies, leading to tight coupling between tools and their dependencies. This makes the tools harder to modify, extend, and test.

Why Dependency Injection is Important for Tools in AG2 Framework:

  • Flexibility and Modularity: Supporting DI would allow each tool to be more flexible. Developers could easily swap dependencies or add new ones without modifying the core tool logic. This modularity makes it easier to extend and maintain tools as the AG2 framework evolves.

  • Ease of Testing: When dependencies are injected, unit testing becomes much easier. Tools can be tested in isolation by providing mock dependencies, ensuring that they function correctly without requiring complex setup or external systems.

  • Separation of Concerns: DI helps separate concerns, allowing the tool logic to focus solely on its responsibilities. The management of dependencies is delegated to an external system, which reduces the complexity of the tool and enhances its maintainability.

  • Scalability: As the AG2 framework grows, the number and complexity of tools will increase. By supporting DI, the framework will be better equipped to scale without becoming overly complex or difficult to maintain. Developers can manage the growing number of tools and their dependencies in a clean and organized way.

Proposed Changes:

  • Modify the Tool class to allow for the injection of dependencies.
  • Ensure that tools can be initialized with their required dependencies from external sources (e.g., via constructor injection or setter injection).
  • Update documentation and examples to reflect how tools can be configured with injected dependencies.

By implementing Dependency Injection in the Tool class, the AG2 framework will improve in terms of maintainability, testability, and scalability, enabling LLMs to interact with tools more efficiently while ensuring that these tools are easier to evolve and extend over time.

@davorrunje davorrunje added the enhancement New feature or request label Dec 23, 2024
@davorrunje davorrunje added this to ag2 Jan 8, 2025
@davorrunje davorrunje moved this to In Progress in ag2 Jan 8, 2025
@davorrunje davorrunje closed this as completed by moving to Done in ag2 Jan 8, 2025
@davorrunje davorrunje moved this from In Progress to Done in ag2 Jan 8, 2025
@davorrunje davorrunje moved this from Done to In Progress in ag2 Jan 8, 2025
@davorrunje davorrunje reopened this Jan 8, 2025
@davorrunje davorrunje moved this from In Progress to Done in ag2 Jan 8, 2025
@davorrunje davorrunje closed this as completed by moving to Done in ag2 Jan 8, 2025
@davorrunje davorrunje reopened this Jan 8, 2025
@davorrunje davorrunje linked a pull request Jan 8, 2025 that will close this issue
2 tasks
@davorrunje davorrunje moved this from Done to In Progress in ag2 Jan 8, 2025
@davorrunje davorrunje moved this from In Progress to Waiting for merge in ag2 Jan 8, 2025
@github-project-automation github-project-automation bot moved this from Waiting for merge to Done in ag2 Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
2 participants