Skip to content

Commit d273e0f

Browse files
committed
Doc bug fix
1 parent 81c927f commit d273e0f

File tree

7 files changed

+53
-17
lines changed

7 files changed

+53
-17
lines changed

docs/features.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,17 +534,20 @@ Outputs:
534534
// Service provider auto-registers
535535

536536
// Use facade
537-
use Cognesy\Instructor\Facades\Instructor;
537+
use Cognesy\Instructor\Laravel\Facades\StructuredOutput;
538538

539-
$result = Instructor::respond()
540-
->withResponseClass(Person::class)
541-
->withMessages($text)
542-
->get();
539+
$result = StructuredOutput::using('openai')
540+
->with(
541+
messages: $text,
542+
responseModel: Person::class,
543+
)->get();
543544

544-
// Or inject
545-
public function handle(StructuredOutput $instructor)
545+
// Or inject via dependency injection
546+
public function handle(\Cognesy\Instructor\StructuredOutput $instructor)
546547
{
547-
return $instructor->withResponseClass(Person::class)->get();
548+
return $instructor
549+
->with(messages: $text, responseModel: Person::class)
550+
->get();
548551
}
549552
```
550553

docs/packages.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,20 @@ Adds Laravel-specific conveniences: service provider, facades, config publishing
140140
```php
141141
<?php
142142
// Use the facade
143-
use Cognesy\Instructor\Facades\Instructor;
143+
use Cognesy\Instructor\Laravel\Facades\StructuredOutput;
144144

145-
$person = Instructor::respond()
146-
->withResponseClass(Person::class)
147-
->withMessages($text)
148-
->get();
145+
$person = StructuredOutput::using('openai')
146+
->with(
147+
messages: $text,
148+
responseModel: Person::class,
149+
)->get();
149150

150151
// Or inject via dependency injection
151-
public function extract(StructuredOutput $instructor)
152+
public function extract(\Cognesy\Instructor\StructuredOutput $instructor)
152153
{
153-
return $instructor->withResponseClass(Person::class)->get();
154+
return $instructor
155+
->with(messages: $text, responseModel: Person::class)
156+
->get();
154157
}
155158
```
156159

packages/doctools/resources/config/quality/profiles/instructor.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,15 @@ rules:
7777
scope: markdown
7878
pattern: '/\bwithLLMConfigOverrides\s*\(/'
7979
message: 'Use `withConfigOverrides(...)` on LLMProvider.'
80+
81+
- id: instructor.no_instructor_facade
82+
engine: regex
83+
scope: markdown
84+
pattern: '/\bFacades\\\\Instructor\b/'
85+
message: 'There is no Instructor facade. Use `Cognesy\Instructor\Laravel\Facades\StructuredOutput` instead.'
86+
87+
- id: instructor.no_instructor_static_call
88+
engine: regex
89+
scope: markdown
90+
pattern: '/\bInstructor::(respond|with|create)\s*\(/'
91+
message: 'Instructor has no static facade methods. Use `StructuredOutput::with(...)` or `(new StructuredOutput)->with(...)` instead.'

packages/laravel/docs/commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Next steps:
4141
php artisan make:response-model PersonData
4242
4343
3. Extract structured data:
44-
$person = Instructor::with(
44+
$person = StructuredOutput::with(
4545
messages: "John is 30 years old",
4646
responseModel: PersonData::class,
4747
)->get();

packages/laravel/src/Console/InstructorInstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function showNextSteps(): void
125125
$this->newLine();
126126

127127
$this->line(' 3. Extract structured data:');
128-
$this->line(' <comment>$person = Instructor::with(</comment>');
128+
$this->line(' <comment>$person = StructuredOutput::with(</comment>');
129129
$this->line(' <comment>messages: "John is 30 years old",</comment>');
130130
$this->line(' <comment>responseModel: PersonData::class,</comment>');
131131
$this->line(' <comment>)->get();</comment>');

packages/laravel/src/Facades/Inference.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* Facade for Inference
1616
*
1717
* @method static \Cognesy\Polyglot\Inference\Inference connection(string $name)
18+
* @method static \Cognesy\Polyglot\Inference\Inference using(string $name)
1819
* @method static \Cognesy\Polyglot\Inference\Inference fromConfig(\Cognesy\Polyglot\Inference\Config\LLMConfig $config)
1920
* @method static \Cognesy\Polyglot\Inference\Inference withRuntime(\Cognesy\Polyglot\Inference\Contracts\CanCreateInference $runtime)
2021
* @method static \Cognesy\Polyglot\Inference\Inference with(?\Cognesy\Messages\Messages $messages = null, ?string $model = null, ?\Cognesy\Polyglot\Inference\Data\ToolDefinitions $tools = null, ?\Cognesy\Polyglot\Inference\Data\ToolChoice $toolChoice = null, ?\Cognesy\Polyglot\Inference\Data\ResponseFormat $responseFormat = null, ?array $options = null)
@@ -67,6 +68,14 @@ public static function connection(string $name): BaseInference|InferenceFake
6768
return static::fromConfig(static::resolveLLMConfig($name));
6869
}
6970

71+
/**
72+
* Alias for connection() — matches the base Inference::using() API.
73+
*/
74+
public static function using(string $name): BaseInference|InferenceFake
75+
{
76+
return static::connection($name);
77+
}
78+
7079
/**
7180
* Replace the Inference instance with a fake for testing.
7281
*/

packages/laravel/src/Facades/StructuredOutput.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Facade for StructuredOutput
1414
*
1515
* @method static \Cognesy\Instructor\StructuredOutput connection(string $name)
16+
* @method static \Cognesy\Instructor\StructuredOutput using(string $name)
1617
* @method static \Cognesy\Instructor\StructuredOutput fromConfig(\Cognesy\Polyglot\Inference\Config\LLMConfig $config)
1718
* @method static \Cognesy\Instructor\StructuredOutput withRuntime(\Cognesy\Instructor\Contracts\CanCreateStructuredOutput $runtime)
1819
* @method static \Cognesy\Instructor\StructuredOutput with(string|array|\Cognesy\Messages\Message|\Cognesy\Messages\Messages|null $messages = null, string|array|object|null $responseModel = null, ?string $system = null, ?string $prompt = null, ?array $examples = null, ?string $model = null, ?array $options = null)
@@ -74,6 +75,14 @@ public static function connection(string $name): BaseStructuredOutput|Structured
7475
return static::fromConfig(static::resolveLLMConfig($name));
7576
}
7677

78+
/**
79+
* Alias for connection() — matches the base StructuredOutput::using() API.
80+
*/
81+
public static function using(string $name): BaseStructuredOutput|StructuredOutputFake
82+
{
83+
return static::connection($name);
84+
}
85+
7786
/**
7887
* Replace the StructuredOutput instance with a fake for testing.
7988
*/

0 commit comments

Comments
 (0)