llm-exe 0.0.5 → 0.0.6
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/dist/interfaces/chat.d.ts +1 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/prompt/_base.d.ts +3 -3
- package/dist/prompt/chat.d.ts +11 -5
- package/dist/prompt/chat.js +39 -1
- package/dist/prompt/chat.js.map +1 -1
- package/dist/utils/modules/handlebars/helpers/index.d.ts +3 -1
- package/dist/utils/modules/handlebars/helpers/index.js +20 -5
- package/dist/utils/modules/handlebars/helpers/index.js.map +1 -1
- package/dist/utils/modules/handlebars/templates/index.d.ts +3 -0
- package/dist/utils/modules/handlebars/templates/index.js +13 -1
- package/dist/utils/modules/handlebars/templates/index.js.map +1 -1
- package/dist/utils/modules/index.d.ts +15 -1
- package/dist/utils/modules/index.js +18 -1
- package/dist/utils/modules/index.js.map +1 -1
- package/dist/utils/modules/json-schema-filter.d.ts +2 -1
- package/dist/utils/modules/json-schema-filter.js +27 -14
- package/dist/utils/modules/json-schema-filter.js.map +1 -1
- package/package.json +9 -6
|
@@ -22,5 +22,6 @@ export interface IChatMessagesPlaceholder {
|
|
|
22
22
|
}
|
|
23
23
|
export type IPromptMessages = (IChatSystemMessage | IChatMessagesPlaceholder)[];
|
|
24
24
|
export type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage | IChatSystemMessage | IChatMessagesPlaceholder)[];
|
|
25
|
+
export type IChatMessage = (IChatUserMessage | IChatAssistantMessage | IChatSystemMessage);
|
|
25
26
|
export type IChatMessages = (IChatUserMessage | IChatAssistantMessage | IChatSystemMessage)[];
|
|
26
27
|
export type PromptTemplateHistoryToken = `{{>DialogueHistory key='${string}'}}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,0CAAwB;AACxB,yCAAuB;AACvB,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,2CAAyB"}
|
package/dist/prompt/_base.d.ts
CHANGED
|
@@ -24,19 +24,19 @@ export declare abstract class BasePrompt<I extends Record<string, any>> {
|
|
|
24
24
|
* @param content The message content
|
|
25
25
|
* @return returns BasePrompt so it can be chained.
|
|
26
26
|
*/
|
|
27
|
-
addSystemMessage(content: string):
|
|
27
|
+
addSystemMessage(content: string): this;
|
|
28
28
|
/**
|
|
29
29
|
* registerPartial description
|
|
30
30
|
* @param partialOrPartials Additional partials that can be made available to the template parser.
|
|
31
31
|
* @return BasePrompt so it can be chained.
|
|
32
32
|
*/
|
|
33
|
-
registerPartial(partialOrPartials: PromptPartial | PromptPartial[]):
|
|
33
|
+
registerPartial(partialOrPartials: PromptPartial | PromptPartial[]): this;
|
|
34
34
|
/**
|
|
35
35
|
* registerHelpers description
|
|
36
36
|
* @param helperOrHelpers Additional helper functions that can be made available to the template parser.
|
|
37
37
|
* @return BasePrompt so it can be chained.
|
|
38
38
|
*/
|
|
39
|
-
registerHelpers(helperOrHelpers: PromptHelper | PromptHelper[]):
|
|
39
|
+
registerHelpers(helperOrHelpers: PromptHelper | PromptHelper[]): this;
|
|
40
40
|
/**
|
|
41
41
|
* format description
|
|
42
42
|
* @param values The message content
|
package/dist/prompt/chat.d.ts
CHANGED
|
@@ -30,16 +30,16 @@ export declare class ChatPrompt<I extends Record<string, any>> extends BasePromp
|
|
|
30
30
|
* @param content The message content.
|
|
31
31
|
* @param role The role of the chat user. Must be one of: assistant, system, user.
|
|
32
32
|
* @param name (optional) The name of the user. Only accepted if role is `user`.
|
|
33
|
-
* @return instance of
|
|
33
|
+
* @return instance of ChatPrompt.
|
|
34
34
|
*/
|
|
35
|
-
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant">, name?: undefined):
|
|
36
|
-
addToPrompt(content: string, role: Extract<IChatMessageRole, "system">, name?: undefined):
|
|
37
|
-
addToPrompt(content: string, role: Extract<IChatMessageRole, "user">, name?: string):
|
|
35
|
+
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant">, name?: undefined): ChatPrompt<I>;
|
|
36
|
+
addToPrompt(content: string, role: Extract<IChatMessageRole, "system">, name?: undefined): ChatPrompt<I>;
|
|
37
|
+
addToPrompt(content: string, role: Extract<IChatMessageRole, "user">, name?: string): ChatPrompt<I>;
|
|
38
38
|
/**
|
|
39
39
|
* addUserMessage Helper to add a user message to the prompt.
|
|
40
40
|
* @param content The message content.
|
|
41
41
|
* @param name (optional) The name of the user.
|
|
42
|
-
* @return instance of
|
|
42
|
+
* @return instance of ChatPrompt.
|
|
43
43
|
*/
|
|
44
44
|
addUserMessage(content: string, name?: string): ChatPrompt<I>;
|
|
45
45
|
/**
|
|
@@ -60,6 +60,12 @@ export declare class ChatPrompt<I extends Record<string, any>> extends BasePromp
|
|
|
60
60
|
* @return returns ChatPrompt so it can be chained.
|
|
61
61
|
*/
|
|
62
62
|
addChatHistoryPlaceholder(key: keyof I): ChatPrompt<I>;
|
|
63
|
+
/**
|
|
64
|
+
* addTokenPlaceholder description
|
|
65
|
+
* @param content The message content
|
|
66
|
+
* @return returns ChatPrompt so it can be chained.
|
|
67
|
+
*/
|
|
68
|
+
addMessagePlaceholder(content: string, role?: IChatMessageRole, name?: string): this;
|
|
63
69
|
/**
|
|
64
70
|
* format formats the stored prompt based on input values.
|
|
65
71
|
* Uses template engine.
|
package/dist/prompt/chat.js
CHANGED
|
@@ -60,7 +60,7 @@ class ChatPrompt extends _base_1.BasePrompt {
|
|
|
60
60
|
* addUserMessage Helper to add a user message to the prompt.
|
|
61
61
|
* @param content The message content.
|
|
62
62
|
* @param name (optional) The name of the user.
|
|
63
|
-
* @return instance of
|
|
63
|
+
* @return instance of ChatPrompt.
|
|
64
64
|
*/
|
|
65
65
|
addUserMessage(content, name) {
|
|
66
66
|
const message = {
|
|
@@ -123,6 +123,26 @@ class ChatPrompt extends _base_1.BasePrompt {
|
|
|
123
123
|
});
|
|
124
124
|
return this;
|
|
125
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* addTokenPlaceholder description
|
|
128
|
+
* @param content The message content
|
|
129
|
+
* @return returns ChatPrompt so it can be chained.
|
|
130
|
+
*/
|
|
131
|
+
addMessagePlaceholder(content, role = "user", name) {
|
|
132
|
+
if (content) {
|
|
133
|
+
const start = `{{> SingleChatMessage `;
|
|
134
|
+
const params = [`role='${role}'`, `content='${(0, utils_1.escape)(content)}'`];
|
|
135
|
+
const end = `}}`;
|
|
136
|
+
if (name) {
|
|
137
|
+
params.push(`name='${name}'`);
|
|
138
|
+
}
|
|
139
|
+
this.messages.push({
|
|
140
|
+
role: "placeholder",
|
|
141
|
+
content: `${start}${params.join(" ")}${end}`,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
126
146
|
/**
|
|
127
147
|
* format formats the stored prompt based on input values.
|
|
128
148
|
* Uses template engine.
|
|
@@ -168,6 +188,24 @@ class ChatPrompt extends _base_1.BasePrompt {
|
|
|
168
188
|
}
|
|
169
189
|
break;
|
|
170
190
|
}
|
|
191
|
+
case ">SingleChatMessage": {
|
|
192
|
+
const { name, content, role } = data;
|
|
193
|
+
if (role && content) {
|
|
194
|
+
const message = {
|
|
195
|
+
role,
|
|
196
|
+
name,
|
|
197
|
+
content: (0, utils_1.replaceTemplateString)(content, replacements, {
|
|
198
|
+
partials: this.partials,
|
|
199
|
+
helpers: this.helpers,
|
|
200
|
+
})
|
|
201
|
+
};
|
|
202
|
+
if (!name || role !== "user") {
|
|
203
|
+
delete message.name;
|
|
204
|
+
}
|
|
205
|
+
messagesOut.push(message);
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
171
209
|
}
|
|
172
210
|
}
|
|
173
211
|
else {
|
package/dist/prompt/chat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"src/","sources":["prompt/chat.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"src/","sources":["prompt/chat.ts"],"names":[],"mappings":";;;AAAA,mCAMiB;AACjB,mCAAqC;AAgBrC;;;;GAIG;AACH,MAAa,UAA0C,SAAQ,kBAAa;IAa1E;;;;OAIG;IACH,YACE,0BAAmC,EACnC,OAA2B;QAE3B,KAAK,CAAC,0BAA0B,CAAC,CAAC;QArBpC;;WAEG;QACH;;;;mBAAgC,MAAM;WAAC;QAEvC;;;;WAIG;QACH;;;;mBAA6B,KAAK;WAAC;QAYjC,IAAI,OAAO,EAAE,uBAAuB,EAAE;YACpC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;SAChC;IACH,CAAC;IAwBD,WAAW,CACT,OAAe,EACf,IAAsB,EACtB,IAAa;QAEb,IAAI,OAAO,EAAE;YACX,QAAQ,IAAI,EAAE;gBACZ,KAAK,QAAQ;oBACX,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;oBAC/B,MAAM;gBACR,KAAK,MAAM;oBACT,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;oBACnC,MAAM;gBACR,KAAK,WAAW;oBACd,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;oBAClC,MAAM;aACT;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,OAAe,EAAE,IAAa;QAC3C,MAAM,OAAO,GAAqB;YAChC,IAAI,EAAE,MAAM;YACZ,OAAO;SACR,CAAC;QACF,IAAI,IAAI,EAAE;YACR,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;SACrB;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAA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AW,CAAC,IAAI,CACd,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE;wBACzB,OAAO,EAAE,IAAA,6BAAqB,EAAC,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE;4BAC5D,QAAQ,EAAE,IAAI,CAAC,QAAQ;4BACvB,OAAO,EAAE,IAAI,CAAC,OAAO;yBACtB,CAAC;qBACH,CAAC,CACH,CAAC;iBACH;qBAAM;oBACL,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBAC3B;aACF;SACF;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,0CAA0C;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAzQD,gCAyQC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getKeyOr(this: any, key: string, arg2: any): any;
|
|
2
2
|
export declare function getOr(this: any, arg1: string, arg2: string): string;
|
|
3
|
+
export declare function indentJson(this: any, arg1: Record<string, any>): string;
|
|
4
|
+
export declare function jsonSchemaExample(this: any, key: string, prop: string): string;
|
|
3
5
|
export declare function pluralize(this: any, arg1: `${string}|${string}`, arg2: number): string;
|
|
4
6
|
export declare function eq(this: any, arg1: string | undefined, arg2: string | undefined, options: any): any;
|
|
5
7
|
export declare function neq(this: any, arg1: string | undefined, arg2: string | undefined, options: any): any;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.join = exports.objectToList = exports.ifCond = exports.neq = exports.eq = exports.pluralize = exports.getOr = exports.
|
|
3
|
+
exports.join = exports.objectToList = exports.ifCond = exports.neq = exports.eq = exports.pluralize = exports.jsonSchemaExample = exports.indentJson = exports.getOr = exports.getKeyOr = void 0;
|
|
4
4
|
const utils_1 = require("../../../../utils");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const json_schema_filter_1 = require("../../json-schema-filter");
|
|
6
|
+
function getKeyOr(key, arg2) {
|
|
7
|
+
const res = (0, utils_1.get)(this, key);
|
|
8
|
+
return typeof res !== "undefined" && res !== "" ? res : arg2;
|
|
7
9
|
}
|
|
8
|
-
exports.
|
|
10
|
+
exports.getKeyOr = getKeyOr;
|
|
9
11
|
function getOr(arg1, arg2) {
|
|
10
|
-
return typeof arg1 !== "undefined" ? arg1 : arg2;
|
|
12
|
+
return typeof arg1 !== "undefined" && arg1 !== "" ? arg1 : arg2;
|
|
11
13
|
}
|
|
12
14
|
exports.getOr = getOr;
|
|
15
|
+
function indentJson(arg1) {
|
|
16
|
+
return typeof arg1 === "object" ? JSON.stringify(arg1, null, 2) : arg1;
|
|
17
|
+
}
|
|
18
|
+
exports.indentJson = indentJson;
|
|
19
|
+
function jsonSchemaExample(key, prop) {
|
|
20
|
+
const schema = (0, utils_1.get)(this, key);
|
|
21
|
+
if (schema && schema.type) {
|
|
22
|
+
const result = (0, json_schema_filter_1.schemaExampleWith)(schema, prop);
|
|
23
|
+
return typeof result === "object" ? JSON.stringify(result, null, 2) : "";
|
|
24
|
+
}
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
exports.jsonSchemaExample = jsonSchemaExample;
|
|
13
28
|
function pluralize(arg1, arg2) {
|
|
14
29
|
const [singular, plural] = arg1.split("|");
|
|
15
30
|
return arg2 > 1 ? plural : singular;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/handlebars/helpers/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/handlebars/helpers/index.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAC9B,iEAA6D;AAE7D,SAAgB,QAAQ,CAAY,GAAW,EAAE,IAAS;IACxD,MAAM,GAAG,GAAG,IAAA,WAAG,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC3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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7D;YACE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;KAChC;AACH,CAAC;AA/BD,wBA+BC;AAED,SAAgB,YAAY,CAE1B,MAA8B,EAAE;IAEhC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;SACpB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;SACrC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAPD,oCAOC;AAED,SAAgB,IAAI,CAAC,KAAe;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAJD,oBAIC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare const COMPLETION_END_TOKEN = "<--END";
|
|
2
2
|
export declare const PROMPT_END_TOKEN = "-->";
|
|
3
3
|
export declare const partials: {
|
|
4
|
+
JsonSchema: string;
|
|
5
|
+
JsonSchemaExampleJson: string;
|
|
4
6
|
MarkdownCode: string;
|
|
5
7
|
DialogueHistory: string;
|
|
8
|
+
SingleChatMessage: string;
|
|
6
9
|
ChatConversationHistory: string;
|
|
7
10
|
ThoughtsAndObservations: string;
|
|
8
11
|
ThoughtActionResult: string;
|
|
@@ -20,14 +20,26 @@ const ChatConversationHistory = `
|
|
|
20
20
|
{{~#eq item.role 'assistant'}}{{../assistantName}}: {{{item.content}}}\n{{/eq}}
|
|
21
21
|
{{~#eq item.role 'system'}}{{../systemName}}: {{{item.content}}}\n{{/eq}}
|
|
22
22
|
{{~/each}}`;
|
|
23
|
-
const DialogueHistory = `{{>ChatConversationHistory title=title chat_history=(
|
|
23
|
+
const DialogueHistory = `{{>ChatConversationHistory title=title chat_history=(getKeyOr key []) assistantName=(getOr assistant 'Assistant') userName=(getOr user 'User') systemName=(getOr system 'System')}}`;
|
|
24
|
+
const SingleChatMessage = `{{~#eq role 'user'}}{{getOr name 'User'}}: {{{content}}}{{~/eq}}
|
|
25
|
+
{{~#eq role 'assistant'}}{{getOr assistant 'Assistant'}}: {{{content}}}{{~/eq}}
|
|
26
|
+
{{~#eq role 'system'}}{{getOr system 'System'}}: {{{content}}}{{~/eq}}`;
|
|
24
27
|
const ThoughtsAndObservations = `{{~#each thoughts as | step |}}
|
|
25
28
|
{{~#if step.thought}}Thought: {{{step.thought}}}\n{{/if}}
|
|
26
29
|
{{~#if step.observation}}Observation: {{{step.observation}}}\n{{/if}}
|
|
27
30
|
{{~/each}}`;
|
|
31
|
+
const JsonSchema = `{{#if (getKeyOr key false)}}
|
|
32
|
+
{{{indentJson (getKeyOr key)}}}
|
|
33
|
+
{{~/if}}`;
|
|
34
|
+
const JsonSchemaExampleJson = `{{#if (getOr key false)}}
|
|
35
|
+
{{{jsonSchemaExample key (getOr property '')}}}
|
|
36
|
+
{{~/if}}`;
|
|
28
37
|
exports.partials = {
|
|
38
|
+
JsonSchema,
|
|
39
|
+
JsonSchemaExampleJson,
|
|
29
40
|
MarkdownCode,
|
|
30
41
|
DialogueHistory,
|
|
42
|
+
SingleChatMessage,
|
|
31
43
|
ChatConversationHistory,
|
|
32
44
|
ThoughtsAndObservations,
|
|
33
45
|
ThoughtActionResult,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/handlebars/templates/index.ts"],"names":[],"mappings":";;;AACa,QAAA,oBAAoB,GAAG,QAAQ,CAAC;AAChC,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC,MAAM,YAAY,GAAG;;cAEP,CAAC;AAEf,MAAM,mBAAmB,GAAG;;;;;;UAMlB,CAAC;AAEX,MAAM,uBAAuB,GAAG;;;;;;WAMrB,CAAC;AAEZ,MAAM,eAAe,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/handlebars/templates/index.ts"],"names":[],"mappings":";;;AACa,QAAA,oBAAoB,GAAG,QAAQ,CAAC;AAChC,QAAA,gBAAgB,GAAG,KAAK,CAAC;AAEtC,MAAM,YAAY,GAAG;;cAEP,CAAC;AAEf,MAAM,mBAAmB,GAAG;;;;;;UAMlB,CAAC;AAEX,MAAM,uBAAuB,GAAG;;;;;;WAMrB,CAAC;AAEZ,MAAM,eAAe,GAAG,qLAAqL,CAAC;AAE9M,MAAM,iBAAiB,GAAG;;uEAE6C,CAAC;AAExE,MAAM,uBAAuB,GAAG;;;WAGrB,CAAC;AAEZ,MAAM,UAAU,GAAG;;SAEV,CAAC;AAEV,MAAM,qBAAqB,GAAG;;SAErB,CAAA;AAEI,QAAA,QAAQ,GAAG;IACtB,UAAU;IACV,qBAAqB;IACrB,YAAY;IACZ,eAAe;IACf,iBAAiB;IACjB,uBAAuB;IACvB,uBAAuB;IACvB,mBAAmB;CACpB,CAAC"}
|
|
@@ -4,9 +4,11 @@ import get from "lodash.get";
|
|
|
4
4
|
import set from "lodash.set";
|
|
5
5
|
import pick from "lodash.pick";
|
|
6
6
|
import camelCase from "lodash.camelcase";
|
|
7
|
+
import unEscape from "lodash.unescape";
|
|
8
|
+
import escape from "lodash.escape";
|
|
7
9
|
import { v4 as uuidv4 } from "uuid";
|
|
8
10
|
export { uuidv4 as uuid };
|
|
9
|
-
export { get, set, pick, camelCase };
|
|
11
|
+
export { get, set, pick, camelCase, unEscape, escape };
|
|
10
12
|
export { filterObjectOnSchema } from "./json-schema-filter";
|
|
11
13
|
export { replaceTemplateString } from "./replaceTemplateString";
|
|
12
14
|
export { asyncCallWithTimeout } from "./asyncCallWithTimeout";
|
|
@@ -44,8 +46,20 @@ export declare function toNumber(value: any): number;
|
|
|
44
46
|
export declare function extractPromptPlaceholderToken(tok: string): {
|
|
45
47
|
token: string;
|
|
46
48
|
key?: undefined;
|
|
49
|
+
name?: undefined;
|
|
50
|
+
content?: undefined;
|
|
51
|
+
role?: undefined;
|
|
47
52
|
} | {
|
|
48
53
|
token: string;
|
|
49
54
|
key: string;
|
|
55
|
+
name?: undefined;
|
|
56
|
+
content?: undefined;
|
|
57
|
+
role?: undefined;
|
|
58
|
+
} | {
|
|
59
|
+
token: string;
|
|
60
|
+
name: undefined;
|
|
61
|
+
content: string;
|
|
62
|
+
role: string;
|
|
63
|
+
key?: undefined;
|
|
50
64
|
};
|
|
51
65
|
export declare function getEnvironmentVariable(name: string): string | undefined;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEnvironmentVariable = exports.extractPromptPlaceholderToken = exports.toNumber = exports.isFinite = exports.isUndefined = exports.isNull = exports.generateUniqueNameId = exports.removeEmptyFromObject = exports.inferFunctionName = exports.ensureInputIsObject = exports.enforceResultAttributes = exports.defineSchema = exports.chunkArray = exports.assert = exports.isObjectStringified = exports.maybeParseJSON = exports.maybeStringifyJSON = exports.asyncCallWithTimeout = exports.replaceTemplateString = exports.filterObjectOnSchema = exports.camelCase = exports.pick = exports.set = exports.get = exports.uuid = void 0;
|
|
6
|
+
exports.getEnvironmentVariable = exports.extractPromptPlaceholderToken = exports.toNumber = exports.isFinite = exports.isUndefined = exports.isNull = exports.generateUniqueNameId = exports.removeEmptyFromObject = exports.inferFunctionName = exports.ensureInputIsObject = exports.enforceResultAttributes = exports.defineSchema = exports.chunkArray = exports.assert = exports.isObjectStringified = exports.maybeParseJSON = exports.maybeStringifyJSON = exports.asyncCallWithTimeout = exports.replaceTemplateString = exports.filterObjectOnSchema = exports.escape = exports.unEscape = exports.camelCase = exports.pick = exports.set = exports.get = exports.uuid = void 0;
|
|
7
7
|
const json_schema_to_ts_1 = require("json-schema-to-ts");
|
|
8
8
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
9
9
|
exports.get = lodash_get_1.default;
|
|
@@ -13,6 +13,10 @@ const lodash_pick_1 = __importDefault(require("lodash.pick"));
|
|
|
13
13
|
exports.pick = lodash_pick_1.default;
|
|
14
14
|
const lodash_camelcase_1 = __importDefault(require("lodash.camelcase"));
|
|
15
15
|
exports.camelCase = lodash_camelcase_1.default;
|
|
16
|
+
const lodash_unescape_1 = __importDefault(require("lodash.unescape"));
|
|
17
|
+
exports.unEscape = lodash_unescape_1.default;
|
|
18
|
+
const lodash_escape_1 = __importDefault(require("lodash.escape"));
|
|
19
|
+
exports.escape = lodash_escape_1.default;
|
|
16
20
|
const uuid_1 = require("uuid");
|
|
17
21
|
Object.defineProperty(exports, "uuid", { enumerable: true, get: function () { return uuid_1.v4; } });
|
|
18
22
|
var json_schema_filter_1 = require("./json-schema-filter");
|
|
@@ -146,6 +150,19 @@ function extractPromptPlaceholderToken(tok) {
|
|
|
146
150
|
};
|
|
147
151
|
}
|
|
148
152
|
}
|
|
153
|
+
else if (token.substring(2, 20) === ">SingleChatMessage") {
|
|
154
|
+
const matchRole = tok.match(/role=(['"`])((?:(?!\1).)*)\1/);
|
|
155
|
+
const matchContent = tok.match(/content=(['"`])((?:(?!\1).)*)\1/);
|
|
156
|
+
const matchName = tok.match(/name=(['"`])((?:(?!\1).)*)\1/);
|
|
157
|
+
if (matchRole) {
|
|
158
|
+
return {
|
|
159
|
+
token: ">SingleChatMessage",
|
|
160
|
+
name: (0, lodash_get_1.default)(matchName, '[2]'),
|
|
161
|
+
content: (0, lodash_unescape_1.default)((0, lodash_get_1.default)(matchContent, '[2]', "")),
|
|
162
|
+
role: (0, lodash_get_1.default)(matchRole, '[2]', "")
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
}
|
|
149
166
|
return { token: "" };
|
|
150
167
|
}
|
|
151
168
|
exports.extractPromptPlaceholderToken = extractPromptPlaceholderToken;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/index.ts"],"names":[],"mappings":";;;;;;AACA,yDAA4C;AAG5C,4DAA6B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["utils/modules/index.ts"],"names":[],"mappings":";;;;;;AACA,yDAA4C;AAG5C,4DAA6B;AASpB,cATF,oBAAG,CASE;AARZ,4DAA6B;AAQf,cARP,oBAAG,CAQO;AAPjB,8DAA+B;AAOZ,eAPZ,qBAAI,CAOY;AANvB,wEAAyC;AAMhB,oBANlB,0BAAS,CAMkB;AALlC,sEAAuC;AAKH,mBAL7B,yBAAQ,CAK6B;AAJ5C,kEAAmC;AAIW,iBAJvC,uBAAM,CAIuC;AAFpD,+BAAoC;AACjB,qFADJ,SAAM,OACE;AAGvB,2DAA4D;AAAnD,0HAAA,oBAAoB,OAAA;AAC7B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,+BAIgB;AAHd,0GAAA,kBAAkB,OAAA;AAClB,sGAAA,cAAc,OAAA;AACd,2GAAA,mBAAmB,OAAA;AAGrB,SAAgB,MAAM,CACpB,SAAc,EACd,OAAoC;IAEpC,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,KAAK,EAAE;QACxE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;SAC1B;aAAM,IAAI,OAAO,YAAY,KAAK,EAAE;YACnC,MAAM,OAAO,CAAC;SACf;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;SACpC;KACF;AACH,CAAC;AAbD,wBAaC;AAEM,MAAM,UAAU,GAAG,CAAC,GA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AAE,CAAC;AACvB,CAAC;AA1BD,sEA0BC;AAED,SAAgB,sBAAsB,CAAC,IAAY;IACjD,IAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,EAAE,GAAG,EAAC;QAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;KACzB;SAAI;QACH,OAAO,SAAS,CAAA;KACjB;AACH,CAAC;AAND,wDAMC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function filterObjectOnSchema(schema: any, doc: any, detach?: any): any;
|
|
1
|
+
export declare function filterObjectOnSchema(schema: any, doc: any, detach?: any, property?: string): any;
|
|
2
|
+
export declare function schemaExampleWith(schema: any, property: string): any;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.filterObjectOnSchema = void 0;
|
|
3
|
+
exports.schemaExampleWith = exports.filterObjectOnSchema = void 0;
|
|
4
|
+
const _1 = require("./");
|
|
4
5
|
function isObject(obj) {
|
|
5
6
|
return obj === Object(obj);
|
|
6
7
|
}
|
|
@@ -18,7 +19,7 @@ function getType(schemaType) {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
function filterObjectOnSchema(schema, doc, detach) {
|
|
22
|
+
function filterObjectOnSchema(schema, doc, detach, property) {
|
|
22
23
|
let result; // returns the resulting filtered thing from this level; can be object, array, literal, ...
|
|
23
24
|
// if the document is null/undefined, short-circuit and return it
|
|
24
25
|
if (doc === null || doc === undefined) {
|
|
@@ -32,21 +33,26 @@ function filterObjectOnSchema(schema, doc, detach) {
|
|
|
32
33
|
Object.keys(schema.properties).forEach(function (key) {
|
|
33
34
|
var child = doc[key];
|
|
34
35
|
var sp = schema.properties[key];
|
|
35
|
-
var filteredChild = filterObjectOnSchema(sp, child, detach);
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
var filteredChild = filterObjectOnSchema(sp, child, detach, property);
|
|
37
|
+
if (property) {
|
|
38
|
+
result[key] = (0, _1.get)(sp, property, "");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (filteredChild === undefined) {
|
|
42
|
+
if (typeof sp?.default !== "undefined") {
|
|
43
|
+
// add default value if undefined and has default
|
|
44
|
+
result[key] = (0, _1.get)(sp, "default", "");
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// filter out if the child is undefined and no default
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
40
50
|
}
|
|
41
51
|
else {
|
|
42
|
-
//
|
|
43
|
-
|
|
52
|
+
// keep the child if it's defined properly or null
|
|
53
|
+
result[key] = filteredChild;
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
|
-
else {
|
|
47
|
-
// keep the child if it's defined properly or null
|
|
48
|
-
result[key] = filteredChild;
|
|
49
|
-
}
|
|
50
56
|
});
|
|
51
57
|
}
|
|
52
58
|
else if (type === "object" && isObject(doc) && detach) {
|
|
@@ -56,7 +62,7 @@ function filterObjectOnSchema(schema, doc, detach) {
|
|
|
56
62
|
// check that the doc is also an array
|
|
57
63
|
result = [];
|
|
58
64
|
doc.forEach(function (item) {
|
|
59
|
-
result.push(filterObjectOnSchema(schema.items, item, detach));
|
|
65
|
+
result.push(filterObjectOnSchema(schema.items, item, detach, property));
|
|
60
66
|
});
|
|
61
67
|
}
|
|
62
68
|
else {
|
|
@@ -66,4 +72,11 @@ function filterObjectOnSchema(schema, doc, detach) {
|
|
|
66
72
|
return result;
|
|
67
73
|
}
|
|
68
74
|
exports.filterObjectOnSchema = filterObjectOnSchema;
|
|
75
|
+
function schemaExampleWith(schema, property) {
|
|
76
|
+
if (schema.type === "array") {
|
|
77
|
+
return filterObjectOnSchema(schema, [{}], undefined, property);
|
|
78
|
+
}
|
|
79
|
+
return filterObjectOnSchema(schema, {}, undefined, property);
|
|
80
|
+
}
|
|
81
|
+
exports.schemaExampleWith = schemaExampleWith;
|
|
69
82
|
//# sourceMappingURL=json-schema-filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-schema-filter.js","sourceRoot":"src/","sources":["utils/modules/json-schema-filter.ts"],"names":[],"mappings":";;;AAAA,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,OAAO,CAAC,UAAe;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC9B,OAAO,UAAU,CAAC;KACnB;IAED,wCAAwC;IACxC,sEAAsE;IACtE,IAAI,SAAS,GAAG,UAAU,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,IAAI,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,MAAM,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;KACF;AACH,CAAC;AAED,SAAgB,oBAAoB,CAAC,MAAW,EAAE,GAAQ,EAAE,MAAY;
|
|
1
|
+
{"version":3,"file":"json-schema-filter.js","sourceRoot":"src/","sources":["utils/modules/json-schema-filter.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AAEzB,SAAS,QAAQ,CAAC,GAAQ;IACxB,OAAO,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,OAAO,CAAC,UAAe;IAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QAC9B,OAAO,UAAU,CAAC;KACnB;IAED,wCAAwC;IACxC,sEAAsE;IACtE,IAAI,SAAS,GAAG,UAAU,CAAC;IAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACzC,IAA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BACL,sDAAsD;wBACtD,OAAO;qBACR;iBACF;qBAAM;oBACL,kDAAkD;oBAClD,MAAM,CAAC,GAAG,CAAC,GAAG,aAAa,CAAC;iBAC7B;aACF;QAEH,CAAC,CAAC,CAAC;KACJ;SAAM,IAAI,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,EAAE;QACvD,OAAO,EAAE,CAAC;KACX;SAAM,IAAI,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE;QACjE,sCAAsC;QACtC,MAAM,GAAG,EAAE,CAAC;QACZ,GAAG,CAAC,OAAO,CAAC,UAAU,IAAI;YACxB,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;KACJ;SAAM;QACL,uEAAuE;QACvE,MAAM,GAAG,GAAG,CAAC;KACd;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AApDD,oDAoDC;AAED,SAAgB,iBAAiB,CAAC,MAAW,EAAE,QAAgB;IAC7D,IAAG,MAAM,CAAC,IAAI,KAAK,OAAO,EAAC;QACzB,OAAO,oBAAoB,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;KAC/D;IACD,OAAO,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC9D,CAAC;AALD,8CAKC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-exe",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A package that provides simplified base components to make building and maintaining LLM-powered applications easier.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"tsc": "tsc --project ./tsconfig.json
|
|
23
|
+
"tsc": "tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json -w",
|
|
24
24
|
"tsc-ci": "tsc --project ./tsconfig.json && tsc-alias -p ./tsconfig.json",
|
|
25
25
|
"tsc-build": "tsc --project ./tsconfig-build.json && tsc-alias -p tsconfig-build.json -w",
|
|
26
26
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --detectOpenHandles --coverage --forceExit",
|
|
27
|
-
"docs:dev": "vuepress dev docs --clean-temp --clean-cache
|
|
28
|
-
"docs:build": "vuepress build docs",
|
|
27
|
+
"docs:dev": "vuepress dev docs --clean-temp --clean-cache",
|
|
28
|
+
"docs:build": "vuepress build docs --clean-temp --clean-cache",
|
|
29
29
|
"lint": "eslint",
|
|
30
30
|
"format:check": "prettier --check \"src\"",
|
|
31
31
|
"format:write": "prettier --write \"src\""
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"author": "Greg Reindel",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@types/lodash.camelcase": "^4.3.7",
|
|
37
36
|
"exponential-backoff": "3.1.1",
|
|
38
37
|
"handlebars": "4.7.7",
|
|
39
|
-
"json-schema-defaults": "0.4.0",
|
|
40
38
|
"json-schema-to-ts": "^2.8.2",
|
|
41
39
|
"jsonschema": "1.4.1",
|
|
42
40
|
"lodash.camelcase": "^4.3.0",
|
|
41
|
+
"lodash.escape": "^4.0.1",
|
|
43
42
|
"lodash.get": "^4.4.2",
|
|
44
43
|
"lodash.pick": "^4.4.0",
|
|
45
44
|
"lodash.set": "^4.3.2",
|
|
45
|
+
"lodash.unescape": "^4.0.1",
|
|
46
46
|
"object-assign-deep": "0.4.0",
|
|
47
47
|
"openai": "^3.2.1",
|
|
48
48
|
"uuid": "^9.0.0"
|
|
@@ -51,6 +51,9 @@
|
|
|
51
51
|
"@tsconfig/recommended": "^1.0.2",
|
|
52
52
|
"@types/jest": "^29.5.2",
|
|
53
53
|
"@types/json-schema": "^7.0.11",
|
|
54
|
+
"@types/lodash.camelcase": "^4.3.7",
|
|
55
|
+
"@types/lodash.escape": "^4.0.7",
|
|
56
|
+
"@types/lodash.unescape": "^4.0.7",
|
|
54
57
|
"@types/lodash.get": "^4.4.7",
|
|
55
58
|
"@types/lodash.pick": "^4.4.7",
|
|
56
59
|
"@types/lodash.set": "^4.3.7",
|