Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 000b605

Browse files
committed
chore: update to llm-chain 0.24
1 parent 77af4db commit 000b605

File tree

5 files changed

+8
-23
lines changed

5 files changed

+8
-23
lines changed

config/packages/llm_chain.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ llm_chain:
4444
chroma_db:
4545
symfonycon:
4646
collection: 'symfony_blog'
47-
embedder:
47+
indexer:
4848
default:
4949
model:
5050
name: 'Embeddings'
@@ -61,5 +61,5 @@ services:
6161
# $apiKey: '%env(SERP_API_KEY)%'
6262
PhpLlm\LlmChain\Chain\Toolbox\Tool\Wikipedia: ~
6363
PhpLlm\LlmChain\Chain\Toolbox\Tool\SimilaritySearch:
64-
$model: '@llm_chain.embedder.default.model'
64+
$model: '@llm_chain.indexer.default.model'
6565

src/Audio/Chat.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PhpLlm\LlmChain\Platform\Message\Message;
1111
use PhpLlm\LlmChain\Platform\Message\MessageBag;
1212
use PhpLlm\LlmChain\Platform\PlatformInterface;
13-
use PhpLlm\LlmChain\Platform\Response\AsyncResponse;
1413
use PhpLlm\LlmChain\Platform\Response\TextResponse;
1514
use Symfony\Component\DependencyInjection\Attribute\Autowire;
1615
use Symfony\Component\HttpFoundation\RequestStack;
@@ -34,11 +33,8 @@ public function say(string $base64audio): void
3433
file_put_contents($path, base64_decode($base64audio));
3534

3635
$response = $this->platform->request(new Whisper(), Audio::fromFile($path));
37-
assert($response instanceof AsyncResponse);
38-
$response = $response->unwrap();
39-
assert($response instanceof TextResponse);
4036

41-
$this->submitMessage($response->getContent());
37+
$this->submitMessage($response->asText());
4238
}
4339

4440
public function loadMessages(): MessageBag

src/Blog/Command/QueryCommand.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
use Codewithkyrian\ChromaDB\Client;
88
use PhpLlm\LlmChain\Platform\Bridge\OpenAI\Embeddings;
99
use PhpLlm\LlmChain\Platform\PlatformInterface;
10-
use PhpLlm\LlmChain\Platform\Response\AsyncResponse;
11-
use PhpLlm\LlmChain\Platform\Response\VectorResponse;
1210
use Symfony\Component\Console\Attribute\AsCommand;
1311
use Symfony\Component\Console\Command\Command;
1412
use Symfony\Component\Console\Input\InputInterface;
@@ -44,11 +42,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4442
$io->comment('Results are limited to 4 most similar documents.');
4543

4644
$platformResponse = $this->platform->request(new Embeddings(), $search);
47-
assert($platformResponse instanceof AsyncResponse);
48-
$platformResponse = $platformResponse->unwrap();
49-
assert($platformResponse instanceof VectorResponse);
5045
$queryResponse = $collection->query(
51-
queryEmbeddings: [$platformResponse->getContent()[0]->getData()],
46+
queryEmbeddings: [$platformResponse->asVectors()[0]->getData()],
5247
nResults: 4,
5348
);
5449

src/Blog/Embedder.php

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

77
use PhpLlm\LlmChain\Store\Document\Metadata;
88
use PhpLlm\LlmChain\Store\Document\TextDocument;
9-
use PhpLlm\LlmChain\Store\Embedder as LlmChainEmbedder;
9+
use PhpLlm\LlmChain\Store\Indexer;
1010

1111
final readonly class Embedder
1212
{
1313
public function __construct(
1414
private FeedLoader $loader,
15-
private LlmChainEmbedder $embedder,
15+
private Indexer $indexer,
1616
) {
1717
}
1818

@@ -23,6 +23,6 @@ public function embedBlog(): void
2323
$documents[] = new TextDocument($post->id, $post->toString(), new Metadata($post->toArray()));
2424
}
2525

26-
$this->embedder->embed($documents);
26+
$this->indexer->index($documents);
2727
}
2828
}

src/Video/TwigComponent.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
use PhpLlm\LlmChain\Platform\Message\Message;
1010
use PhpLlm\LlmChain\Platform\Message\MessageBag;
1111
use PhpLlm\LlmChain\Platform\PlatformInterface;
12-
use PhpLlm\LlmChain\Platform\Response\AsyncResponse;
13-
use PhpLlm\LlmChain\Platform\Response\TextResponse;
1412
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
1513
use Symfony\UX\LiveComponent\Attribute\LiveAction;
1614
use Symfony\UX\LiveComponent\Attribute\LiveArg;
@@ -46,10 +44,6 @@ public function submit(#[LiveArg] string $instruction, #[LiveArg] string $image)
4644
'max_tokens' => 100,
4745
]);
4846

49-
assert($response instanceof AsyncResponse);
50-
$response = $response->unwrap();
51-
assert($response instanceof TextResponse);
52-
53-
$this->caption = $response->getContent();
47+
$this->caption = $response->asText();
5448
}
5549
}

0 commit comments

Comments
 (0)