<?php
use Cognesy\Addons\FunctionCall\FunctionCallFactory;
use Cognesy\Instructor\StructuredOutput;
class DataStore {
/** Save user data to storage */
public function saveUser(string $name, int $age, string $country) {
// ...
}
}
$text = "His name is Jason, he is 28 years old and he lives in Germany.";
$args = (new StructuredOutput)->with(
messages: $text,
responseModel: FunctionCallFactory::fromMethodName(Datastore::class, 'saveUser'),
)->get();
// call the function with the extracted arguments
(new DataStore)->saveUser(...$args);
?>
// @doctest id="b86e"