-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
190 changed files
with
2,958 additions
and
1,518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ archived/ | |
vendor/ | ||
php_errors.log | ||
composer.lock | ||
xdebug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use Cognesy\Instructor\ApiClient\ModelParams; | ||
use Cognesy\Instructor\Configuration\Configuration; | ||
|
||
return function(Configuration $config) : Configuration { | ||
$config->declare( | ||
class: ModelParams::class, | ||
name: 'google:gemini-1.5-flash', | ||
context: [ | ||
'label' => 'Google Gemini 1.5 Flash', | ||
'type' => 'gemini', | ||
'name' => 'gemini-1.5-flash', | ||
'maxTokens' => 4096, | ||
'contextSize' => 128_000, | ||
'inputCost' => 1, | ||
'outputCost' => 1, | ||
'roleMap' => [ | ||
'user' => 'user', | ||
'assistant' => 'model', | ||
'system' => 'user' | ||
], | ||
], | ||
); | ||
|
||
return $config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Using structured data as an input | ||
|
||
Instructor offers a way to use structured data as an input. This is | ||
useful when you want to use object data as input and get another object | ||
with a result of LLM inference. | ||
|
||
The `input` field of Instructor's `respond()` and `request()` methods | ||
can be an object, but also an array or just a string. | ||
|
||
```php | ||
<?php | ||
$loader = require 'vendor/autoload.php'; | ||
$loader->add('Cognesy\\Instructor\\', __DIR__ . '../../src/'); | ||
|
||
use Cognesy\Instructor\Instructor; | ||
|
||
class Email { | ||
public function __construct( | ||
public string $address = '', | ||
public string $subject = '', | ||
public string $body = '', | ||
) {} | ||
} | ||
|
||
$email = new Email( | ||
address: 'joe@gmail', | ||
subject: 'Status update', | ||
body: 'Your account has been updated.' | ||
); | ||
|
||
$translatedEmail = (new Instructor)->respond( | ||
input: $email, | ||
responseModel: Email::class, | ||
prompt: 'Translate the text fields of email to Spanish. Keep other fields unchanged.', | ||
); | ||
|
||
dump($translatedEmail); | ||
|
||
assert($translatedEmail->address === $email->address); | ||
assert($translatedEmail->subject !== $email->subject); | ||
assert($translatedEmail->body !== $email->body); | ||
?> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,10 @@ $user = $instructor->respond( | |
responseModel: User::class, | ||
model: 'claude-3-haiku-20240307', | ||
mode: Mode::Tools, | ||
//options: ['stream' => true ] | ||
examples: [[ | ||
'input' => 'Ive got email Frank - their developer. He asked to come back to him [email protected]. Btw, he plays on drums!', | ||
'output' => ['age' => null, 'name' => 'Frank', 'role' => 'developer', 'hobbies' => ['playing drums'],], | ||
]], | ||
); | ||
|
||
print("Completed response model:\n\n"); | ||
|
Oops, something went wrong.