@solvers-hub/llm-json 0.1.6 → 0.1.7

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.
package/docs-md/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  A TypeScript SDK for extracting and correcting JSON data from LLM outputs.
6
6
 
7
- [![npm version](https://badge.fury.io/js/llm-json.svg)](https://badge.fury.io/js/llm-json)
7
+ [![npm version](https://badge.fury.io/js/llm-json.svg)](https://badge.fury.io/js/llm-json)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
9
 
10
10
  ## Overview
@@ -13,47 +13,96 @@ LLM-JSON is a lightweight library designed to parse and extract JSON objects fro
13
13
 
14
14
  ## Key Features
15
15
 
16
- - **Text/JSON Separation**: Cleanly separates text content from JSON data in LLM outputs
17
- - **Multiple JSON Support**: Extracts multiple JSON objects or arrays from a single input
18
- - **JSON Validation & Correction**: Automatically fixes common JSON formatting errors from LLMs
19
- - **Code Block Support**: Extracts JSON from markdown code blocks (```json)
16
+ - **Text/JSON Separation**: Cleanly separates text content from JSON data in LLM outputs
17
+ - **Multiple JSON Support**: Extracts multiple JSON objects or arrays from a single input
18
+ - **JSON Validation & Correction**: Automatically fixes common JSON formatting errors from LLMs
19
+ - **Code Block Support**: Extracts JSON from markdown code blocks (```json)
20
+ - **Schema Validation**: Validates extracted JSON against provided schemas
20
21
  - **TypeScript Support**: Written in TypeScript with full type definitions
21
22
 
22
23
  ## Quick Start
23
24
 
24
25
  ### Installation
25
26
 
26
- ```bash
27
- npm install llm-json
27
+ ```bash
28
+ npm install @solvers-hub/llm-json
28
29
  ```
29
30
 
30
31
  ### Basic Usage
31
32
 
32
- ```typescript
33
- import { LlmJson } from 'llm-json';
33
+ ```typescript
34
+ import { LlmJson } from '@solvers-hub/llm-json';
34
35
 
35
36
  const llmOutput = `Here's some text followed by JSON:
36
37
 
37
- {
38
- "name": "John",
39
- "age": 30,
40
- "skills": ["JavaScript", "TypeScript", "React"]
38
+ {
39
+ "name": "John",
40
+ "age": 30,
41
+ "skills": ["JavaScript", "TypeScript", "React"]
41
42
  }`;
42
43
 
43
- const llmJson = new LlmJson({ attemptCorrection: true });
44
+ const llmJson = new LlmJson({ attemptCorrection: true });
44
45
  const { text, json } = llmJson.extract(llmOutput);
45
46
 
46
- console.log(text); // ['Here\'s some text followed by JSON:']
47
- console.log(json); // [{ name: 'John', age: 30, skills: ['JavaScript', 'TypeScript', 'React'] }]
47
+ console.log(text); // ['Here\'s some text followed by JSON:']
48
+ console.log(json); // [{ name: 'John', age: 30, skills: ['JavaScript', 'TypeScript', 'React'] }]
48
49
  ```
49
50
 
50
- ## Documentation
51
+ ### Schema Validation
52
+
53
+ You can validate extracted JSON against schemas:
54
+
55
+ ```typescript
56
+ import { LlmJson } from '@solvers-hub/llm-json';
57
+
58
+ const schemas = [
59
+ {
60
+ name: 'person',
61
+ schema: {
62
+ type: 'object',
63
+ properties: {
64
+ name: { type: 'string' },
65
+ age: { type: 'integer' }
66
+ },
67
+ required: ['name', 'age']
68
+ }
69
+ }
70
+ ];
71
+
72
+ const llmJson = new LlmJson({
73
+ attemptCorrection: true,
74
+ schemas
75
+ });
76
+
77
+ const llmOutput = `Here's a person: {"name": "John", "age": 30}
78
+ And some other data: {"title": "Meeting notes"}`;
79
+ const result = llmJson.extract(llmOutput);
80
+
81
+ // Note: All extracted JSON objects are included in the json array
82
+ console.log(result.json);
83
+ // [
84
+ // { name: 'John', age: 30 },
85
+ // { title: 'Meeting notes' }
86
+ // ]
87
+
88
+ // The validatedJson array includes validation results for each JSON object
89
+ console.log(result.validatedJson);
90
+ // [
91
+ // {
92
+ // json: { name: 'John', age: 30 },
93
+ // matchedSchema: 'person',
94
+ // isValid: true
95
+ // },
96
+ // {
97
+ // json: { title: 'Meeting notes' },
98
+ // matchedSchema: null,
99
+ // isValid: false,
100
+ // validationErrors: [...] // Validation errors
101
+ // }
102
+ // ]
51
103
 
52
- For detailed documentation including API references and examples:
53
-
54
- - [API Documentation](./docs/README.md)
55
- - [Examples](./docs/examples.md)
104
+ ```
56
105
 
57
106
  ## License
58
107
 
59
- MIT © 2023
108
+ MIT © 2025
@@ -42,7 +42,7 @@ Creates a new LlmJson instance with the specified options.
42
42
 
43
43
  #### Defined in
44
44
 
45
- [index.ts:17](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L17)
45
+ [index.ts:17](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L17)
46
46
 
47
47
  ## Properties
48
48
 
@@ -52,7 +52,7 @@ Creates a new LlmJson instance with the specified options.
52
52
 
53
53
  #### Defined in
54
54
 
55
- [index.ts:11](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L11)
55
+ [index.ts:11](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L11)
56
56
 
57
57
  ___
58
58
 
@@ -62,7 +62,7 @@ ___
62
62
 
63
63
  #### Defined in
64
64
 
65
- [index.ts:10](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L10)
65
+ [index.ts:10](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L10)
66
66
 
67
67
  ___
68
68
 
@@ -72,7 +72,7 @@ ___
72
72
 
73
73
  #### Defined in
74
74
 
75
- [index.ts:9](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L9)
75
+ [index.ts:9](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L9)
76
76
 
77
77
  ## Methods
78
78
 
@@ -96,7 +96,7 @@ An object containing arrays of extracted text and JSON.
96
96
 
97
97
  #### Defined in
98
98
 
99
- [index.ts:39](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L39)
99
+ [index.ts:39](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L39)
100
100
 
101
101
  ___
102
102
 
@@ -120,7 +120,7 @@ An object containing arrays of extracted text and JSON.
120
120
 
121
121
  #### Defined in
122
122
 
123
- [index.ts:48](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L48)
123
+ [index.ts:48](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L48)
124
124
 
125
125
  ___
126
126
 
@@ -144,4 +144,4 @@ The LlmJson singleton instance.
144
144
 
145
145
  #### Defined in
146
146
 
147
- [index.ts:27](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/index.ts#L27)
147
+ [index.ts:27](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/index.ts#L27)
@@ -9,6 +9,7 @@ Options for JSON extraction.
9
9
  ### Properties
10
10
 
11
11
  - [attemptCorrection](ExtractOptions.md#attemptcorrection)
12
+ - [schemas](ExtractOptions.md#schemas)
12
13
 
13
14
  ## Properties
14
15
 
@@ -26,4 +27,23 @@ false
26
27
 
27
28
  #### Defined in
28
29
 
29
- [types.ts:9](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L9)
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
+ 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)
@@ -10,6 +10,7 @@ Result of the JSON extraction.
10
10
 
11
11
  - [json](ExtractResult.md#json)
12
12
  - [text](ExtractResult.md#text)
13
+ - [validatedJson](ExtractResult.md#validatedjson)
13
14
 
14
15
  ## Properties
15
16
 
@@ -21,7 +22,7 @@ Array of parsed JSON objects extracted from the input.
21
22
 
22
23
  #### Defined in
23
24
 
24
- [types.ts:24](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L24)
25
+ [types.ts:71](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L71)
25
26
 
26
27
  ___
27
28
 
@@ -33,4 +34,16 @@ Array of text blocks extracted from the input.
33
34
 
34
35
  #### Defined in
35
36
 
36
- [types.ts:19](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L19)
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)
@@ -24,7 +24,7 @@ The end index of the JSON block in the input string.
24
24
 
25
25
  #### Defined in
26
26
 
27
- [types.ts:44](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L44)
27
+ [types.ts:96](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L96)
28
28
 
29
29
  ___
30
30
 
@@ -36,7 +36,7 @@ The parsed JSON object.
36
36
 
37
37
  #### Defined in
38
38
 
39
- [types.ts:54](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L54)
39
+ [types.ts:106](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L106)
40
40
 
41
41
  ___
42
42
 
@@ -48,7 +48,7 @@ The raw JSON string.
48
48
 
49
49
  #### Defined in
50
50
 
51
- [types.ts:34](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L34)
51
+ [types.ts:86](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L86)
52
52
 
53
53
  ___
54
54
 
@@ -60,7 +60,7 @@ The start index of the JSON block in the input string.
60
60
 
61
61
  #### Defined in
62
62
 
63
- [types.ts:39](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L39)
63
+ [types.ts:91](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L91)
64
64
 
65
65
  ___
66
66
 
@@ -72,4 +72,4 @@ Whether the JSON was corrected.
72
72
 
73
73
  #### Defined in
74
74
 
75
- [types.ts:49](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L49)
75
+ [types.ts:101](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L101)
@@ -22,7 +22,7 @@ The original error message.
22
22
 
23
23
  #### Defined in
24
24
 
25
- [types.ts:64](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L64)
25
+ [types.ts:116](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L116)
26
26
 
27
27
  ___
28
28
 
@@ -34,7 +34,7 @@ The position in the JSON string where the error occurred.
34
34
 
35
35
  #### Defined in
36
36
 
37
- [types.ts:74](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L74)
37
+ [types.ts:126](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L126)
38
38
 
39
39
  ___
40
40
 
@@ -46,4 +46,4 @@ The raw JSON string that failed to parse.
46
46
 
47
47
  #### Defined in
48
48
 
49
- [types.ts:69](https://github.com/solvers-hub/llm-json/blob/4d60f7fa6cdcace0d353b33e3d79c6fd33db1860/src/types.ts#L69)
49
+ [types.ts:121](https://github.com/solvers-hub/llm-json/blob/6d8d00890ee1d42b63f8bb8c3f6401333e41041e/src/types.ts#L121)
@@ -0,0 +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)
@@ -0,0 +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)
@@ -18,6 +18,8 @@
18
18
  - [ExtractResult](interfaces/ExtractResult.md)
19
19
  - [JsonBlock](interfaces/JsonBlock.md)
20
20
  - [JsonParseError](interfaces/JsonParseError.md)
21
+ - [SchemaDefinition](interfaces/SchemaDefinition.md)
22
+ - [ValidationResult](interfaces/ValidationResult.md)
21
23
 
22
24
  ## References
23
25
 
@@ -0,0 +1,69 @@
1
+ import LlmJson from '../src/index';
2
+
3
+ /**
4
+ * Example demonstrating how to use the LLM-JSON library for arrays.
5
+ */
6
+ function runArrayExample() {
7
+ // Create an instance with auto-correction enabled
8
+ const llmJson = new LlmJson({ attemptCorrection: true });
9
+
10
+ // Simple array example
11
+ const simpleArrayInput = `Here is a list of names: ["John", "Jane", "Bob"]`;
12
+
13
+ console.log("=== Simple Array Example ===");
14
+
15
+ // Using extract - might not properly handle standalone arrays
16
+ const simpleExtractResult = llmJson.extract(simpleArrayInput);
17
+ console.log("With extract():");
18
+ console.log("Text:", simpleExtractResult.text);
19
+ console.log("JSON:", JSON.stringify(simpleExtractResult.json, null, 2));
20
+ console.log();
21
+
22
+ // Using extractAll - properly handles arrays
23
+ const simpleExtractAllResult = llmJson.extractAll(simpleArrayInput);
24
+ console.log("With extractAll():");
25
+ console.log("Text:", simpleExtractAllResult.text);
26
+ console.log("JSON:", JSON.stringify(simpleExtractAllResult.json, null, 2));
27
+ console.log();
28
+
29
+ // Complex array example
30
+ const complexArrayInput = `Here's an array of users:
31
+ [
32
+ {
33
+ "name": "John Doe",
34
+ "age": 30,
35
+ "skills": ["JavaScript", "TypeScript"]
36
+ },
37
+ {
38
+ "name": "Jane Smith",
39
+ "age": 28,
40
+ "skills": ["Python", "Machine Learning"]
41
+ }
42
+ ]`;
43
+
44
+ console.log("=== Complex Array Example ===");
45
+
46
+ // Using extractAll - properly handles complex arrays
47
+ const complexResult = llmJson.extractAll(complexArrayInput);
48
+ console.log("With extractAll():");
49
+ console.log("Text:", complexResult.text);
50
+ console.log("JSON:", JSON.stringify(complexResult.json, null, 2));
51
+ console.log();
52
+
53
+ // Multiple JSON structures example
54
+ const mixedInput = `Here's an object: {"name": "John", "age": 30}
55
+
56
+ And here's an array: [1, 2, 3, 4, 5]
57
+
58
+ And another object: {"city": "New York", "country": "USA"}`;
59
+
60
+ console.log("=== Mixed JSON Types Example ===");
61
+
62
+ // Using extractAll - handles both objects and arrays
63
+ const mixedResult = llmJson.extractAll(mixedInput);
64
+ console.log("With extractAll():");
65
+ console.log("Text:", mixedResult.text);
66
+ console.log("JSON:", JSON.stringify(mixedResult.json, null, 2));
67
+ }
68
+
69
+ runArrayExample();
@@ -0,0 +1,101 @@
1
+ import LlmJson from '../src/index';
2
+
3
+ /**
4
+ * Example demonstrating how to use the LLM-JSON library.
5
+ */
6
+ function runExample() {
7
+ // Create an instance with auto-correction enabled
8
+ const llmJson = new LlmJson({ attemptCorrection: true });
9
+
10
+ // Example from the requirements
11
+ const input = `<research_planning>
12
+ a. Summary: The given organization is unnamed and works in the area of "something new," which suggests an innovative or emerging field. This could involve novel technologies, fresh market approaches, or unexplored domains. Without specific details, assumptions about the sector or industry may involve startups, tech innovation, or trendsetting industries. The focus and goals may lean toward exploration, user adoption, and refinement of novel concepts.
13
+
14
+ b. Potential Product Features:
15
+ - Exploration of new technologies (VR/AR interfaces, IoT integration)
16
+ - User onboarding and education tools
17
+ - Novel interaction models or user interfaces
18
+ - Feedback and improvement loops
19
+ - Community engagement and collaboration spaces
20
+
21
+ c. User Persona: Considering the organization's innovative nature, the primary user could be an early adopter, tech-savvy individual who is curious and willing to explore new technologies. This persona is likely someone who enjoys experimenting with novel ideas and is motivated by the excitement of participating in pioneering efforts.
22
+ Study Name: "Demo - Innovator Insight"
23
+
24
+ d. Potential Research Objectives:
25
+ - Evaluate user onboarding process effectiveness in helping users understand the product's novel features.
26
+ - Assess user engagement with community collaboration spaces to identify areas for increased interaction.
27
+ - Verify the intuitiveness of new interaction models and user interfaces.
28
+ - Explore user satisfaction with feedback and improvement loops.
29
+ - Measure the impact of educational tools on user empowerment and confidence.
30
+ - Analyze user behavior patterns to refine product workflows.
31
+ - Investigate potential barriers to user adoption and retention.
32
+
33
+ e. Narrowing Down Objectives:
34
+ After considering the potential research objectives, the focus shifted towards objectives that can be directly evaluated through a live web application. The final objectives chosen were geared towards user onboarding, interaction intuitiveness, and community engagement, as they align with the persona of an early adopter and focus on improving user experience in areas relevant to the organization's innovative nature.
35
+ </research_planning>
36
+
37
+ \`\`\`json
38
+ {
39
+ "studyName": "Demo - Innovator Insight",
40
+ "userPersona": "Tech-savvy early adopter exploring new innovations.",
41
+ "objectives": [
42
+ {
43
+ "objectiveTitle": "Onboarding Process Evaluation",
44
+ "objectiveDescription": "Assess the effectiveness of the user onboarding process in enabling users to grasp the novel features of the product quickly and efficiently, ensuring that it enhances initial user engagement and reduces learning curves."
45
+ },
46
+ {
47
+ "objectiveTitle": "Community Interaction Analysis",
48
+ "objectiveDescription": "Investigate user engagement within community collaboration spaces, identifying potential improvements to foster more interaction, sharing, and collaboration among users, enhancing overall community dynamics."
49
+ },
50
+ {
51
+ "objectiveTitle": "Interface Intuition Verification",
52
+ "objectiveDescription": "Verify the intuitiveness of new interaction models and user interfaces, focusing on how users adapt and navigate through the product, aiming to identify any areas needing refinement for better usability."
53
+ }
54
+ ]
55
+ }
56
+ \`\`\``;
57
+
58
+ // Extract JSON and text
59
+ const result = llmJson.extract(input);
60
+
61
+ console.log("Extracted text:");
62
+ console.log("------------------");
63
+ result.text.forEach((text, index) => {
64
+ console.log(`Text block ${index + 1}:`);
65
+ console.log(text);
66
+ console.log();
67
+ });
68
+
69
+ console.log("Extracted JSON:");
70
+ console.log("------------------");
71
+ result.json.forEach((json, index) => {
72
+ console.log(`JSON object ${index + 1}:`);
73
+ console.log(JSON.stringify(json, null, 2));
74
+ console.log();
75
+ });
76
+
77
+ // Example with malformed JSON
78
+ console.log("\nExample with malformed JSON:");
79
+ console.log("---------------------------");
80
+
81
+ const malformedInput = `Here is some information:
82
+
83
+ {
84
+ name: "John",
85
+ age: 30,
86
+ skills: ["JavaScript", "TypeScript"],
87
+ preferences: {
88
+ theme: "dark",
89
+ notifications: true,
90
+ }
91
+ }`;
92
+
93
+ const malformedResult = llmJson.extract(malformedInput);
94
+
95
+ console.log("Text:");
96
+ console.log(malformedResult.text[0]);
97
+ console.log("\nCorrected JSON:");
98
+ console.log(JSON.stringify(malformedResult.json[0], null, 2));
99
+ }
100
+
101
+ runExample();