@solvers-hub/llm-json 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -0
  3. package/docs/classes/LlmJson.html +5 -5
  4. package/docs/index.html +2 -1
  5. package/docs/interfaces/ExtractOptions.html +3 -3
  6. package/docs/interfaces/ExtractResult.html +4 -4
  7. package/docs/interfaces/JsonBlock.html +6 -6
  8. package/docs/interfaces/JsonParseError.html +4 -4
  9. package/docs/interfaces/SchemaDefinition.html +3 -3
  10. package/docs/interfaces/ValidationResult.html +5 -5
  11. package/docs-md/README.md +55 -55
  12. package/docs-md/classes/LlmJson.md +147 -147
  13. package/docs-md/interfaces/ExtractOptions.md +48 -48
  14. package/docs-md/interfaces/ExtractResult.md +49 -49
  15. package/docs-md/interfaces/JsonBlock.md +75 -75
  16. package/docs-md/interfaces/JsonParseError.md +49 -49
  17. package/docs-md/interfaces/SchemaDefinition.md +36 -36
  18. package/docs-md/interfaces/ValidationResult.md +62 -62
  19. package/docs-md/modules.md +28 -28
  20. package/package.json +52 -52
  21. package/dist/examples/example.d.ts +0 -1
  22. package/dist/examples/example.js +0 -96
  23. /package/dist/{src/array-extractor.d.ts → array-extractor.d.ts} +0 -0
  24. /package/dist/{src/array-extractor.js → array-extractor.js} +0 -0
  25. /package/dist/{src/corrector.d.ts → corrector.d.ts} +0 -0
  26. /package/dist/{src/corrector.js → corrector.js} +0 -0
  27. /package/dist/{src/extractor.d.ts → extractor.d.ts} +0 -0
  28. /package/dist/{src/extractor.js → extractor.js} +0 -0
  29. /package/dist/{src/index.d.ts → index.d.ts} +0 -0
  30. /package/dist/{src/index.js → index.js} +0 -0
  31. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
  32. /package/dist/{src/types.js → types.js} +0 -0
  33. /package/dist/{src/validator.d.ts → validator.d.ts} +0 -0
  34. /package/dist/{src/validator.js → validator.js} +0 -0
@@ -1,49 +1,49 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ExtractOptions
2
-
3
- # Interface: ExtractOptions
4
-
5
- Options for JSON extraction.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [attemptCorrection](ExtractOptions.md#attemptcorrection)
12
- - [schemas](ExtractOptions.md#schemas)
13
-
14
- ## Properties
15
-
16
- ### attemptCorrection
17
-
18
- • `Optional` **attemptCorrection**: `boolean`
19
-
20
- Whether to attempt to correct malformed JSON.
21
-
22
- **`Default`**
23
-
24
- ```ts
25
- false
26
- ```
27
-
28
- #### Defined in
29
-
30
- [types.ts:9](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L9)
31
-
32
- ___
33
-
34
- ### schemas
35
-
36
- • `Optional` **schemas**: [`SchemaDefinition`](SchemaDefinition.md)[]
37
-
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ExtractOptions
2
+
3
+ # Interface: ExtractOptions
4
+
5
+ Options for JSON extraction.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [attemptCorrection](ExtractOptions.md#attemptcorrection)
12
+ - [schemas](ExtractOptions.md#schemas)
13
+
14
+ ## Properties
15
+
16
+ ### attemptCorrection
17
+
18
+ • `Optional` **attemptCorrection**: `boolean`
19
+
20
+ Whether to attempt to correct malformed JSON.
21
+
22
+ **`Default`**
23
+
24
+ ```ts
25
+ false
26
+ ```
27
+
28
+ #### Defined in
29
+
30
+ [types.ts:9](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L9)
31
+
32
+ ___
33
+
34
+ ### schemas
35
+
36
+ • `Optional` **schemas**: [`SchemaDefinition`](SchemaDefinition.md)[]
37
+
38
38
  JSON schemas to validate extracted JSON against.
39
- If provided, the extracted JSON will be validated against these schemas.
40
-
41
- **`Default`**
42
-
43
- ```ts
44
- undefined
45
- ```
46
-
47
- #### Defined in
48
-
49
- [types.ts:16](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L16)
39
+ If provided, the extracted JSON will be validated against these schemas.
40
+
41
+ **`Default`**
42
+
43
+ ```ts
44
+ undefined
45
+ ```
46
+
47
+ #### Defined in
48
+
49
+ [types.ts:16](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L16)
@@ -1,49 +1,49 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ExtractResult
2
-
3
- # Interface: ExtractResult
4
-
5
- Result of the JSON extraction.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [json](ExtractResult.md#json)
12
- - [text](ExtractResult.md#text)
13
- - [validatedJson](ExtractResult.md#validatedjson)
14
-
15
- ## Properties
16
-
17
- ### json
18
-
19
- • **json**: `any`[]
20
-
21
- Array of parsed JSON objects extracted from the input.
22
-
23
- #### Defined in
24
-
25
- [types.ts:71](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L71)
26
-
27
- ___
28
-
29
- ### text
30
-
31
- • **text**: `string`[]
32
-
33
- Array of text blocks extracted from the input.
34
-
35
- #### Defined in
36
-
37
- [types.ts:66](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L66)
38
-
39
- ___
40
-
41
- ### validatedJson
42
-
43
- • `Optional` **validatedJson**: [`ValidationResult`](ValidationResult.md)[]
44
-
45
- Array of validated JSON results, only present if schemas were provided.
46
-
47
- #### Defined in
48
-
49
- [types.ts:76](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L76)
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ExtractResult
2
+
3
+ # Interface: ExtractResult
4
+
5
+ Result of the JSON extraction.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [json](ExtractResult.md#json)
12
+ - [text](ExtractResult.md#text)
13
+ - [validatedJson](ExtractResult.md#validatedjson)
14
+
15
+ ## Properties
16
+
17
+ ### json
18
+
19
+ • **json**: `any`[]
20
+
21
+ Array of parsed JSON objects extracted from the input.
22
+
23
+ #### Defined in
24
+
25
+ [types.ts:71](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L71)
26
+
27
+ ___
28
+
29
+ ### text
30
+
31
+ • **text**: `string`[]
32
+
33
+ Array of text blocks extracted from the input.
34
+
35
+ #### Defined in
36
+
37
+ [types.ts:66](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L66)
38
+
39
+ ___
40
+
41
+ ### validatedJson
42
+
43
+ • `Optional` **validatedJson**: [`ValidationResult`](ValidationResult.md)[]
44
+
45
+ Array of validated JSON results, only present if schemas were provided.
46
+
47
+ #### Defined in
48
+
49
+ [types.ts:76](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L76)
@@ -1,75 +1,75 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / JsonBlock
2
-
3
- # Interface: JsonBlock
4
-
5
- Information about a detected JSON block.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [endIndex](JsonBlock.md#endindex)
12
- - [parsed](JsonBlock.md#parsed)
13
- - [raw](JsonBlock.md#raw)
14
- - [startIndex](JsonBlock.md#startindex)
15
- - [wasCorrected](JsonBlock.md#wascorrected)
16
-
17
- ## Properties
18
-
19
- ### endIndex
20
-
21
- • **endIndex**: `number`
22
-
23
- The end index of the JSON block in the input string.
24
-
25
- #### Defined in
26
-
27
- [types.ts:96](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L96)
28
-
29
- ___
30
-
31
- ### parsed
32
-
33
- • `Optional` **parsed**: `any`
34
-
35
- The parsed JSON object.
36
-
37
- #### Defined in
38
-
39
- [types.ts:106](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L106)
40
-
41
- ___
42
-
43
- ### raw
44
-
45
- • **raw**: `string`
46
-
47
- The raw JSON string.
48
-
49
- #### Defined in
50
-
51
- [types.ts:86](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L86)
52
-
53
- ___
54
-
55
- ### startIndex
56
-
57
- • **startIndex**: `number`
58
-
59
- The start index of the JSON block in the input string.
60
-
61
- #### Defined in
62
-
63
- [types.ts:91](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L91)
64
-
65
- ___
66
-
67
- ### wasCorrected
68
-
69
- • `Optional` **wasCorrected**: `boolean`
70
-
71
- Whether the JSON was corrected.
72
-
73
- #### Defined in
74
-
75
- [types.ts:101](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L101)
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / JsonBlock
2
+
3
+ # Interface: JsonBlock
4
+
5
+ Information about a detected JSON block.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [endIndex](JsonBlock.md#endindex)
12
+ - [parsed](JsonBlock.md#parsed)
13
+ - [raw](JsonBlock.md#raw)
14
+ - [startIndex](JsonBlock.md#startindex)
15
+ - [wasCorrected](JsonBlock.md#wascorrected)
16
+
17
+ ## Properties
18
+
19
+ ### endIndex
20
+
21
+ • **endIndex**: `number`
22
+
23
+ The end index of the JSON block in the input string.
24
+
25
+ #### Defined in
26
+
27
+ [types.ts:96](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L96)
28
+
29
+ ___
30
+
31
+ ### parsed
32
+
33
+ • `Optional` **parsed**: `any`
34
+
35
+ The parsed JSON object.
36
+
37
+ #### Defined in
38
+
39
+ [types.ts:106](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L106)
40
+
41
+ ___
42
+
43
+ ### raw
44
+
45
+ • **raw**: `string`
46
+
47
+ The raw JSON string.
48
+
49
+ #### Defined in
50
+
51
+ [types.ts:86](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L86)
52
+
53
+ ___
54
+
55
+ ### startIndex
56
+
57
+ • **startIndex**: `number`
58
+
59
+ The start index of the JSON block in the input string.
60
+
61
+ #### Defined in
62
+
63
+ [types.ts:91](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L91)
64
+
65
+ ___
66
+
67
+ ### wasCorrected
68
+
69
+ • `Optional` **wasCorrected**: `boolean`
70
+
71
+ Whether the JSON was corrected.
72
+
73
+ #### Defined in
74
+
75
+ [types.ts:101](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L101)
@@ -1,49 +1,49 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / JsonParseError
2
-
3
- # Interface: JsonParseError
4
-
5
- Error information for JSON parsing failures.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [message](JsonParseError.md#message)
12
- - [position](JsonParseError.md#position)
13
- - [raw](JsonParseError.md#raw)
14
-
15
- ## Properties
16
-
17
- ### message
18
-
19
- • **message**: `string`
20
-
21
- The original error message.
22
-
23
- #### Defined in
24
-
25
- [types.ts:116](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L116)
26
-
27
- ___
28
-
29
- ### position
30
-
31
- • `Optional` **position**: `number`
32
-
33
- The position in the JSON string where the error occurred.
34
-
35
- #### Defined in
36
-
37
- [types.ts:126](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L126)
38
-
39
- ___
40
-
41
- ### raw
42
-
43
- • **raw**: `string`
44
-
45
- The raw JSON string that failed to parse.
46
-
47
- #### Defined in
48
-
49
- [types.ts:121](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L121)
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / JsonParseError
2
+
3
+ # Interface: JsonParseError
4
+
5
+ Error information for JSON parsing failures.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [message](JsonParseError.md#message)
12
+ - [position](JsonParseError.md#position)
13
+ - [raw](JsonParseError.md#raw)
14
+
15
+ ## Properties
16
+
17
+ ### message
18
+
19
+ • **message**: `string`
20
+
21
+ The original error message.
22
+
23
+ #### Defined in
24
+
25
+ [types.ts:116](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L116)
26
+
27
+ ___
28
+
29
+ ### position
30
+
31
+ • `Optional` **position**: `number`
32
+
33
+ The position in the JSON string where the error occurred.
34
+
35
+ #### Defined in
36
+
37
+ [types.ts:126](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L126)
38
+
39
+ ___
40
+
41
+ ### raw
42
+
43
+ • **raw**: `string`
44
+
45
+ The raw JSON string that failed to parse.
46
+
47
+ #### Defined in
48
+
49
+ [types.ts:121](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L121)
@@ -1,36 +1,36 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / SchemaDefinition
2
-
3
- # Interface: SchemaDefinition
4
-
5
- Definition of a JSON schema for validation.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [name](SchemaDefinition.md#name)
12
- - [schema](SchemaDefinition.md#schema)
13
-
14
- ## Properties
15
-
16
- ### name
17
-
18
- • **name**: `string`
19
-
20
- A unique name for the schema to identify which schema matched.
21
-
22
- #### Defined in
23
-
24
- [types.ts:26](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L26)
25
-
26
- ___
27
-
28
- ### schema
29
-
30
- • **schema**: `object`
31
-
32
- The JSON schema object conforming to JSON Schema specification.
33
-
34
- #### Defined in
35
-
36
- [types.ts:31](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L31)
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / SchemaDefinition
2
+
3
+ # Interface: SchemaDefinition
4
+
5
+ Definition of a JSON schema for validation.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [name](SchemaDefinition.md#name)
12
+ - [schema](SchemaDefinition.md#schema)
13
+
14
+ ## Properties
15
+
16
+ ### name
17
+
18
+ • **name**: `string`
19
+
20
+ A unique name for the schema to identify which schema matched.
21
+
22
+ #### Defined in
23
+
24
+ [types.ts:26](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L26)
25
+
26
+ ___
27
+
28
+ ### schema
29
+
30
+ • **schema**: `object`
31
+
32
+ The JSON schema object conforming to JSON Schema specification.
33
+
34
+ #### Defined in
35
+
36
+ [types.ts:31](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L31)
@@ -1,62 +1,62 @@
1
- [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ValidationResult
2
-
3
- # Interface: ValidationResult
4
-
5
- Result of schema validation for a JSON object.
6
-
7
- ## Table of contents
8
-
9
- ### Properties
10
-
11
- - [isValid](ValidationResult.md#isvalid)
12
- - [json](ValidationResult.md#json)
13
- - [matchedSchema](ValidationResult.md#matchedschema)
14
- - [validationErrors](ValidationResult.md#validationerrors)
15
-
16
- ## Properties
17
-
18
- ### isValid
19
-
20
- • **isValid**: `boolean`
21
-
22
- Whether the JSON is valid according to the matched schema.
23
-
24
- #### Defined in
25
-
26
- [types.ts:51](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L51)
27
-
28
- ___
29
-
30
- ### json
31
-
32
- • **json**: `any`
33
-
34
- The JSON object that was validated.
35
-
36
- #### Defined in
37
-
38
- [types.ts:41](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L41)
39
-
40
- ___
41
-
42
- ### matchedSchema
43
-
44
- • **matchedSchema**: ``null`` \| `string`
45
-
46
- The name of the schema that matched, or null if no schema matched.
47
-
48
- #### Defined in
49
-
50
- [types.ts:46](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L46)
51
-
52
- ___
53
-
54
- ### validationErrors
55
-
56
- • `Optional` **validationErrors**: `any`[]
57
-
58
- Validation errors if any, or undefined if validation passed.
59
-
60
- #### Defined in
61
-
62
- [types.ts:56](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L56)
1
+ [@solvers-hub/llm-json](../README.md) / [Exports](../modules.md) / ValidationResult
2
+
3
+ # Interface: ValidationResult
4
+
5
+ Result of schema validation for a JSON object.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [isValid](ValidationResult.md#isvalid)
12
+ - [json](ValidationResult.md#json)
13
+ - [matchedSchema](ValidationResult.md#matchedschema)
14
+ - [validationErrors](ValidationResult.md#validationerrors)
15
+
16
+ ## Properties
17
+
18
+ ### isValid
19
+
20
+ • **isValid**: `boolean`
21
+
22
+ Whether the JSON is valid according to the matched schema.
23
+
24
+ #### Defined in
25
+
26
+ [types.ts:51](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L51)
27
+
28
+ ___
29
+
30
+ ### json
31
+
32
+ • **json**: `any`
33
+
34
+ The JSON object that was validated.
35
+
36
+ #### Defined in
37
+
38
+ [types.ts:41](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L41)
39
+
40
+ ___
41
+
42
+ ### matchedSchema
43
+
44
+ • **matchedSchema**: ``null`` \| `string`
45
+
46
+ The name of the schema that matched, or null if no schema matched.
47
+
48
+ #### Defined in
49
+
50
+ [types.ts:46](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L46)
51
+
52
+ ___
53
+
54
+ ### validationErrors
55
+
56
+ • `Optional` **validationErrors**: `any`[]
57
+
58
+ Validation errors if any, or undefined if validation passed.
59
+
60
+ #### Defined in
61
+
62
+ [types.ts:56](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L56)