You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -192,6 +192,30 @@ $imageMessage = new Image($imageBinaryContent);
192
192
$mimeType = $imageMessage->getMimeType(); // Get the MIME type of the image
193
193
```
194
194
195
+
## Schema and Schema Objects
196
+
197
+
You can use the `Schema` class to define a schema for a structured output. The `Schema` class utilizes `SchemaObject`s to define each property of the schema, following the [JSON Schema](https://json-schema.org/) format.
198
+
199
+
```php
200
+
use Utopia\Agents\Schema\Schema;
201
+
use Utopia\Agents\Schema\SchemaObject;
202
+
203
+
$object = new SchemaObject();
204
+
$object->addProperty('location', [
205
+
'type' => SchemaObject::TYPE_STRING,
206
+
'description' => 'The city and state, e.g. San Francisco, CA',
207
+
]);
208
+
209
+
$schema = new Schema(
210
+
name: 'get_weather',
211
+
description: 'Get the current weather in a given location in well structured JSON',
212
+
object: $object,
213
+
required: $object->getNames()
214
+
);
215
+
216
+
$agent->setSchema($schema);
217
+
```
218
+
195
219
## Tests
196
220
197
221
To run all unit tests, use the following Docker command:
0 commit comments