Skip to content

Commit 94074e2

Browse files
committed
Moves env variables into a Spiral Bootloader
1 parent 68894a0 commit 94074e2

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ bootloader.
6666
**Here's how:**
6767

6868
1. Open up your `app/src/Application/Kernel.php` file.
69-
2. In the `defineBootloaders()` method, add the bootloader like this:
69+
2. Add the bootloader like this:
7070
```php
7171
public function defineBootloaders(): array
7272
{
7373
return [
7474
// ... other bootloaders ...
75-
\LLM\Agents\Agent\SiteStatusChecker\Bootloader\SiteStatusCheckerBootloader::class,
75+
\LLM\Agents\Agent\SiteStatusChecker\Integrations\Spiral\SiteStatusCheckerBootloader::class,
7676
];
7777
}
7878
```
7979

80-
And that's it! Your Spiral app is now ready to use the Site Status Checker Agent.
80+
And that's it! Your Spiral app is now ready to use the agent.
8181

8282
## Want to help out? 🤝
8383

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"license": "MIT",
55
"require": {
66
"php": "^8.3",
7-
"llm-agents/agents": "^1.0",
8-
"spiral/boot": "^3.13"
7+
"llm-agents/agents": "^1.0"
98
},
109
"require-dev": {
11-
"phpunit/phpunit": "^11.3"
10+
"phpunit/phpunit": "^11.3",
11+
"spiral/boot": "^3.13"
1212
},
1313
"autoload": {
1414
"psr-4": {

src/Bootloader/SiteStatusCheckerBootloader.php renamed to src/Integrations/Spiral/SiteStatusCheckerBootloader.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,36 @@
22

33
declare(strict_types=1);
44

5-
namespace LLM\Agents\Agent\SiteStatusChecker\Bootloader;
5+
namespace LLM\Agents\Agent\SiteStatusChecker\Integrations\Spiral;
66

77
use LLM\Agents\Agent\AgentRegistryInterface;
88
use LLM\Agents\Agent\SiteStatusChecker\CheckSiteAvailabilityTool;
99
use LLM\Agents\Agent\SiteStatusChecker\GetDNSInfoTool;
1010
use LLM\Agents\Agent\SiteStatusChecker\PerformPingTestTool;
11+
use LLM\Agents\Agent\SiteStatusChecker\SiteStatusCheckerAgent;
1112
use LLM\Agents\Agent\SiteStatusChecker\SiteStatusCheckerAgentFactory;
1213
use LLM\Agents\Tool\ToolRegistryInterface;
1314
use Spiral\Boot\Bootloader\Bootloader;
15+
use Spiral\Boot\EnvironmentInterface;
1416

1517
final class SiteStatusCheckerBootloader extends Bootloader
1618
{
1719
public function boot(
1820
AgentRegistryInterface $agents,
1921
ToolRegistryInterface $tools,
2022
SiteStatusCheckerAgentFactory $siteStatusCheckerAgentFactory,
23+
EnvironmentInterface $env,
2124
): void {
22-
$agents->register($siteStatusCheckerAgentFactory->create());
25+
$agents->register(
26+
$siteStatusCheckerAgentFactory->create(
27+
$env->get('SITE_STATUS_CHECKER_MODEL', SiteStatusCheckerAgent::DEFAULT_MODEL),
28+
),
29+
);
2330

2431
$tools->register(
2532
new CheckSiteAvailabilityTool(),
2633
new GetDNSInfoTool(),
27-
new PerformPingTestTool()
34+
new PerformPingTestTool(),
2835
);
2936
}
3037
}

src/SiteStatusCheckerAgentFactory.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66

77
use LLM\Agents\Agent\AgentFactoryInterface;
88
use LLM\Agents\Agent\AgentInterface;
9-
use Spiral\Boot\EnvironmentInterface;
109

1110
final readonly class SiteStatusCheckerAgentFactory implements AgentFactoryInterface
1211
{
13-
public function __construct(
14-
private EnvironmentInterface $env,
15-
) {}
16-
17-
public function create(): AgentInterface
12+
public function create(string $model = SiteStatusCheckerAgent::DEFAULT_MODEL): AgentInterface
1813
{
1914
return SiteStatusCheckerAgent::create(
20-
model: $this->env->get('SITE_STATUS_CHECKER_MODEL', SiteStatusCheckerAgent::DEFAULT_MODEL),
15+
model: $model,
2116
);
2217
}
2318
}

0 commit comments

Comments
 (0)