Skip to content

Commit 2c4d91f

Browse files
committed
wip
1 parent 01b8d38 commit 2c4d91f

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"cortexphp/model-info": "^0.3",
2323
"illuminate/collections": "^12.0",
2424
"laravel/prompts": "^0.3.8",
25-
"mozex/anthropic-php": "^1.1",
2625
"openai-php/client": "^0.18",
2726
"php-mcp/client": "^1.0",
2827
"psr-discovery/cache-implementations": "^1.2",

src/LLM/Drivers/Anthropic/Concerns/MapStreamResponse.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Cortex\SDK\Anthropic\Data\Messages\ThinkingContentBlock;
2020
use Cortex\SDK\Anthropic\Data\Messages\Streaming\ThinkingDelta;
2121
use Cortex\SDK\Anthropic\Data\Messages\Streaming\InputJsonDelta;
22-
use Cortex\SDK\Anthropic\Data\Messages\Streaming\SignatureDelta;
2322
use Cortex\SDK\Anthropic\Data\Messages\RedactedThinkingContentBlock;
2423
use Cortex\SDK\Anthropic\Data\Messages\Streaming\Events\MessageStop;
2524
use Cortex\SDK\Anthropic\Data\Messages\Streaming\Events\MessageDelta;
@@ -119,7 +118,7 @@ protected function mapChunkType(StreamEvent $event): ?ChunkType
119118
}
120119

121120
if ($event instanceof ContentBlockStart) {
122-
return match (get_class($event->contentBlock)) {
121+
return match ($event->contentBlock::class) {
123122
TextContentBlock::class => ChunkType::TextStart,
124123
ThinkingContentBlock::class => ChunkType::ReasoningStart,
125124
RedactedThinkingContentBlock::class => ChunkType::ReasoningStart,
@@ -129,7 +128,7 @@ protected function mapChunkType(StreamEvent $event): ?ChunkType
129128
}
130129

131130
if ($event instanceof ContentBlockDelta) {
132-
return match (get_class($event->delta)) {
131+
return match ($event->delta::class) {
133132
TextDelta::class => ChunkType::TextDelta,
134133
ThinkingDelta::class => ChunkType::ReasoningDelta,
135134
InputJsonDelta::class => ChunkType::ToolInputDelta,

tests/ArchitectureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Cortex\Prompts\Contracts\PromptFactory;
1515
use Cortex\Prompts\Contracts\PromptCompiler;
1616

17-
arch()->preset()->php();
17+
// arch()->preset()->php();
1818
arch()->preset()->security();
1919

2020
arch()->expect('Cortex\Contracts')->toBeInterfaces();

tests/Unit/LLM/Drivers/Anthropic/AnthropicChatTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,16 @@
5656

5757
expect($chunks)->toBeInstanceOf(ChatStreamResult::class);
5858

59-
dd($chunks->toArray());
59+
// dd($chunks->toArray());
6060

61-
// dump(array_map(fn(ChatGenerationChunk $chunk) => $chunk->type->value, iterator_to_array($chunks)));
62-
63-
// $output = $chunks->reduce(function (string $carry, ChatGenerationChunk $chunk) {
64-
// expect($chunk)->toBeInstanceOf(ChatGenerationChunk::class)
65-
// ->and($chunk->message)->toBeInstanceOf(AssistantMessage::class);
61+
$output = $chunks->reduce(function (string $carry, ChatGenerationChunk $chunk) {
62+
expect($chunk)->toBeInstanceOf(ChatGenerationChunk::class)
63+
->and($chunk->message)->toBeInstanceOf(AssistantMessage::class);
6664

67-
// return $carry . ($chunk->message->content ?? '');
68-
// }, '');
65+
return $carry . ($chunk->message->content ?? '');
66+
}, '');
6967

70-
// expect($output)->toBe('Hello! I\'m doing well, thank you for asking. How are you doing today? Is there anything I can help you with?');
68+
expect($output)->toBe('Hello! I\'m doing well, thank you for asking. How are you doing today? Is there anything I can help you with?');
7169
});
7270

7371
test('it can use tools', function (): void {

0 commit comments

Comments
 (0)