1. Go to this page and download the library: Download caiquebispo/ai-agents-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
caiquebispo / ai-agents-php example snippets
//Load the .env file
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
// Create a new chat model
$chat = new \CaiqueBispo\AiAgentsPHP\ChatModels\ChatGPT();
// Create a new agent
$agent = new \CaiqueBispo\AiAgentsPHP\Agents\TestingAgent($chat);
$agent->ask("Hello, is this working?"); // Yes, I am here. How can I help you today?
class TestingAgent extends BaseAgent {
use \CaiqueBispo\AiAgentsPHP\AgentTraits\MathTrait; // Access to math functions
public string $prePrompt = "You are a helpful assistant"; // Pre-prompt
}
/**
* @param int $a
* @param int $b
* @return int
* @aiagent-description Adds two numbers
*/
public function add(int $a, int $b): int {
return $a + $b;
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.