@transcend-io/cli 4.97.2 → 4.98.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.
- package/build/ai/TranscendAiPrompt.d.ts +5 -1
- package/build/ai/TranscendAiPrompt.d.ts.map +1 -1
- package/build/ai/TranscendAiPrompt.js +8 -2
- package/build/ai/TranscendAiPrompt.js.map +1 -1
- package/build/tests/TranscendAiPrompt.test.d.ts +2 -0
- package/build/tests/TranscendAiPrompt.test.d.ts.map +1 -0
- package/build/tests/TranscendAiPrompt.test.js +53 -0
- package/build/tests/TranscendAiPrompt.test.js.map +1 -0
- package/build/tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -14,18 +14,22 @@ export declare class TranscendAiPrompt<TParams extends ObjByString, TOutputCodec
|
|
|
14
14
|
codec: TOutputCodec;
|
|
15
15
|
/** Handlebars compiler */
|
|
16
16
|
handlebars: typeof handlebars;
|
|
17
|
+
/** Extract response from this tag */
|
|
18
|
+
extractFromTagRegex?: RegExp;
|
|
17
19
|
/**
|
|
18
20
|
* Constructor
|
|
19
21
|
*
|
|
20
22
|
* @param options - Options
|
|
21
23
|
*/
|
|
22
|
-
constructor({ title, codec, handlebarsOptions, }: {
|
|
24
|
+
constructor({ title, codec, extractFromTag, handlebarsOptions, }: {
|
|
23
25
|
/** Title of prompt in transcend */
|
|
24
26
|
title: string;
|
|
25
27
|
/** Codec to validate output shape of the prompt */
|
|
26
28
|
codec: TOutputCodec;
|
|
27
29
|
/** Options for configuring handlebars */
|
|
28
30
|
handlebarsOptions?: HandlebarsInput;
|
|
31
|
+
/** When provided, the response should be extracted from this tag name e.g. json */
|
|
32
|
+
extractFromTag?: string;
|
|
29
33
|
});
|
|
30
34
|
/**
|
|
31
35
|
* Fetch prompt from Transcend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranscendAiPrompt.d.ts","sourceRoot":"","sources":["../../src/ai/TranscendAiPrompt.ts"],"names":[],"mappings":"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MAAM,CAAC;IAErB,wCAAwC;IACjC,KAAK,EAAE,YAAY,CAAC;IAE3B,0BAA0B;IACnB,UAAU,EAAE,OAAO,UAAU,CAAC;IAErC,qCAAqC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;OAIG;gBACS,EACV,KAAK,EACL,KAAK,EACL,cAAc,EACd,iBAAiB,GAClB,EAAE;QACD,mCAAmC;QACnC,KAAK,EAAE,MAAM,CAAC;QACd,mDAAmD;QACnD,KAAK,EAAE,YAAY,CAAC;QACpB,yCAAyC;QACzC,iBAAiB,CAAC,EAAE,eAAe,CAAC;QACpC,mFAAmF;QACnF,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IASD;;;;;OAKG;IACG,wBAAwB,CAAC,EAC7B,0BAAiC,EACjC,YAAoC,EACpC,eAAe,EACf,eAAe,GAChB,EAAE;QACD,4BAA4B;QAC5B,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QACzC,qEAAqE;QACrE,0BAA0B,CAAC,EAAE,OAAO,CAAC;QACrC,+BAA+B;QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,8DAA8D;QAC9D,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,GAAG,OAAO,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IA+ExC;;;;;OAKG;IACH,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;CAM1D"}
|
|
@@ -23,10 +23,13 @@ class TranscendAiPrompt {
|
|
|
23
23
|
*
|
|
24
24
|
* @param options - Options
|
|
25
25
|
*/
|
|
26
|
-
constructor({ title, codec, handlebarsOptions, }) {
|
|
26
|
+
constructor({ title, codec, extractFromTag, handlebarsOptions, }) {
|
|
27
27
|
this.title = title;
|
|
28
28
|
this.codec = codec;
|
|
29
29
|
this.handlebars = (0, createHandlebarsWithHelpers_1.createHandlebarsWithHelpers)(handlebarsOptions);
|
|
30
|
+
this.extractFromTagRegex = extractFromTag
|
|
31
|
+
? new RegExp(`<${extractFromTag}>([\\s\\S]+?)<\\/${extractFromTag}>`)
|
|
32
|
+
: undefined;
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Fetch prompt from Transcend
|
|
@@ -96,7 +99,10 @@ class TranscendAiPrompt {
|
|
|
96
99
|
* @returns Parsed content
|
|
97
100
|
*/
|
|
98
101
|
parseAiResponse(response) {
|
|
99
|
-
|
|
102
|
+
const extracted = this.extractFromTagRegex
|
|
103
|
+
? (this.extractFromTagRegex.exec(response) || [])[1] || response
|
|
104
|
+
: response;
|
|
105
|
+
return (0, type_utils_1.decodeCodec)(this.codec, extracted);
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
exports.TranscendAiPrompt = TranscendAiPrompt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranscendAiPrompt.js","sourceRoot":"","sources":["../../src/ai/TranscendAiPrompt.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAoE;AAEpE,+DAA+D;AAG/D,kEAAkE;AAClE,4CAAqD;AACrD,wCAA6E;AAC7E,sGAAmG;AACnG,+EAGuC;AACvC,iEAAyC;AACzC,yDAAiC;AAEpB,QAAA,yBAAyB,GAAG,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"TranscendAiPrompt.js","sourceRoot":"","sources":["../../src/ai/TranscendAiPrompt.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAoE;AAEpE,+DAA+D;AAG/D,kEAAkE;AAClE,4CAAqD;AACrD,wCAA6E;AAC7E,sGAAmG;AACnG,+EAGuC;AACvC,iEAAyC;AACzC,yDAAiC;AAEpB,QAAA,yBAAyB,GAAG,YAAY,CAAC;AAEtD;;GAEG;AACH,MAAa,iBAAiB;IAgB5B;;;;OAIG;IACH,YAAY,EACV,KAAK,EACL,KAAK,EACL,cAAc,EACd,iBA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;qBACH;oBACD,WAAW,CAAC,uBAAuB,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC;gBAClE,CAAC,CAAC,CAAC;aACJ;SACF;QAED,4DAA4D;QAC5D,0BAA0B;QAC1B,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC1C,qCAAqC;YACrC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACrC,GAAG,WAAW;YACd,GAAG,MAAM;SACV,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,QAAgB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB;YACxC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ;YAChE,CAAC,CAAC,QAAQ,CAAC;QACb,OAAO,IAAA,wBAAW,EAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF;AA3JD,8CA2JC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscendAiPrompt.test.d.ts","sourceRoot":"","sources":["../../src/tests/TranscendAiPrompt.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const chai_1 = require("chai");
|
|
27
|
+
const t = __importStar(require("io-ts"));
|
|
28
|
+
const TranscendAiPrompt_1 = require("../ai/TranscendAiPrompt");
|
|
29
|
+
const TEST_DATA = `
|
|
30
|
+
Unfortunately the sample dataset provided does not contain enough information to determine who is most important.
|
|
31
|
+
However, here is a JSON string list of fields that could be useful for answering such a question if more data were available:
|
|
32
|
+
<json>
|
|
33
|
+
["Name", "Title", "Department", "Salary", "Tenure"]
|
|
34
|
+
</json>
|
|
35
|
+
These fields like name, title, department, salary, and tenure co
|
|
36
|
+
`;
|
|
37
|
+
describe('TranscendAiPrompt', () => {
|
|
38
|
+
const aiPrompt = new TranscendAiPrompt_1.TranscendAiPrompt({
|
|
39
|
+
title: 'test',
|
|
40
|
+
codec: t.array(t.string),
|
|
41
|
+
extractFromTag: 'json',
|
|
42
|
+
});
|
|
43
|
+
it('should remove links', () => {
|
|
44
|
+
(0, chai_1.expect)(aiPrompt.parseAiResponse(TEST_DATA)).to.deep.equal([
|
|
45
|
+
'Name',
|
|
46
|
+
'Title',
|
|
47
|
+
'Department',
|
|
48
|
+
'Salary',
|
|
49
|
+
'Tenure',
|
|
50
|
+
]);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
//# sourceMappingURL=TranscendAiPrompt.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TranscendAiPrompt.test.js","sourceRoot":"","sources":["../../src/tests/TranscendAiPrompt.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAC9B,yCAA2B;AAC3B,+DAA4D;AAE5D,MAAM,SAAS,GAAG;;;;;;;CAOjB,CAAC;AAEF,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,MAAM,QAAQ,GAAG,IAAI,qCAAiB,CAAC;QACrC,KAAK,EAAE,MAAM;QACb,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM;KACvB,CAAC,CAAC;IACH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,IAAA,aAAM,EAAC,QAAQ,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACxD,MAAM;YACN,OAAO;YACP,YAAY;YACZ,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|