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]: Factory #894

Open
7 tasks
3rd-Son opened this issue Dec 9, 2024 · 0 comments
Open
7 tasks

[Feature Request]: Factory #894

3rd-Son opened this issue Dec 9, 2024 · 0 comments

Comments

@3rd-Son
Copy link
Contributor

3rd-Son commented Dec 9, 2024

Feature Name

IFactory, FactoryBase, Factory (non-recursive), AgentFactory (class-specific), and a factory method on ComponentBase (recursive)

Feature Description

This feature introduces a flexible factory system to streamline the creation and management of various components within the SDK. It includes:

  • IFactory: An interface defining core methods for factories.
  • FactoryBase: A base class providing default behaviors for common factory operations.
  • Factory (non-recursive): A simple factory implementation that supports straightforward instantiation without recursion.
  • AgentFactory: A class-specific factory for creating agent instances, tailored to their unique requirements.
  • Factory Method on ComponentBase (recursive): A recursive factory implementation leveraging Pydantic's model_validate for validating and initializing components from JSON or other payloads.

This feature ensures consistent and efficient creation of components while accommodating diverse use cases, such as agents, parsers, and other MAS elements.

Motivation

Factories are essential for encapsulating object creation logic, reducing duplication, and improving modularity. This feature will:

  • Provide a unified pattern for creating components dynamically.
  • Simplify the instantiation process for complex components requiring validation or specific configurations.
  • Enable easier integration of new component types into the MAS framework.
  • Ensure compatibility with Pydantic for schema validation, improving robustness.

Potential Solutions

  1. Interface and Base Class Design:
  • Define IFactory with methods like create and register.
  • Implement common behaviours in FactoryBase, such as caching or registry management.
  1. Concrete Implementations:
  • Factory (non-recursive): Focus on simple object creation with no dependency resolution.
  • AgentFactory: Extend FactoryBase for class-specific requirements, like initializing agents with predefined configurations.
  1. Testing:
  • Test non-recursive and recursive factory behaviors separately.
  • Validate correct instantiation of agents and other components.

Additional Context (optional)

No response

Affected Areas

None

Priority

Low

Required Files

  • Test File
  • Component File
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant