Skip to content

refactor: introduce model capabilities with generic base model instead of interfaces with supportsX methods #305

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

Closed
wants to merge 1 commit into from

Conversation

chr-hertel
Copy link
Member

@chr-hertel chr-hertel commented May 12, 2025

Idea is to make it possible to use models from more generic model providers like huggingface, replicate, and more with chain as well and configure the capabilities via provided classes instead of interfaces.

besides having a generic model that you can basically configure like you want, it introduces a new way of defining specific models in a bridge, e.g.

class DallE extends Model
{
    public const DALL_E_2 = 'dall-e-2';
    public const DALL_E_3 = 'dall-e-3';

    /** @param array<string, mixed> $options The default options for the model usage */
    public function __construct(string $name = self::DALL_E_2, array $options = [])
    {
        $capabilities = [
            Capability::INPUT_TEXT,
            Capability::OUTPUT_IMAGE,
        ];

        parent::__construct($name, $capabilities, $options);
    }
}

@chr-hertel chr-hertel added the BC BREAK Backwards compatibility break label May 12, 2025
@chr-hertel chr-hertel requested a review from OskarStark May 12, 2025 21:15
@chr-hertel
Copy link
Member Author

chr-hertel commented May 12, 2025

one question would be if we want to differentiate between three kinds of capabilities:

  • input capabilities, e.g. supports text or audio
  • output capabilities, e.g. support images
  • functional capabilities, e.g. supports tool calling

🤔

like openai does it
image

@chr-hertel chr-hertel force-pushed the refactor-capabilities branch 2 times, most recently from 9430b51 to e7faba1 Compare May 18, 2025 14:39
@chr-hertel chr-hertel force-pushed the refactor-capabilities branch 4 times, most recently from 4c2fa37 to 964e4a8 Compare May 26, 2025 21:33
@chr-hertel chr-hertel force-pushed the refactor-capabilities branch from 964e4a8 to e7a5702 Compare May 29, 2025 13:43
@chr-hertel
Copy link
Member Author

closed in favor of #326

@chr-hertel chr-hertel closed this May 29, 2025
chr-hertel added a commit that referenced this pull request Jun 1, 2025
- [x] Introducing global model class to be more agnostic with explicit
`Capability` class
- [x] Introducing Contract with Normalizers to solve Base Contract
(OpenAI) vs. Model/Platform specific differences
- [x] Reshape into three major components `Chain`, `Platform` and
`Store`
- [x] Adoption of Symfony-style for CS Fixer and `Interface` &
`Exception` suffix

Replaces #301 and #305 

# Breaking Changes
* Sorting into three main sub compontents `Platform`, `Chain` and
`Store`
* High level implementation also went into those components, see
`ChainInterface` as example
  * `Model` namespace went into `Platform`
  * Bridges got sorted into `Platform` or `Store`
  * Tool metadata moved from `Chain` to `Platform\Contract` 
* Implementation of `JsonSerializable` was dropped in favor of Symfony's
serializer/normalizer
* Removal of `LanguageModel` and `EmbeddingsModel` interface in favor of
base `Model` and `Capabilities`
* Renaming of `StructuredResponse` to `ObjectResponse` 
* Slimming down the `supports()` method of `ModelClient` and
`ResponseConverter`
* Changing signature of `ModelClient` to already accepting the
normalized request payload
* Renaming interfaces to always contain the `Interface` suffix
* Renaming exceptions to always contain the `Exception` suffix
chr-hertel added a commit that referenced this pull request Jun 1, 2025
- [x] Introducing global model class to be more agnostic with explicit
`Capability` class
- [x] Introducing Contract with Normalizers to solve Base Contract
(OpenAI) vs. Model/Platform specific differences
- [x] Reshape into three major components `Chain`, `Platform` and
`Store`
- [x] Adoption of Symfony-style for CS Fixer and `Interface` &
`Exception` suffix

Replaces #301 and #305

* Sorting into three main sub compontents `Platform`, `Chain` and
`Store`
* High level implementation also went into those components, see
`ChainInterface` as example
  * `Model` namespace went into `Platform`
  * Bridges got sorted into `Platform` or `Store`
  * Tool metadata moved from `Chain` to `Platform\Contract`
* Implementation of `JsonSerializable` was dropped in favor of Symfony's
serializer/normalizer
* Removal of `LanguageModel` and `EmbeddingsModel` interface in favor of
base `Model` and `Capabilities`
* Renaming of `StructuredResponse` to `ObjectResponse`
* Slimming down the `supports()` method of `ModelClient` and
`ResponseConverter`
* Changing signature of `ModelClient` to already accepting the
normalized request payload
* Renaming interfaces to always contain the `Interface` suffix
* Renaming exceptions to always contain the `Exception` suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC BREAK Backwards compatibility break refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant