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

Commit 5e49821

Browse files
committed
refactor: update fabric package detection and remove comments
1 parent 862d3ae commit 5e49821

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

examples/fabric/summarize.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,16 @@
1515
exit(1);
1616
}
1717

18-
// Check if Fabric patterns package is installed
1918
if (!is_dir(dirname(__DIR__, 2).'/vendor/php-llm/fabric-pattern')) {
2019
echo 'Fabric patterns are not installed.'.\PHP_EOL;
2120
echo 'Please install them with: composer require php-llm/fabric-pattern'.\PHP_EOL;
2221
exit(1);
2322
}
2423

25-
// Initialize platform and model
2624
$platform = PlatformFactory::create($_ENV['OPENAI_API_KEY']);
2725
$model = new GPT(GPT::GPT_4O_MINI);
2826
$chain = new Chain($platform, $model);
2927

30-
// Example article to summarize
3128
$article = <<<'ARTICLE'
3229
The field of artificial intelligence has undergone dramatic transformations in recent years,
3330
with large language models (LLMs) emerging as one of the most significant breakthroughs.
@@ -41,13 +38,11 @@
4138
potential harms.
4239
ARTICLE;
4340

44-
// Create messages using Fabric pattern
4541
$messages = new MessageBag(
4642
Message::fabric('create_summary'),
4743
Message::ofUser($article)
4844
);
4945

50-
// Call the chain
5146
$response = $chain->call($messages);
5247

5348
echo 'Summary using Fabric pattern "create_summary":'.\PHP_EOL;

src/Platform/Fabric/FabricRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class FabricRepository
2121
public function __construct(?string $patternsPath = null)
2222
{
2323
if (null === $patternsPath) {
24-
// Check if fabric-pattern package is installed by checking for its Pattern class
25-
if (!class_exists(\PhpLlm\FabricPattern\Pattern::class)) {
24+
// Check if Fabric patterns package is installed
25+
if (!is_dir(\dirname(__DIR__, 2).'/vendor/php-llm/fabric-pattern')) {
2626
throw new \RuntimeException('Fabric patterns not found. Please install the "php-llm/fabric-pattern" package: composer require php-llm/fabric-pattern');
2727
}
2828

0 commit comments

Comments
 (0)