php-llm-agent/lib/actions/action.sample.php
Frederico @ VilaRosa02 436e0e57c5 new version
2025-09-10 11:40:03 +00:00

31 lines
642 B
PHP

<?php
/**
* SAMPLE ACTION: Say Hello
* -------------------------
* Demonstrates how to register and implement a simple action.
*
* Call format:
* @sayHello Alice 30
*
* Expected output:
* "Hello Alice, you are 30 years old!"
*/
// 1. Register the action with expected argument types
registerAction(
(new Action())
->setFunctionName("sayHello")
->setArgumentsTypes(["name", "age"]) // name, age
);
/**
* 2. Implement the function
*
* @param string $name
* @param int $age
* @return string
*/
function sayHello(string $name, int $age): string {
return "Hello $name, you are $age years old!";
}