Repository navigation
Return raw response from schema #55
Replies: 3 comments 3 replies
|
For a dynamic schema you should not need to map every enum to a PHP enum class. In current So a plain JSON Schema enum should look like this: $schema = [
'type' => 'object',
'properties' => [
'status' => [
'type' => 'string',
'enum' => ['draft', 'published'],
],
],
'required' => ['status'],
'additionalProperties' => false,
];
$result = $instructor->request(
input: $prompt,
responseModel: $schema,
model: $model,
);
$array = $result instanceof \Cognesy\Dynamic\Structure
? $result->toArray()
: (array) $result;I would check two things:
If you actually want PHP enum hydration, then |
|
@krotname Now I have the newest version, but I get exception: Is a template engine mandatory when I only want to get the raw array response? |
|
2.5.0 will be released today - it makes things even simpler and cleaner |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have a question. I have a json schema, which I'm sending via parameter "responseModel" like:
As my schema is dynamic from the database, I cannot map it to a certain class. I just want to have the chat response as array and store it as JSON. I'm using enum's in the schema. I always get the Exception:
Exception: Enum must have x-php-class field with the target class name
Does anyone know how I can handle this? I just want to have the JSON response as array :)
Thx & BR,
Alex
All reactions