Skip to content

Commit 1133e1d

Browse files
committed
Moves OpenAI client into a separate package
1 parent da3e534 commit 1133e1d

24 files changed

+23
-639
lines changed

app/src/Agents/CodeReviewer/CodeReviewAgent.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use LLM\Agents\Agent\Agent;
88
use LLM\Agents\Agent\AgentAggregate;
9+
use LLM\Agents\OpenAI\Client\OpenAIModel;
10+
use LLM\Agents\OpenAI\Client\Option;
911
use LLM\Agents\Solution\MetadataType;
1012
use LLM\Agents\Solution\Model;
1113
use LLM\Agents\Solution\SolutionMetadata;
@@ -42,12 +44,12 @@ public static function create(): self
4244
),
4345
new SolutionMetadata(
4446
type: MetadataType::Configuration,
45-
key: 'max_tokens',
47+
key: Option::MaxTokens->value,
4648
content: 3000,
4749
),
4850
);
4951

50-
$model = new Model(model: 'gpt-4o-mini');
52+
$model = new Model(model: OpenAIModel::Gpt4oMini->value);
5153
$aggregate->addAssociation($model);
5254

5355
$aggregate->addAssociation(new ToolLink(name: ListProjectTool::NAME));

app/src/Agents/Delivery/DeliveryAgent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use LLM\Agents\Agent\Agent;
99
use LLM\Agents\Agent\AgentAggregate;
1010
use LLM\Agents\Agent\SiteStatusChecker\SiteStatusCheckerAgent;
11+
use LLM\Agents\OpenAI\Client\OpenAIModel;
1112
use LLM\Agents\Solution\AgentLink;
1213
use LLM\Agents\Solution\MetadataType;
1314
use LLM\Agents\Solution\Model;
@@ -77,7 +78,7 @@ public static function create(): self
7778
);
7879

7980
// Add a model to the agent
80-
$model = new Model(model: 'gpt-4o-mini');
81+
$model = new Model(model: OpenAIModel::Gpt4oMini->value);
8182
$aggregate->addAssociation($model);
8283

8384
$aggregate->addAssociation(new ToolLink(name: GetDeliveryDateTool::NAME));

app/src/Agents/SmartHomeControl/SmartHomeControlAgent.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use LLM\Agents\Agent\Agent;
88
use LLM\Agents\Agent\AgentAggregate;
9+
use LLM\Agents\OpenAI\Client\OpenAIModel;
10+
use LLM\Agents\OpenAI\Client\Option;
911
use LLM\Agents\Solution\MetadataType;
1012
use LLM\Agents\Solution\Model;
1113
use LLM\Agents\Solution\SolutionMetadata;
@@ -50,7 +52,7 @@ public static function create(): self
5052

5153
new SolutionMetadata(
5254
type: MetadataType::Configuration,
53-
key: 'max_tokens',
55+
key: Option::MaxTokens->value,
5456
content: 3000,
5557
),
5658

@@ -86,7 +88,7 @@ public static function create(): self
8688
),
8789
);
8890

89-
$model = new Model(model: 'gpt-4o-mini');
91+
$model = new Model(model: OpenAIModel::Gpt4oMini->value);
9092
$aggregate->addAssociation($model);
9193

9294
$aggregate->addAssociation(new ToolLink(name: ListRoomDevicesTool::NAME));

app/src/Agents/TaskSplitter/TaskSplitterAgent.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use LLM\Agents\Agent\Agent;
88
use LLM\Agents\Agent\AgentAggregate;
9+
use LLM\Agents\OpenAI\Client\OpenAIModel;
10+
use LLM\Agents\OpenAI\Client\Option;
911
use LLM\Agents\Solution\MetadataType;
1012
use LLM\Agents\Solution\Model;
1113
use LLM\Agents\Solution\SolutionMetadata;
@@ -46,12 +48,12 @@ public static function create(): self
4648
),
4749
new SolutionMetadata(
4850
type: MetadataType::Configuration,
49-
key: 'max_tokens',
51+
key: Option::MaxTokens->value,
5052
content: 3000,
5153
),
5254
);
5355

54-
$model = new Model(model: 'gpt-4o-mini');
56+
$model = new Model(model: OpenAIModel::Gpt4oMini->value);
5557
$aggregate->addAssociation($model);
5658

5759
$aggregate->addAssociation(new ToolLink(name: TaskCreateTool::NAME));

app/src/Application/Bootloader/AgentsBootloader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
use App\Domain\Chat\SimpleChatService;
1212
use App\Domain\MLQ\AgentPromptGenerator;
1313
use App\Domain\Tool\SchemaMapper;
14-
use App\Infrastructure\OpenAI\ContextFactory;
15-
use App\Infrastructure\OpenAI\OptionsFactory;
1614
use App\Infrastructure\RoadRunner\Chat\ChatHistoryRepository;
1715
use LLM\Agents\Agent\AgentRegistry;
1816
use LLM\Agents\Agent\AgentRegistryInterface;
1917
use LLM\Agents\Agent\AgentRepositoryInterface;
2018
use LLM\Agents\LLM\AgentPromptGeneratorInterface;
2119
use LLM\Agents\LLM\ContextFactoryInterface;
2220
use LLM\Agents\LLM\OptionsFactoryInterface;
21+
use LLM\Agents\OpenAI\Client\ContextFactory;
22+
use LLM\Agents\OpenAI\Client\OptionsFactory;
2323
use LLM\Agents\Tool\SchemaMapperInterface;
2424
use LLM\Agents\Tool\ToolRegistry;
2525
use LLM\Agents\Tool\ToolRegistryInterface;

app/src/Application/Bootloader/Infrastructure/OpenAIBootloader.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

app/src/Application/Kernel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Application;
66

77
use LLM\Agents\Agent\SiteStatusChecker\Bootloader\SiteStatusCheckerBootloader;
8+
use LLM\Agents\OpenAI\Client\Bootloader\OpenAIClientBootloader;
89
use Spiral\Boot\Bootloader\CoreBootloader;
910
use Spiral\DotEnv\Bootloader\DotenvBootloader;
1011
use Spiral\Prototype\Bootloader\PrototypeBootloader;
@@ -32,8 +33,7 @@ public function defineBootloaders(): array
3233
Bootloader\Infrastructure\SecurityBootloader::class,
3334
Bootloader\Infrastructure\CycleOrmBootloader::class,
3435
Bootloader\Infrastructure\ValinorBootloader::class,
35-
Bootloader\Infrastructure\OpenAIBootloader::class,
36-
36+
OpenAIClientBootloader::class,
3737
// Prototyping
3838
PrototypeBootloader::class,
3939

app/src/Domain/Agent/AgentExecutorBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
namespace App\Domain\Agent;
66

7-
use App\Infrastructure\OpenAI\Option;
8-
use App\Infrastructure\OpenAI\StreamChunkCallbackInterface;
97
use LLM\Agents\Agent\AgentExecutor;
108
use LLM\Agents\Agent\Exception\InvalidBuilderStateException;
119
use LLM\Agents\Agent\Execution;
1210
use LLM\Agents\LLM\OptionsFactoryInterface;
1311
use LLM\Agents\LLM\OptionsInterface;
1412
use LLM\Agents\LLM\Prompt\Chat\MessagePrompt;
1513
use LLM\Agents\LLM\Prompt\Chat\Prompt;
14+
use LLM\Agents\OpenAI\Client\Option;
15+
use LLM\Agents\OpenAI\Client\StreamChunkCallbackInterface;
1616

1717
final class AgentExecutorBuilder
1818
{

app/src/Domain/Chat/SimpleChatService.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use App\Application\Entity\Uuid;
88
use App\Domain\Agent\AgentExecutorBuilder;
99
use App\Domain\Chat\Exception\ChatNotFoundException;
10-
use App\Infrastructure\OpenAI\StreamChunkCallback;
1110
use LLM\Agents\Agent\AgentRepositoryInterface;
1211
use LLM\Agents\Agent\Exception\AgentNotFoundException;
1312
use LLM\Agents\Agent\Execution;

app/src/Infrastructure/OpenAI/StreamChunkCallback.php renamed to app/src/Domain/Chat/StreamChunkCallback.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
declare(strict_types=1);
44

5-
namespace App\Infrastructure\OpenAI;
5+
namespace App\Domain\Chat;
66

77
use App\Application\Entity\Uuid;
88
use App\Domain\Chat\Event\MessageChunk;
9+
use LLM\Agents\OpenAI\Client\StreamChunkCallbackInterface;
910
use Psr\EventDispatcher\EventDispatcherInterface;
1011

1112
final readonly class StreamChunkCallback implements StreamChunkCallbackInterface

0 commit comments

Comments
 (0)