Skip to content

Commit

Permalink
Docs update
Browse files Browse the repository at this point in the history
  • Loading branch information
ddebowczyk committed Oct 6, 2024
1 parent de9a496 commit a3fcba4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
5 changes: 4 additions & 1 deletion docs/cookbook/examples/advanced/partials.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ response is received.
$loader = require 'vendor/autoload.php';
$loader->add('Cognesy\\Instructor\\', __DIR__ . '../../src/');

use Cognesy\Instructor\Enums\Mode;
use Cognesy\Instructor\Events\Event;
use Cognesy\Instructor\Instructor;

Expand Down Expand Up @@ -66,11 +67,13 @@ $text = <<<TEXT
TEXT;

$user = (new Instructor)
->withConnection('openai')
->onPartialUpdate(partialUpdate(...))
->request(
messages: $text,
responseModel: UserDetail::class,
options: ['stream' => true]
options: ['stream' => true],
mode: Mode::Json,
)->get();

echo "All tokens received, fully completed object available in `\$user` variable.\n";
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/examples/basics/custom_validation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserDetails
#[Assert\Callback]
public function validateName(ExecutionContextInterface $context, mixed $payload) {
if ($this->name !== strtoupper($this->name)) {
$context->buildViolation("Name must be in all uppercase letters.")
$context->buildViolation("Name must be all uppercase.")
->atPath('name')
->setInvalidValue($this->name)
->addViolation();
Expand Down
5 changes: 2 additions & 3 deletions docs/cookbook/examples/basics/validation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ try {
messages: [['role' => 'user', 'content' => "you can reply to me via mail -- Jason"]],
responseModel: UserDetails::class,
)->get();
dump($user);
} catch(Exception $e) {
$caughtException = true;
}

dump($user);

assert($user === null);
assert(!isset($user));
assert($caughtException === true);
?>
```
2 changes: 1 addition & 1 deletion docs/cookbook/examples/extras/transcription_to_tasks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum Role : string {
class Task {
public string $title;
public string $description;
public DateTime $dueDate;
public DateTimeImmutable $dueDate;
public Role $owner;
public TaskStatus $status;
}
Expand Down
2 changes: 0 additions & 2 deletions docs/cookbook/examples/troubleshooting/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ $loader->add('Cognesy\\Instructor\\', __DIR__ . '../../src/');

use Cognesy\Instructor\Extras\LLM\Data\LLMConfig;
use Cognesy\Instructor\Extras\LLM\Drivers\OpenAIDriver;
use Cognesy\Instructor\Extras\LLM\Enums\LLMProviderType;
use Cognesy\Instructor\Instructor;
use Cognesy\Instructor\Utils\Env;

class User {
public int $age;
Expand Down
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"cookbook/examples/advanced/function_calls",
"cookbook/examples/advanced/partials",
"cookbook/examples/advanced/demonstrations",
"cookbook/examples/advanced/scalars",
"cookbook/examples/advanced/sequences",
"cookbook/examples/advanced/streaming",
"cookbook/examples/advanced/structures"
Expand Down

0 comments on commit a3fcba4

Please sign in to comment.