Skip to content

Conversation

@chr-hertel
Copy link
Member

Q A
Bug fix? no
New feature? yes
Docs? no
Issues
License MIT

Cherry picking php-llm/llm-chain#372

Could fix part of #371 - the question for flexibility.

Why? Messages are given on platform calls and are given with the
`MessageInterface`. So it is very flexible what could be given on call.
Normalizers are only configured once, internally. So one side is highly
flexible, the other side not.

Giving the contract an interface allows creating own contracts with
whatever backed technology one wants. So more flexible. Additionally it
allows to add a contract that has an amount of normalizers one wants.
For making it easier i thought about having model contract sets. I did
it for anthropic, google and the platform itself.

So a custom contract could look like

```php

use PhpLlm\LlmChain\Platform\Bridge\OpenAI\PlatformFactory;
use PhpLlm\LlmChain\Platform\Contract;

$platform = PlatformFactory::create(
    'my-api-key',
    contract: Contract::create(new MyOwnMessageBagNormalizer(), new MyOwnMessageThingyNormalizer()),
);
```

or, totally flexible:

```php
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\PlatformFactory;

$platform = PlatformFactory::create(
    'my-api-key',
    contract: new MyVeryOwnContractUtilizingJsonStreamer(),
);
```

Maybe this could be a way for more flexibility with the combination of
non configurable normalizer and "unknown" message input?
@chr-hertel chr-hertel requested a review from Nyholm as a code owner July 6, 2025 20:48
@chr-hertel chr-hertel added the Platform Issues & PRs about the AI Platform component label Jul 6, 2025
@chr-hertel chr-hertel merged commit fac418b into main Jul 6, 2025
24 checks passed
@chr-hertel chr-hertel deleted the extendable-contract branch July 6, 2025 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Platform Issues & PRs about the AI Platform component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants