-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAgentsBootloader.php
More file actions
78 lines (65 loc) · 2.77 KB
/
AgentsBootloader.php
File metadata and controls
78 lines (65 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
namespace App\Application\Bootloader;
use App\Application\AgentsLocator;
use App\Application\PythonExecutor;
use App\Application\ToolsLocator;
use App\Domain\Chat\ChatHistoryRepositoryInterface;
use App\Domain\Chat\ChatServiceInterface;
use App\Domain\Chat\SimpleChatService;
use App\Domain\MLQ\AgentPromptGenerator;
use App\Infrastructure\RoadRunner\Chat\ChatHistoryRepository;
use LLM\Agents\Agent\AgentRegistry;
use LLM\Agents\Agent\AgentRegistryInterface;
use LLM\Agents\Agent\AgentRepositoryInterface;
use LLM\Agents\JsonSchema\Mapper\SchemaMapper;
use LLM\Agents\LLM\AgentPromptGeneratorInterface;
use LLM\Agents\LLM\ContextFactoryInterface;
use LLM\Agents\LLM\OptionsFactoryInterface;
use LLM\Agents\OpenAI\Client\ContextFactory;
use LLM\Agents\OpenAI\Client\OptionsFactory;
use LLM\Agents\Tool\SchemaMapperInterface;
use LLM\Agents\Tool\ToolExecutor;
use LLM\Agents\Tool\ToolLanguage;
use LLM\Agents\Tool\ToolRegistry;
use LLM\Agents\Tool\ToolRegistryInterface;
use LLM\Agents\Tool\ToolRepositoryInterface;
use Spiral\Boot\Bootloader\Bootloader;
use Spiral\Cache\CacheStorageProviderInterface;
use Spiral\Tokenizer\TokenizerListenerRegistryInterface;
final class AgentsBootloader extends Bootloader
{
public function defineSingletons(): array
{
return [
ToolRegistry::class => ToolRegistry::class,
ToolRegistryInterface::class => ToolRegistry::class,
ToolRepositoryInterface::class => ToolRegistry::class,
ToolExecutor::class => ToolExecutor::class,
AgentRegistry::class => AgentRegistry::class,
AgentRegistryInterface::class => AgentRegistry::class,
AgentRepositoryInterface::class => AgentRegistry::class,
ChatServiceInterface::class => SimpleChatService::class,
OptionsFactoryInterface::class => OptionsFactory::class,
ContextFactoryInterface::class => ContextFactory::class,
AgentPromptGeneratorInterface::class => AgentPromptGenerator::class,
SchemaMapperInterface::class => SchemaMapper::class,
ChatHistoryRepositoryInterface::class => static fn(
CacheStorageProviderInterface $cache,
): ChatHistoryRepositoryInterface => new ChatHistoryRepository(
$cache->storage('chat-messages'),
),
];
}
public function init(
TokenizerListenerRegistryInterface $listenerRegistry,
ToolsLocator $toolsLocator,
AgentsLocator $agentsLocator,
ToolExecutor $toolExecutor,
PythonExecutor $pythonExecutor,
): void {
$toolExecutor->register(ToolLanguage::Python, $pythonExecutor);
$listenerRegistry->addListener($agentsLocator);
$listenerRegistry->addListener($toolsLocator);
}
}