Skip to content

Commit

Permalink
Adds new agent - symfony-console
Browse files Browse the repository at this point in the history
Some fixes in chat command
  • Loading branch information
butschster committed Sep 4, 2024
1 parent eff218d commit 1cb1794
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/public/storage
/storage/*.key
/vendor
composer.lock
.env
.env.backup
.env.production
Expand Down
41 changes: 30 additions & 11 deletions app/Chat/SimpleChatService.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ public function startSession(UuidInterface $accountUuid, string $agentName): Uui
'title' => $agent->getDescription(),
]);

$session->save();

return $session->getUuid();
}

Expand Down Expand Up @@ -189,17 +187,38 @@ private function callTool(SessionInterface $session, ToolCall $tool): ToolCallRe
),
);

$functionResult = $this->toolExecutor->execute($tool->name, $tool->arguments);
try {
$functionResult = $this->toolExecutor->execute($tool->name, $tool->arguments);

$this->eventDispatcher?->dispatch(
new \LLM\Agents\Chat\Event\ToolCallResult(
sessionUuid: $session->getUuid(),
$this->eventDispatcher?->dispatch(
new \LLM\Agents\Chat\Event\ToolCallResult(
sessionUuid: $session->getUuid(),
id: $tool->id,
tool: $tool->name,
result: $functionResult,
createdAt: new \DateTimeImmutable(),
),
);
} catch (\Throwable $e) {
$this->eventDispatcher?->dispatch(
new \LLM\Agents\Chat\Event\ToolCallResult(
sessionUuid: $session->getUuid(),
id: $tool->id,
tool: $tool->name,
result: \json_encode([
'error' => $e->getMessage(),
]),
createdAt: new \DateTimeImmutable(),
),
);

return new ToolCallResultMessage(
id: $tool->id,
tool: $tool->name,
result: $functionResult,
createdAt: new \DateTimeImmutable(),
),
);
content: [
$e->getMessage(),
],
);
}

return new ToolCallResultMessage(
id: $tool->id,
Expand Down
2 changes: 1 addition & 1 deletion app/Models/ValueObject/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use LLM\Agents\LLM\Prompt\Chat\Prompt;
use Traversable;

final class History implements \IteratorAggregate
final class History implements \IteratorAggregate, \JsonSerializable
{
public static function fromString(string $value): self
{
Expand Down
1 change: 1 addition & 0 deletions bootstrap/providers.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
App\Providers\SmartHomeServiceProvider::class,
App\Providers\AgentsServiceProvider::class,
App\Providers\AgentsChatServiceProvider::class,
LLM\Agents\Agent\SymfonyConsole\Integrations\Laravel\SymfonyConsoleServiceProvider::class,
];
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"require": {
"php": "^8.2",
"laravel/framework": "^11.9",
"llm-agents/agent-site-status-checker": "^1.0",
"llm-agents/agent-symfony-console": "^1.0",
"llm-agents/agents": "^1.1",
"llm-agents/cli-chat": "^1.0",
"llm-agents/json-schema-mapper": "^1.0",
"llm-agents/openai-client": "^1.0",
"llm-agents/agent-site-status-checker": "^1.0",
"openai-php/laravel": "^0.10.1"
},
"require-dev": {
Expand Down
10 changes: 5 additions & 5 deletions config/agents.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@

return [
'agents' => [
CodeReviewAgentFactory::class,
// CodeReviewAgentFactory::class,
DeliveryAgentFactory::class,
SmartHomeControlAgentFactory::class,
TaskSplitterAgentFactory::class,
SiteStatusChecker\SiteStatusCheckerAgentFactory::class,
SiteStatusChecker\SiteStatusCheckerAgentFactory::class,
],
'tools' => [
\App\Agents\AgentsCaller\AskAgentTool::class,

// Code Reviewer
\App\Agents\CodeReviewer\ListProjectTool::class,
\App\Agents\CodeReviewer\ReadFileTool::class,
\App\Agents\CodeReviewer\ReviewTool::class,
// \App\Agents\CodeReviewer\ListProjectTool::class,
// \App\Agents\CodeReviewer\ReadFileTool::class,
// \App\Agents\CodeReviewer\ReviewTool::class,

// Delivery
\App\Agents\Delivery\GetOrderNumberTool::class,
Expand Down

0 comments on commit 1cb1794

Please sign in to comment.