PHP code example of cognesy / agents
1. Go to this page and download the library: Download cognesy/agents 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/ */
cognesy / agents example snippets
use Cognesy\Agents\AgentLoop;
use Cognesy\Agents\Data\AgentState;
$agent = AgentLoop::default();
$state = AgentState::empty()->withUserMessage('What is 2+2?');
$result = $agent->execute($state);
echo $result->finalResponse()->toString();
use Cognesy\Agents\Builder\AgentBuilder;
use Cognesy\Agents\Capability\Coding\UseCodingTools;
use Cognesy\Agents\Capability\Prompt\UseSystemPrompt;
use Cognesy\Agents\Data\AgentState;
$workDir = '/path/to/project';
$agent = AgentBuilder::base()
->withCapability(new UseCodingTools($workDir))
->withCapability(new UseSystemPrompt(
preamble: 'You are an expert coding assistant.',
))
->build();
$state = AgentState::empty()
->withUserMessage('Inspect the project and make the requested change.');
$result = $agent->execute($state);