-
-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review
Description
I just found a bug which is easy to reproduce with
framework:
serializer:
enabled: true
enable_attributes: true
name_converter: 'serializer.name_converter.camel_case_to_snake_case'And an output class like
class Foo
{
public function __construct(public string $fooBar) {}
}When using
$content = $this->agent->call($messages, [
'response_format' => Foo::class,
])->getContent();The schema is generated using the ReflectionProperty
ai/src/platform/src/Contract/JsonSchema/Factory.php
Lines 87 to 89 in 5e1d943
| $reflection = new \ReflectionClass($className); | |
| return $this->convertTypes($reflection->getProperties()); |
fooBarBut the data is hydrated with the serializer
| : $this->serializer->deserialize($innerResult->getContent(), $this->outputType, 'json'); |
so the serializer name converter is used and it will expect a
foo_bar key instead of fooBar.
Currently the workaround is to do
class Foo
{
public function __construct(
#[SerializedName('fooBar')]
public string $fooBar
) {}
}Any clue on how to fix this ? Maybe the PlatformSubscriber shouldn't rely on the default serialzer of Symfony ?
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't workingPlatformIssues & PRs about the AI Platform componentIssues & PRs about the AI Platform componentStatus: Needs Review