Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

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

@carsonbot carsonbot added Status: Needs Review Bug Something isn't working labels Aug 29, 2025
@carsonbot carsonbot changed the title Fix Anthropic definition Fix Anthropic definition Aug 29, 2025
@VincentLanglet
Copy link
Contributor Author

@Krystopher88 could you try this and confirm it solves your issue ?

@VincentLanglet VincentLanglet changed the title Fix Anthropic definition Fix Anthropic platform definition Aug 29, 2025
@OskarStark OskarStark added the Platform Issues & PRs about the AI Platform component label Aug 29, 2025
@carsonbot carsonbot changed the title Fix Anthropic platform definition [Platform] Fix Anthropic platform definition Aug 29, 2025
@OskarStark OskarStark added the AI Bundle Issues & PRs about the AI integration bundle label Aug 29, 2025
@carsonbot carsonbot changed the title [Platform] Fix Anthropic platform definition [AI Bundle][Platform] Fix Anthropic platform definition Aug 29, 2025
HttpClientInterface $httpClient,
#[\SensitiveParameter] private string $apiKey,
private string $version = '2023-06-01',
private ?string $version = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform is doing

new ModelClient($httpClient, $apiKey, $version)

Which means that, either

  • It has to know the default value, so $version = '2023-06-01', is duplicated
  • It requires the logic
null === $version ? new ModelClient($httpClient, $apiKey) : new ModelClient($httpClient, $apiKey, $version);

Also, since I needed to pass the platform version in the AiBundle config, I didn't want to pass

$platform['version'] ?? '2023-06-01',

with the version hard coded a third time.

#[\SensitiveParameter]
string $apiKey,
string $version = '2023-06-01',
?string $version = null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving this parameter at the end instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a solution.

But still I'm unsure it a nice pattern to duplicate the default value '2023-06-01' between the factory and the Model, no ?

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for jumping on that @VincentLanglet!
I'm usually not a huge fan of nullable arguments, and it's true that this is a bit weird in handling and duplicated here.

One thing I noticed when looking at the Anthropics docs again: there are only two version strings at this point 2023-01-01 and the 2023-06-01 we're currently using. and guess what, only one is supported by our implementation here anyways. with 2023-01-01 you get the error "anthropic-version: "2023-01-01" not allowed for this endpoint" error.

So, if you're up for it, let's just clean that up, remove all arguments, the bundle config option and hard code the version in the header: 'anthropic-version' => '2023-06-01' - easier and we don't have to debate the nullable and where not to duplicate stuff 😆

@OskarStark
Copy link
Contributor

Please fix PHPStan, thanks

@OskarStark
Copy link
Contributor

Thanks for fixing this bug Vincent.

@OskarStark OskarStark merged commit 70bc6b5 into symfony:main Aug 30, 2025
7 checks passed
@chr-hertel
Copy link
Member

@OskarStark saw my comment? any thoughts on that?

@OskarStark
Copy link
Contributor

You mean regarding the defaults? Mixed feelings, as if there is a new version, you can only use it with a new release of the lib, like for the models

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Bundle Issues & PRs about the AI integration bundle Bug Something isn't working Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid constructor argument 3 for service "ai.platform.anthropic": argument 2 must be defined before in dev-main

5 participants