This repository was archived by the owner on Jul 16, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +2
-7
lines changed Expand file tree Collapse file tree 2 files changed +2
-7
lines changed Original file line number Diff line number Diff line change 1515 exit (1 );
1616}
1717
18- // Check if Fabric patterns package is installed
1918if (!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.
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
5348echo 'Summary using Fabric pattern "create_summary": ' .\PHP_EOL ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments