-
Notifications
You must be signed in to change notification settings - Fork 12
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
1 parent
47f1cf1
commit 5c9a058
Showing
59 changed files
with
668 additions
and
407 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
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 |
---|---|---|
|
@@ -58,14 +58,19 @@ class User { | |
$user = $instructor->respond( | ||
messages: "Jason (@jxnlco) is 25 years old and is the admin of this project. He likes playing football and reading books.", | ||
responseModel: User::class, | ||
model: 'llama2:latest', | ||
prompt: 'Parse the user data to JSON, respond using following JSON Schema: <|json_schema|>', | ||
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'],], | ||
'input' => 'Ive got email Frank - their developer. Asked to connect via Twitter @frankch. Btw, he plays on drums!', | ||
'output' => ['name' => 'Frank', 'role' => 'developer', 'hobbies' => ['playing drums'], 'username' => 'frankch', 'age' => null], | ||
],[ | ||
'input' => 'We have a meeting with John, our new user. He is 30 years old - check his profile: @jx90.', | ||
'output' => ['name' => 'John', 'role' => 'admin', 'hobbies' => [], 'username' => 'jx90', 'age' => 30], | ||
]], | ||
model: 'qwen2', | ||
mode: Mode::Json, | ||
); | ||
|
||
|
||
print("Completed response model:\n\n"); | ||
|
||
dump($user); | ||
|
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
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
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,48 @@ | ||
<?php | ||
namespace Cognesy\Instructor\Clients\Azure\Traits; | ||
|
||
use Cognesy\Instructor\Enums\Mode; | ||
|
||
trait HandlesRequestBody | ||
{ | ||
public function messages(): array { | ||
if ($this->noScript()) { | ||
return $this->messages; | ||
} | ||
|
||
if($this->mode->is(Mode::Tools)) { | ||
unset($this->scriptContext['json_schema']); | ||
} | ||
|
||
return $this | ||
->withMetaSections($this->script) | ||
->withContext($this->scriptContext) | ||
->select([ | ||
'system', | ||
'pre-input', 'messages', 'input', 'post-input', | ||
'pre-prompt', 'prompt', 'post-prompt', | ||
'pre-examples', 'examples', 'post-examples', | ||
'pre-retries', 'retries', 'post-retries' | ||
]) | ||
->toArray(); | ||
} | ||
|
||
public function tools(): array { | ||
return $this->tools; | ||
} | ||
|
||
public function getToolChoice(): string|array { | ||
if (empty($this->tools)) { | ||
return ''; | ||
} | ||
return $this->toolChoice ?: 'auto'; | ||
} | ||
|
||
protected function getResponseSchema() : array { | ||
return $this->responseFormat['schema'] ?? []; | ||
} | ||
|
||
protected function getResponseFormat(): array { | ||
return $this->responseFormat['format'] ?? []; | ||
} | ||
} |
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
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
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
Oops, something went wrong.