Skip to content

Commit 112a392

Browse files
committed
Release version 0.17.11
1 parent 8e937a7 commit 112a392

File tree

112 files changed

+572
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+572
-191
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: 'Customize parameters via DSN'
3+
docname: 'custom_llm_with_dsn'
4+
---
5+
6+
## Overview
7+
8+
You can provide your own LLM configuration data to `Instructor` object with DSN string.
9+
This is useful for inline configuration or for building configuration from admin UI,
10+
CLI arguments or environment variables.
11+
12+
## Example
13+
14+
```php
15+
<?php
16+
require 'examples/boot.php';
17+
18+
use Cognesy\Instructor\Instructor;
19+
use Cognesy\Polyglot\LLM\Data\LLMConfig;
20+
use Cognesy\Polyglot\LLM\Enums\OutputMode;
21+
use Cognesy\Utils\Env;
22+
23+
class User {
24+
public int $age;
25+
public string $name;
26+
}
27+
28+
$user = (new Instructor)
29+
::fromDSN('connection=xai,model=grok-2')
30+
->respond(
31+
messages: "Our user Jason is 25 years old.",
32+
responseModel: User::class,
33+
mode: OutputMode::Tools,
34+
);
35+
36+
dump($user);
37+
38+
assert(isset($user->name));
39+
assert(isset($user->age));
40+
?>
41+
```

docs-build/cookbook/instructor/advanced/demonstrations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ is expected to be a JSON object.
1919
require 'examples/boot.php';
2020

2121
use Cognesy\Http\Events\HttpRequestSent;
22-
use Cognesy\Instructor\Features\Core\Data\Example;
22+
use Cognesy\Instructor\Data\Example;
2323
use Cognesy\Instructor\Instructor;
2424
use Cognesy\Polyglot\LLM\Enums\OutputMode;
2525

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: 'Customize LLM Configuration with DSN string'
3+
docname: 'custom_llm_via_dsn'
4+
---
5+
6+
## Overview
7+
8+
You can provide your own LLM configuration data to `Inference` object with DSN string.
9+
This is useful for inline configuration or for building configuration from admin UI,
10+
CLI arguments or environment variables.
11+
12+
## Example
13+
14+
```php
15+
<?php
16+
require 'examples/boot.php';
17+
18+
use Cognesy\Polyglot\LLM\Inference;
19+
use Cognesy\Utils\Str;
20+
21+
$answer = Inference
22+
::fromDSN('connection=xai,model=grok-2')
23+
->create(
24+
messages: [['role' => 'user', 'content' => 'What is the capital of France']],
25+
options: ['max_tokens' => 64]
26+
)
27+
->toText();
28+
29+
echo "USER: What is capital of France\n";
30+
echo "ASSISTANT: $answer\n";
31+
32+
assert(Str::contains($answer, 'Paris'));
33+
?>
34+
```

docs-build/cookbook/prompting/few_shot/in_context_examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ We can implement SG-ICL using Instructor as seen below.
2020
<?php
2121
require 'examples/boot.php';
2222

23+
use Cognesy\Instructor\Data\Example;
2324
use Cognesy\Instructor\Extras\Scalar\Scalar;
2425
use Cognesy\Instructor\Extras\Sequence\Sequence;
25-
use Cognesy\Instructor\Features\Core\Data\Example;
2626
use Cognesy\Instructor\Instructor;
2727

2828
enum ReviewSentiment : string {

docs-build/instructor/concepts/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ The library is inspired by the [Instructor](https://jxnl.github.io/instructor/)
1111

1212
Instructor uses Large Language Models (LLMs) to process data and return structured information you can easily use in your code.
1313

14-
![image](../../images/concept.png)
14+
![image](../images/concept.png)
1515

1616

1717

1818
## Instructor in action
1919

2020
Here's a simple CLI demo app using Instructor to extract structured data from text:
2121

22-
![image](../../images/extraction.gif)
22+
![image](../images/extraction.gif)
2323

2424

2525

docs-build/instructor/essentials/demonstrations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ array data rendered as JSON text.
2222

2323
```php
2424
<?php
25-
use Cognesy\Instructor\Features\Core\Data\Example;
25+
use Cognesy\Instructor\Data\Example;
2626

2727
class User {
2828
public int $age;

docs-build/mint.json

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,41 +134,6 @@
134134
"instructor/misc/llm_providers"
135135
]
136136
},
137-
{
138-
"group": "Release Notes",
139-
"pages": [
140-
"release-notes/v0.17.4",
141-
"release-notes/v0.17.3",
142-
"release-notes/v0.17.1",
143-
"release-notes/v0.17.0",
144-
"release-notes/v0.16.0",
145-
"release-notes/v0.15.2",
146-
"release-notes/v0.15.1",
147-
"release-notes/v0.15.0",
148-
"release-notes/v0.14.7",
149-
"release-notes/v0.14.6",
150-
"release-notes/v0.14.5",
151-
"release-notes/v0.14.4",
152-
"release-notes/v0.14.3",
153-
"release-notes/v0.14.2",
154-
"release-notes/v0.14.1",
155-
"release-notes/v0.14.0",
156-
"release-notes/v0.13.0",
157-
"release-notes/v0.12.13",
158-
"release-notes/v0.12.12",
159-
"release-notes/v0.12.11",
160-
"release-notes/v0.12.10",
161-
"release-notes/v0.12.9",
162-
"release-notes/v0.12.8",
163-
"release-notes/v0.12.7",
164-
"release-notes/v0.12.6",
165-
"release-notes/v0.12.5",
166-
"release-notes/v0.12.4",
167-
"release-notes/v0.12.3",
168-
"release-notes/v0.12.2",
169-
"release-notes/v0.12.0"
170-
]
171-
},
172137
{
173138
"group": "Polyglot",
174139
"pages": [
@@ -275,6 +240,49 @@
275240
"cookbook/contributing"
276241
]
277242
},
243+
{
244+
"group": "Release Notes",
245+
"pages": [
246+
"release-notes/v0.17.11",
247+
"release-notes/v0.17.10",
248+
"release-notes/v0.17.9",
249+
"release-notes/v0.17.8",
250+
"release-notes/v0.17.7",
251+
"release-notes/v0.17.6",
252+
"release-notes/v0.17.5",
253+
"release-notes/v0.17.4",
254+
"release-notes/v0.17.3",
255+
"release-notes/v0.17.1",
256+
"release-notes/v0.17.0",
257+
"release-notes/v0.16.0",
258+
"release-notes/v0.15.2",
259+
"release-notes/v0.15.1",
260+
"release-notes/v0.15.0",
261+
"release-notes/v0.14.7",
262+
"release-notes/v0.14.6",
263+
"release-notes/v0.14.5",
264+
"release-notes/v0.14.4",
265+
"release-notes/v0.14.3",
266+
"release-notes/v0.14.2",
267+
"release-notes/v0.14.1",
268+
"release-notes/v0.14.0",
269+
"release-notes/v0.13.0",
270+
"release-notes/v0.12.13",
271+
"release-notes/v0.12.12",
272+
"release-notes/v0.12.11",
273+
"release-notes/v0.12.10",
274+
"release-notes/v0.12.9",
275+
"release-notes/v0.12.8",
276+
"release-notes/v0.12.7",
277+
"release-notes/v0.12.6",
278+
"release-notes/v0.12.5",
279+
"release-notes/v0.12.4",
280+
"release-notes/v0.12.3",
281+
"release-notes/v0.12.2",
282+
"release-notes/v0.12.0",
283+
"release-notes/v0.8.0"
284+
]
285+
},
278286
{
279287
"group": "Cookbook \\ Instructor \\ Basics",
280288
"pages": [
@@ -299,6 +307,7 @@
299307
"cookbook/instructor/advanced/context_cache_structured",
300308
"cookbook/instructor/advanced/custom_llm",
301309
"cookbook/instructor/advanced/custom_prompts",
310+
"cookbook/instructor/advanced/custom_llm_with_dsn",
302311
"cookbook/instructor/advanced/structured_input",
303312
"cookbook/instructor/advanced/function_calls",
304313
"cookbook/instructor/advanced/partials",
@@ -379,6 +388,7 @@
379388
"cookbook/polyglot/llm_advanced/custom_llm",
380389
"cookbook/polyglot/llm_advanced/custom_embeddings_driver",
381390
"cookbook/polyglot/llm_advanced/custom_llm_driver",
391+
"cookbook/polyglot/llm_advanced/custom_llm_via_dsn",
382392
"cookbook/polyglot/llm_advanced/embeddings",
383393
"cookbook/polyglot/llm_advanced/parallel_calls",
384394
"cookbook/polyglot/llm_advanced/reasoning_content"

docs-build/polyglot/advanced/json-schema.mdx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Structured outputs with `JsonSchema` class
2+
title: Structured outputs with JsonSchema class
33
description: Learn how to use JSON Schemas to generate structured outputs using LLMs.
44
---
55

@@ -474,9 +474,3 @@ $result = (new Inference)
474474
// Additional configuration...
475475
);
476476
```
477-
478-
## Conclusion
479-
480-
JsonSchema in Polyglot provides a powerful way to structure your LLM interactions. By defining clear schemas, you ensure consistent, typed responses from language models and improve the reliability of your AI-powered applications.
481-
482-
Remember that while schemas help define the structure of your data, they don't automatically validate the data against these schemas - they primarily serve as guidance for the LLM to structure its responses correctly. Always implement server-side validation for production applications.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- (polyglot) Support for DSN string containing parameters of LLM provider connection - Inference, Embeddings classes and their configs
2+
- (instructor) Support for DSN string containing parameters of LLM provider connection - Instructor class
3+
- (utils) DSN class with DSN-like string parsing capabilities
4+
- (docs) DSN examples for Inference and Instructor
5+
- (instructor) Internal refactoring - moved some Instructor/Features/Core code to Instructor namespace
6+
- (hub) Automated build of changelog section in docs
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- 'Structured-to-structured' processing - provide objects or arrays to be processed with LLM, get object as a result
2+
- Composite language programs with Module classes (inspired by DSPy)
3+
- `FunctionCall` helper class for extracting arguments for functions, methods or closures
4+
- (experimental) Anthropic tool calls mode support
5+
- (experimental) Cohere API support - MdJson only, other modes unstable
6+
- (experimental) Gemini API client - MdJson & sync only, streaming is unstable
7+
- (internals) Simplified, cleaner API client code
8+
- (internals) Consolidated message building logic to support formats required by different APIs
9+
- (internals) Better control over complex chat message sequences with `Scripts` and `Sections`
10+
- (internals) Code cleanup and bug fixes
11+
- Additions to docs and examples

0 commit comments

Comments
 (0)