vv-ai-prompt-format 3.0.0

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 (44) hide show
  1. package/LICENSE +21 -0
  2. package/dist/src/checkJsonSchema.d.ts +31 -0
  3. package/dist/src/checkJsonSchema.d.ts.map +1 -0
  4. package/dist/src/checkJsonSchema.js +45 -0
  5. package/dist/src/checkJsonSchema.js.map +1 -0
  6. package/dist/src/convertJsonSchemaToGbnf.d.ts +44 -0
  7. package/dist/src/convertJsonSchemaToGbnf.d.ts.map +1 -0
  8. package/dist/src/convertJsonSchemaToGbnf.js +89 -0
  9. package/dist/src/convertJsonSchemaToGbnf.js.map +1 -0
  10. package/dist/src/index.d.ts +16 -0
  11. package/dist/src/index.d.ts.map +1 -0
  12. package/dist/src/index.js +8 -0
  13. package/dist/src/index.js.map +1 -0
  14. package/dist/src/promtLoad.d.ts +37 -0
  15. package/dist/src/promtLoad.d.ts.map +1 -0
  16. package/dist/src/promtLoad.js +221 -0
  17. package/dist/src/promtLoad.js.map +1 -0
  18. package/dist/src/promtOptions/index.d.ts +99 -0
  19. package/dist/src/promtOptions/index.d.ts.map +1 -0
  20. package/dist/src/promtOptions/index.js +48 -0
  21. package/dist/src/promtOptions/index.js.map +1 -0
  22. package/dist/src/promtOptions/value.d.ts +66 -0
  23. package/dist/src/promtOptions/value.d.ts.map +1 -0
  24. package/dist/src/promtOptions/value.js +134 -0
  25. package/dist/src/promtOptions/value.js.map +1 -0
  26. package/dist/src/promtOptionsParse.d.ts +22 -0
  27. package/dist/src/promtOptionsParse.d.ts.map +1 -0
  28. package/dist/src/promtOptionsParse.js +54 -0
  29. package/dist/src/promtOptionsParse.js.map +1 -0
  30. package/dist/src/promtStore.d.ts +40 -0
  31. package/dist/src/promtStore.d.ts.map +1 -0
  32. package/dist/src/promtStore.js +83 -0
  33. package/dist/src/promtStore.js.map +1 -0
  34. package/dist/src/toPromtOptions.d.ts +129 -0
  35. package/dist/src/toPromtOptions.d.ts.map +1 -0
  36. package/dist/src/toPromtOptions.js +252 -0
  37. package/dist/src/toPromtOptions.js.map +1 -0
  38. package/dist/test/index.test.d.ts +2 -0
  39. package/dist/test/index.test.d.ts.map +1 -0
  40. package/dist/test/index.test.js +692 -0
  41. package/dist/test/index.test.js.map +1 -0
  42. package/package.json +43 -0
  43. package/readme.md +313 -0
  44. package/readme.rus.md +313 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Vitalii Vasilev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Validates JSON Schema string using AJV validator.
3
+ *
4
+ * @param raw - JSON Schema string to validate
5
+ * @returns `undefined` if schema is valid, error message string if invalid
6
+ *
7
+ * @remarks
8
+ * This function:
9
+ * - Parses the JSON string to verify it's valid JSON
10
+ * - Validates the schema structure using AJV (Another JSON Schema Validator)
11
+ * - Checks for valid JSON Schema keywords and structure
12
+ * - Returns `undefined` for valid schemas (including empty input)
13
+ * - Returns error message for invalid JSON or invalid schema structure
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const result1 = CheckJsonSchema('{"type": "object", "properties": {}}')
18
+ * // Returns: undefined (valid schema)
19
+ *
20
+ * const result2 = CheckJsonSchema('{"type": "object1"}')
21
+ * // Returns: error message (invalid type)
22
+ *
23
+ * const result3 = CheckJsonSchema('invalid json')
24
+ * // Returns: error message (invalid JSON)
25
+ *
26
+ * const result4 = CheckJsonSchema('')
27
+ * // Returns: undefined (empty input)
28
+ * ```
29
+ */
30
+ export declare function CheckJsonSchema(raw: string): string | undefined;
31
+ //# sourceMappingURL=checkJsonSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkJsonSchema.d.ts","sourceRoot":"","sources":["../../src/checkJsonSchema.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAa/D"}
@@ -0,0 +1,45 @@
1
+ import { Ajv } from 'ajv';
2
+ /**
3
+ * Validates JSON Schema string using AJV validator.
4
+ *
5
+ * @param raw - JSON Schema string to validate
6
+ * @returns `undefined` if schema is valid, error message string if invalid
7
+ *
8
+ * @remarks
9
+ * This function:
10
+ * - Parses the JSON string to verify it's valid JSON
11
+ * - Validates the schema structure using AJV (Another JSON Schema Validator)
12
+ * - Checks for valid JSON Schema keywords and structure
13
+ * - Returns `undefined` for valid schemas (including empty input)
14
+ * - Returns error message for invalid JSON or invalid schema structure
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const result1 = CheckJsonSchema('{"type": "object", "properties": {}}')
19
+ * // Returns: undefined (valid schema)
20
+ *
21
+ * const result2 = CheckJsonSchema('{"type": "object1"}')
22
+ * // Returns: error message (invalid type)
23
+ *
24
+ * const result3 = CheckJsonSchema('invalid json')
25
+ * // Returns: error message (invalid JSON)
26
+ *
27
+ * const result4 = CheckJsonSchema('')
28
+ * // Returns: undefined (empty input)
29
+ * ```
30
+ */
31
+ export function CheckJsonSchema(raw) {
32
+ if (!raw || raw.trim() === '') {
33
+ return undefined;
34
+ }
35
+ try {
36
+ const json = JSON.parse(raw);
37
+ const ajv = new Ajv({ strict: false, allErrors: true });
38
+ ajv.compile(json);
39
+ return undefined;
40
+ }
41
+ catch (err) {
42
+ return `${err}`;
43
+ }
44
+ }
45
+ //# sourceMappingURL=checkJsonSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkJsonSchema.js","sourceRoot":"","sources":["../../src/checkJsonSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW;IAC1C,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/B,OAAO,SAAS,CAAA;IACjB,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC5B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QACvD,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACjB,OAAO,SAAS,CAAA;IACjB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,GAAG,GAAG,EAAE,CAAA;IAChB,CAAC;AACF,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Converts JSON Schema to GBNF (Grammar BNF) format for node-llama-cpp.
3
+ *
4
+ * @param schema - JSON Schema object to convert
5
+ * @returns Object with either `error` string or `result` containing converted GBNF grammar
6
+ *
7
+ * @remarks
8
+ * This function converts JSON Schema to GBNF format used by node-llama-cpp for structured output.
9
+ *
10
+ * Supported JSON Schema types:
11
+ * - `object` with `properties` and `additionalProperties`
12
+ * - `array` with `items`
13
+ * - Primitive types: `string`, `number`, `integer`, `boolean`, `null`
14
+ * - `enum` for enumerated values
15
+ * - `const` for constant values
16
+ *
17
+ * The function returns a discriminated union:
18
+ * - On success: `{ result: any }` - contains the converted GBNF grammar object
19
+ * - On error: `{ error: string }` - contains the error message
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const schema = {
24
+ * type: 'object',
25
+ * properties: {
26
+ * name: { type: 'string' },
27
+ * age: { type: 'integer' }
28
+ * }
29
+ * }
30
+ *
31
+ * const result = ConvertJsonSchemaToGbnf(schema)
32
+ * if ('result' in result) {
33
+ * console.log(result.result) // GBNF grammar object
34
+ * } else {
35
+ * console.error(result.error) // Error message
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function ConvertJsonSchemaToGbnf(schema: any): {
40
+ error: string;
41
+ } | {
42
+ result: any;
43
+ };
44
+ //# sourceMappingURL=convertJsonSchemaToGbnf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertJsonSchemaToGbnf.d.ts","sourceRoot":"","sources":["../../src/convertJsonSchemaToGbnf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,GAAG,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,GAAG,CAAA;CAAE,CAOxF"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Converts JSON Schema to GBNF (Grammar BNF) format for node-llama-cpp.
3
+ *
4
+ * @param schema - JSON Schema object to convert
5
+ * @returns Object with either `error` string or `result` containing converted GBNF grammar
6
+ *
7
+ * @remarks
8
+ * This function converts JSON Schema to GBNF format used by node-llama-cpp for structured output.
9
+ *
10
+ * Supported JSON Schema types:
11
+ * - `object` with `properties` and `additionalProperties`
12
+ * - `array` with `items`
13
+ * - Primitive types: `string`, `number`, `integer`, `boolean`, `null`
14
+ * - `enum` for enumerated values
15
+ * - `const` for constant values
16
+ *
17
+ * The function returns a discriminated union:
18
+ * - On success: `{ result: any }` - contains the converted GBNF grammar object
19
+ * - On error: `{ error: string }` - contains the error message
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const schema = {
24
+ * type: 'object',
25
+ * properties: {
26
+ * name: { type: 'string' },
27
+ * age: { type: 'integer' }
28
+ * }
29
+ * }
30
+ *
31
+ * const result = ConvertJsonSchemaToGbnf(schema)
32
+ * if ('result' in result) {
33
+ * console.log(result.result) // GBNF grammar object
34
+ * } else {
35
+ * console.error(result.error) // Error message
36
+ * }
37
+ * ```
38
+ */
39
+ export function ConvertJsonSchemaToGbnf(schema) {
40
+ try {
41
+ const converted = convertJsonSchemaToGbnfInternal(schema);
42
+ return { result: converted };
43
+ }
44
+ catch (err) {
45
+ return { error: `${err}` };
46
+ }
47
+ }
48
+ function convertJsonSchemaToGbnfInternal(schema) {
49
+ if (schema.type === 'array' && schema.items) {
50
+ return {
51
+ type: 'array',
52
+ items: convertJsonSchemaToGbnfInternal(schema.items),
53
+ };
54
+ }
55
+ if (schema.type === 'object' && schema.properties) {
56
+ const properties = {};
57
+ for (const [key, value] of Object.entries(schema.properties)) {
58
+ properties[key] = convertJsonSchemaToGbnfInternal(value);
59
+ }
60
+ return {
61
+ type: 'object',
62
+ properties,
63
+ additionalProperties: schema.additionalProperties === true ? true : false,
64
+ };
65
+ }
66
+ if (schema.type === 'string') {
67
+ return { type: 'string' };
68
+ }
69
+ if (schema.type === 'number') {
70
+ return { type: 'number' };
71
+ }
72
+ if (schema.type === 'integer') {
73
+ return { type: 'integer' };
74
+ }
75
+ if (schema.type === 'boolean') {
76
+ return { type: 'boolean' };
77
+ }
78
+ if (schema.type === 'null') {
79
+ return { type: 'null' };
80
+ }
81
+ if (schema.enum) {
82
+ return { enum: schema.enum };
83
+ }
84
+ if (schema.const !== undefined) {
85
+ return { const: schema.const };
86
+ }
87
+ throw new Error(`Unsupported JSON Schema format: ${JSON.stringify(schema)}`);
88
+ }
89
+ //# sourceMappingURL=convertJsonSchemaToGbnf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertJsonSchemaToGbnf.js","sourceRoot":"","sources":["../../src/convertJsonSchemaToGbnf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAW;IAClD,IAAI,CAAC;QACJ,MAAM,SAAS,GAAG,+BAA+B,CAAC,MAAM,CAAC,CAAA;QACzD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAA;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,EAAE,KAAK,EAAE,GAAG,GAAG,EAAE,EAAE,CAAA;IAC3B,CAAC;AACF,CAAC;AAED,SAAS,+BAA+B,CAAC,MAAW;IACnD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC7C,OAAO;YACN,IAAI,EAAE,OAAgB;YACtB,KAAK,EAAE,+BAA+B,CAAC,MAAM,CAAC,KAAK,CAAC;SACpD,CAAA;IACF,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACnD,MAAM,UAAU,GAAwB,EAAE,CAAA;QAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9D,UAAU,CAAC,GAAG,CAAC,GAAG,+BAA+B,CAAC,KAAY,CAAC,CAAA;QAChE,CAAC;QAED,OAAO;YACN,IAAI,EAAE,QAAiB;YACvB,UAAU;YACV,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;SACzE,CAAA;IACF,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAA;IACnC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,QAAiB,EAAE,CAAA;IACnC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,SAAkB,EAAE,CAAA;IACpC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,IAAI,EAAE,SAAkB,EAAE,CAAA;IACpC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,MAAe,EAAE,CAAA;IACjC,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAqD,EAAE,CAAA;IAC9E,CAAC;IACD,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAA;IAC/B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAC7E,CAAC"}
@@ -0,0 +1,16 @@
1
+ export { TPromtOptions, TPromtOptionsOpenAi, TPromtOptionsOllama, TPromtOptionsLlamaCpp, SPromtOptions, SPromtOptionsJson, defVal, defValJson, } from './promtOptions/index.js';
2
+ export { CheckJsonSchema } from './checkJsonSchema.js';
3
+ export { PromtOptionsParse } from './promtOptionsParse.js';
4
+ export { PromtLoad } from './promtLoad.js';
5
+ export { PromtStore } from './promtStore.js';
6
+ export { ToPromtOptionsOpenAi, ToPromtOptionsOllama, ToPromtOptionsLlamaCpp } from './toPromtOptions.js';
7
+ export { ConvertJsonSchemaToGbnf } from './convertJsonSchemaToGbnf.js';
8
+ export type TPromt = {
9
+ system?: string;
10
+ user: string;
11
+ options?: TPromtOptions;
12
+ segment?: Record<string, string>;
13
+ jsonresponse?: string;
14
+ };
15
+ import { TPromtOptions } from './promtOptions/index.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,UAAU,GACV,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA;AAEtE,MAAM,MAAM,MAAM,GAAG;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { SPromtOptions, SPromtOptionsJson, defVal, defValJson, } from './promtOptions/index.js';
2
+ export { CheckJsonSchema } from './checkJsonSchema.js';
3
+ export { PromtOptionsParse } from './promtOptionsParse.js';
4
+ export { PromtLoad } from './promtLoad.js';
5
+ export { PromtStore } from './promtStore.js';
6
+ export { ToPromtOptionsOpenAi, ToPromtOptionsOllama, ToPromtOptionsLlamaCpp } from './toPromtOptions.js';
7
+ export { ConvertJsonSchemaToGbnf } from './convertJsonSchemaToGbnf.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKN,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,UAAU,GACV,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1,37 @@
1
+ import { TPromt } from './index.js';
2
+ /**
3
+ * Loads and parses prompts from a text string with structured sections.
4
+ *
5
+ * @param raw - Raw text string containing prompts in the format with $$begin/$$end markers
6
+ * @param use - Schema type for options validation: 'core' for standard AI models, 'json' for structured JSON output (default: 'core')
7
+ * @returns Array of parsed TPromt objects
8
+ *
9
+ * @remarks
10
+ * Text format supports the following sections:
11
+ * - `$$begin` / `$$end` - Marks prompt boundaries
12
+ * - `$$system` - System message (optional)
13
+ * - `$$user` - User message (required)
14
+ * - `$$options` - Model parameters in key=value format (optional)
15
+ * - `$$jsonresponse` - JSON Schema for structured response output (optional)
16
+ * - `$$segment=name` - Named content segments (optional)
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const text = `$$begin
21
+ * $$options
22
+ * temperature=0.7
23
+ * maxTokens=2048
24
+ * $$system
25
+ * You are a helpful assistant
26
+ * $$user
27
+ * Hello, world!
28
+ * $$jsonresponse
29
+ * {"type": "object", "properties": {}}
30
+ * $$end`
31
+ *
32
+ * const prompts = PromtLoad(text)
33
+ * // Returns: [{ system: '...', user: '...', options: {...}, jsonresponse: '...' }]
34
+ * ```
35
+ */
36
+ export declare function PromtLoad(raw: string, use?: 'core' | 'json'): TPromt[];
37
+ //# sourceMappingURL=promtLoad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promtLoad.d.ts","sourceRoot":"","sources":["../../src/promtLoad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAA;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,MAAM,GAAG,MAAe,GAAG,MAAM,EAAE,CAE9E"}
@@ -0,0 +1,221 @@
1
+ import { PromtOptionsParse } from './promtOptionsParse.js';
2
+ /**
3
+ * Loads and parses prompts from a text string with structured sections.
4
+ *
5
+ * @param raw - Raw text string containing prompts in the format with $$begin/$$end markers
6
+ * @param use - Schema type for options validation: 'core' for standard AI models, 'json' for structured JSON output (default: 'core')
7
+ * @returns Array of parsed TPromt objects
8
+ *
9
+ * @remarks
10
+ * Text format supports the following sections:
11
+ * - `$$begin` / `$$end` - Marks prompt boundaries
12
+ * - `$$system` - System message (optional)
13
+ * - `$$user` - User message (required)
14
+ * - `$$options` - Model parameters in key=value format (optional)
15
+ * - `$$jsonresponse` - JSON Schema for structured response output (optional)
16
+ * - `$$segment=name` - Named content segments (optional)
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const text = `$$begin
21
+ * $$options
22
+ * temperature=0.7
23
+ * maxTokens=2048
24
+ * $$system
25
+ * You are a helpful assistant
26
+ * $$user
27
+ * Hello, world!
28
+ * $$jsonresponse
29
+ * {"type": "object", "properties": {}}
30
+ * $$end`
31
+ *
32
+ * const prompts = PromtLoad(text)
33
+ * // Returns: [{ system: '...', user: '...', options: {...}, jsonresponse: '...' }]
34
+ * ```
35
+ */
36
+ export function PromtLoad(raw, use = 'core') {
37
+ return parse(raw, use);
38
+ }
39
+ function parse(content, use) {
40
+ const lines = content.split('\n');
41
+ const promts = [];
42
+ let inBlock = false;
43
+ let currentPromt = null;
44
+ let currentSection = null;
45
+ let currentSegmentName = null;
46
+ let sectionContent = [];
47
+ for (let i = 0; i < lines.length; i++) {
48
+ const line = lines[i];
49
+ const trimmed = line.trim();
50
+ if (trimmed === '$$begin') {
51
+ if (inBlock && currentPromt) {
52
+ if (currentSection && sectionContent.length > 0) {
53
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
54
+ }
55
+ if (currentPromt.user) {
56
+ promts.push(currentPromt);
57
+ }
58
+ }
59
+ inBlock = true;
60
+ currentPromt = {};
61
+ currentSection = null;
62
+ currentSegmentName = null;
63
+ sectionContent = [];
64
+ continue;
65
+ }
66
+ if (trimmed === '$$end') {
67
+ if (inBlock && currentPromt) {
68
+ if (currentSection && sectionContent.length > 0) {
69
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
70
+ }
71
+ if (currentPromt.user) {
72
+ promts.push(currentPromt);
73
+ }
74
+ }
75
+ inBlock = false;
76
+ currentPromt = null;
77
+ currentSection = null;
78
+ currentSegmentName = null;
79
+ sectionContent = [];
80
+ continue;
81
+ }
82
+ if (!inBlock || !currentPromt) {
83
+ continue;
84
+ }
85
+ if (trimmed === '$$system') {
86
+ if (currentSection && sectionContent.length > 0) {
87
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
88
+ }
89
+ currentSection = 'system';
90
+ currentSegmentName = null;
91
+ sectionContent = [];
92
+ continue;
93
+ }
94
+ if (trimmed === '$$user') {
95
+ if (currentSection && sectionContent.length > 0) {
96
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
97
+ }
98
+ currentSection = 'user';
99
+ currentSegmentName = null;
100
+ sectionContent = [];
101
+ continue;
102
+ }
103
+ if (trimmed === '$$options') {
104
+ if (currentSection && sectionContent.length > 0) {
105
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
106
+ }
107
+ currentSection = 'options';
108
+ currentSegmentName = null;
109
+ sectionContent = [];
110
+ continue;
111
+ }
112
+ if (trimmed === '$$jsonresponse') {
113
+ if (currentSection && sectionContent.length > 0) {
114
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
115
+ }
116
+ currentSection = 'jsonresponse';
117
+ currentSegmentName = null;
118
+ sectionContent = [];
119
+ continue;
120
+ }
121
+ if (trimmed.startsWith('$$segment=')) {
122
+ if (currentSection && sectionContent.length > 0) {
123
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
124
+ }
125
+ currentSection = 'segment';
126
+ currentSegmentName = trimmed.substring('$$segment='.length).trim();
127
+ sectionContent = [];
128
+ continue;
129
+ }
130
+ if (currentSection) {
131
+ sectionContent.push(line);
132
+ }
133
+ }
134
+ if (inBlock && currentPromt) {
135
+ if (currentSection && sectionContent.length > 0) {
136
+ finishSection(currentPromt, currentSection, sectionContent, use, currentSegmentName);
137
+ }
138
+ if (currentPromt.user) {
139
+ promts.push(currentPromt);
140
+ }
141
+ }
142
+ return promts;
143
+ }
144
+ function finishSection(promt, section, lines, use, segmentName) {
145
+ const content = lines.join('\n').trim();
146
+ if (section === 'system') {
147
+ promt.system = content;
148
+ }
149
+ else if (section === 'user') {
150
+ promt.user = content;
151
+ }
152
+ else if (section === 'segment' && segmentName) {
153
+ if (!promt.segment) {
154
+ promt.segment = {};
155
+ }
156
+ promt.segment[segmentName] = content;
157
+ }
158
+ else if (section === 'options') {
159
+ const rawOptions = parseOptionsToObject(content);
160
+ promt.options = PromtOptionsParse(use, rawOptions, false);
161
+ }
162
+ else if (section === 'jsonresponse') {
163
+ promt.jsonresponse = content;
164
+ }
165
+ }
166
+ function parseOptionsToObject(content) {
167
+ const options = {};
168
+ const lines = content.split('\n');
169
+ for (const line of lines) {
170
+ const trimmed = line.trim();
171
+ if (!trimmed)
172
+ continue;
173
+ const eqIndex = trimmed.indexOf('=');
174
+ if (eqIndex <= 0)
175
+ continue;
176
+ const key = trimmed.substring(0, eqIndex).trim();
177
+ const valueStr = trimmed.substring(eqIndex + 1).trim();
178
+ const value = parseOptionValue(valueStr);
179
+ if (value !== undefined) {
180
+ options[key] = value;
181
+ }
182
+ }
183
+ return options;
184
+ }
185
+ function parseOptionValue(valueStr) {
186
+ // Пустое значение = undefined
187
+ if (valueStr === '') {
188
+ return undefined;
189
+ }
190
+ // Убираем кавычки если есть
191
+ let cleanValue = valueStr;
192
+ if ((cleanValue.startsWith('"') && cleanValue.endsWith('"')) || (cleanValue.startsWith("'") && cleanValue.endsWith("'"))) {
193
+ cleanValue = cleanValue.slice(1, -1);
194
+ }
195
+ // Пробуем распарсить как JSON (для массивов и объектов)
196
+ if (valueStr.startsWith('[') || valueStr.startsWith('{')) {
197
+ try {
198
+ const parsed = JSON.parse(valueStr);
199
+ if (Array.isArray(parsed) || typeof parsed === 'object') {
200
+ return parsed;
201
+ }
202
+ }
203
+ catch (_a) {
204
+ // Игнорируем ошибку, попробуем другие варианты
205
+ }
206
+ }
207
+ // Boolean значения
208
+ const lower = cleanValue.toLowerCase();
209
+ if (lower === 'true' || lower === '1' || lower === 'y')
210
+ return true;
211
+ if (lower === 'false' || lower === '0' || lower === 'n')
212
+ return false;
213
+ // Числовые значения - заменяем запятую на точку
214
+ const numValue = cleanValue.replace(',', '.');
215
+ const parsed = parseFloat(numValue);
216
+ if (!isNaN(parsed)) {
217
+ return parsed;
218
+ }
219
+ return undefined;
220
+ }
221
+ //# sourceMappingURL=promtLoad.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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,GAAG,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QAC1H,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACrC,CAAC;IAED,wDAAwD;IACxD,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;YACnC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACzD,OAAO,MAAM,CAAA;YACd,CAAC;QACF,CAAC;QAAC,WAAM,CAAC;YACR,+CAA+C;QAChD,CAAC;IACF,CAAC;IAED,mBAAmB;IACnB,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;IACtC,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,IAAI,CAAA;IACnE,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,KAAK,CAAA;IAErE,gDAAgD;IAChD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACnC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAA;IACd,CAAC;IAED,OAAO,SAAS,CAAA;AACjB,CAAC"}
@@ -0,0 +1,99 @@
1
+ import { Static } from '@sinclair/typebox';
2
+ import { defVal, defValJson } from './value.js';
3
+ export { defVal, defValJson };
4
+ export declare const SPromtOptions: import("@sinclair/typebox").TObject<{
5
+ temperature: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
6
+ topP: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
7
+ topK: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
8
+ minP: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
9
+ maxTokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
10
+ repeatPenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
11
+ repeatPenaltyNum: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
12
+ presencePenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
13
+ frequencyPenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
14
+ mirostat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
15
+ mirostatTau: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
16
+ mirostatEta: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
17
+ penalizeNewline: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
18
+ stopSequences: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
19
+ trimWhitespace: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
20
+ seed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
21
+ tokenBias: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber>>;
22
+ evaluationPriority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
23
+ contextShiftSize: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
24
+ disableContextShift: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
25
+ }>;
26
+ export declare const SPromtOptionsJson: import("@sinclair/typebox").TObject<{
27
+ temperature: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
28
+ topP: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
29
+ topK: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
30
+ minP: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
31
+ maxTokens: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
32
+ repeatPenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
33
+ repeatPenaltyNum: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
34
+ presencePenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
35
+ frequencyPenalty: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
36
+ mirostat: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
37
+ mirostatTau: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
38
+ mirostatEta: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
39
+ penalizeNewline: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
40
+ stopSequences: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
41
+ trimWhitespace: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
42
+ seed: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
43
+ tokenBias: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber>>;
44
+ evaluationPriority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
45
+ contextShiftSize: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
46
+ disableContextShift: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
47
+ }>;
48
+ export type TPromtOptions = Static<typeof SPromtOptions>;
49
+ export type TPromtOptionsOpenAi = {
50
+ temperature?: number;
51
+ top_p?: number;
52
+ max_tokens?: number;
53
+ frequency_penalty?: number;
54
+ presence_penalty?: number;
55
+ seed?: number;
56
+ stop?: string[];
57
+ logit_bias?: Record<string, number>;
58
+ response_format?: any;
59
+ };
60
+ export type TPromtOptionsOllama = {
61
+ temperature?: number;
62
+ top_p?: number;
63
+ top_k?: number;
64
+ min_p?: number;
65
+ num_predict?: number;
66
+ repeat_penalty?: number;
67
+ repeat_last_n?: number;
68
+ mirostat?: number;
69
+ mirostat_tau?: number;
70
+ mirostat_eta?: number;
71
+ tfs_z?: number;
72
+ seed?: number;
73
+ stop?: string[];
74
+ penalize_newline?: boolean;
75
+ };
76
+ export type TPromtOptionsLlamaCpp = {
77
+ temperature?: number;
78
+ topP?: number;
79
+ topK?: number;
80
+ minP?: number;
81
+ maxTokens?: number;
82
+ seed?: number;
83
+ trimWhitespaceSuffix?: boolean;
84
+ customStopTriggers?: (string | string[])[];
85
+ tokenBias?: Record<string, number> | (() => Record<string, number>);
86
+ evaluationPriority?: number;
87
+ contextShiftSize?: number;
88
+ disableContextShift?: boolean;
89
+ repeatPenalty?: false | {
90
+ lastTokens?: number;
91
+ penalty?: number;
92
+ frequencyPenalty?: number;
93
+ presencePenalty?: number;
94
+ penalizeNewLine?: boolean;
95
+ punishTokensFilter?: (tokens: any[]) => any[];
96
+ };
97
+ grammar?: any;
98
+ };
99
+ //# sourceMappingURL=index.d.ts.map