@promptbook/core 0.66.0-6 → 0.66.0-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/esm/index.es.js +314 -164
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/cli.index.d.ts +2 -2
- package/esm/typings/src/cli/main.d.ts +2 -2
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/knowledge/prepare-knowledge/_common/prepareKnowledgePieces.test.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.test.d.ts +1 -1
- package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.test.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/getLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -0
- package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +10 -5
- package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +10 -5
- package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +8 -4
- package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +8 -4
- package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +9 -5
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +10 -5
- package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +8 -4
- package/esm/typings/src/personas/preparePersona.test.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +314 -164
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* The version of the Promptbook library
|
|
21
21
|
*/
|
|
22
|
-
var PROMPTBOOK_VERSION = '0.66.0-
|
|
22
|
+
var PROMPTBOOK_VERSION = '0.66.0-6';
|
|
23
23
|
// TODO: !!!! List here all the versions and annotate + put into script
|
|
24
24
|
|
|
25
25
|
/*! *****************************************************************************
|
|
@@ -1650,7 +1650,7 @@
|
|
|
1650
1650
|
});
|
|
1651
1651
|
}
|
|
1652
1652
|
|
|
1653
|
-
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-
|
|
1653
|
+
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.66.0-6",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",dependentParameterNames:["knowledgeContent"],resultingParameterName:"knowledgePieces"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-from-markdown.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.ptbk.md",promptbookVersion:"0.66.0-6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"keywords"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-keywords.ptbk.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.ptbk.md",promptbookVersion:"0.66.0-6",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"knowledge",title:"Knowledge",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"],resultingParameterName:"title"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-knowledge-title.ptbk.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.ptbk.md",promptbookVersion:"0.66.0-6",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],promptTemplates:[{blockType:"PROMPT_TEMPLATE",name:"make-model-requirements",title:"Make modelRequirements",modelRequirements:{modelVariant:"CHAT",modelName:"gpt-4-turbo"},content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Sample\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n### Option `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Option `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Option `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",expectFormat:"JSON",dependentParameterNames:["availableModelNames","personaDescription"],resultingParameterName:"modelRequirements"}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./promptbook-collection/prepare-persona.ptbk.md"}];
|
|
1654
1654
|
|
|
1655
1655
|
var defaultDiacriticsRemovalMap = [
|
|
1656
1656
|
{
|
|
@@ -2243,6 +2243,60 @@
|
|
|
2243
2243
|
enumerable: false,
|
|
2244
2244
|
configurable: true
|
|
2245
2245
|
});
|
|
2246
|
+
/**
|
|
2247
|
+
* Check the configuration of all execution tools
|
|
2248
|
+
*/
|
|
2249
|
+
MultipleLlmExecutionTools.prototype.checkConfiguration = function () {
|
|
2250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2251
|
+
return __generator(this, function (_a) {
|
|
2252
|
+
return [2 /*return*/];
|
|
2253
|
+
});
|
|
2254
|
+
});
|
|
2255
|
+
};
|
|
2256
|
+
/**
|
|
2257
|
+
* List all available models that can be used
|
|
2258
|
+
* This lists is a combination of all available models from all execution tools
|
|
2259
|
+
*/
|
|
2260
|
+
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
2261
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2262
|
+
var availableModels, _a, _b, llmExecutionTools, models, e_1_1;
|
|
2263
|
+
var e_1, _c;
|
|
2264
|
+
return __generator(this, function (_d) {
|
|
2265
|
+
switch (_d.label) {
|
|
2266
|
+
case 0:
|
|
2267
|
+
availableModels = [];
|
|
2268
|
+
_d.label = 1;
|
|
2269
|
+
case 1:
|
|
2270
|
+
_d.trys.push([1, 6, 7, 8]);
|
|
2271
|
+
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
2272
|
+
_d.label = 2;
|
|
2273
|
+
case 2:
|
|
2274
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
2275
|
+
llmExecutionTools = _b.value;
|
|
2276
|
+
return [4 /*yield*/, llmExecutionTools.listModels()];
|
|
2277
|
+
case 3:
|
|
2278
|
+
models = _d.sent();
|
|
2279
|
+
availableModels.push.apply(availableModels, __spreadArray([], __read(models), false));
|
|
2280
|
+
_d.label = 4;
|
|
2281
|
+
case 4:
|
|
2282
|
+
_b = _a.next();
|
|
2283
|
+
return [3 /*break*/, 2];
|
|
2284
|
+
case 5: return [3 /*break*/, 8];
|
|
2285
|
+
case 6:
|
|
2286
|
+
e_1_1 = _d.sent();
|
|
2287
|
+
e_1 = { error: e_1_1 };
|
|
2288
|
+
return [3 /*break*/, 8];
|
|
2289
|
+
case 7:
|
|
2290
|
+
try {
|
|
2291
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2292
|
+
}
|
|
2293
|
+
finally { if (e_1) throw e_1.error; }
|
|
2294
|
+
return [7 /*endfinally*/];
|
|
2295
|
+
case 8: return [2 /*return*/, availableModels];
|
|
2296
|
+
}
|
|
2297
|
+
});
|
|
2298
|
+
});
|
|
2299
|
+
};
|
|
2246
2300
|
/**
|
|
2247
2301
|
* Calls the best available chat model
|
|
2248
2302
|
*/
|
|
@@ -2269,8 +2323,8 @@
|
|
|
2269
2323
|
*/
|
|
2270
2324
|
MultipleLlmExecutionTools.prototype.callCommonModel = function (prompt) {
|
|
2271
2325
|
return __awaiter(this, void 0, void 0, function () {
|
|
2272
|
-
var errors, _a, _b, llmExecutionTools, _c, error_1,
|
|
2273
|
-
var
|
|
2326
|
+
var errors, _a, _b, llmExecutionTools, _c, error_1, e_2_1;
|
|
2327
|
+
var e_2, _d;
|
|
2274
2328
|
var _this = this;
|
|
2275
2329
|
return __generator(this, function (_e) {
|
|
2276
2330
|
switch (_e.label) {
|
|
@@ -2326,14 +2380,14 @@
|
|
|
2326
2380
|
return [3 /*break*/, 2];
|
|
2327
2381
|
case 14: return [3 /*break*/, 17];
|
|
2328
2382
|
case 15:
|
|
2329
|
-
|
|
2330
|
-
|
|
2383
|
+
e_2_1 = _e.sent();
|
|
2384
|
+
e_2 = { error: e_2_1 };
|
|
2331
2385
|
return [3 /*break*/, 17];
|
|
2332
2386
|
case 16:
|
|
2333
2387
|
try {
|
|
2334
2388
|
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
2335
2389
|
}
|
|
2336
|
-
finally { if (
|
|
2390
|
+
finally { if (e_2) throw e_2.error; }
|
|
2337
2391
|
return [7 /*endfinally*/];
|
|
2338
2392
|
case 17:
|
|
2339
2393
|
if (errors.length === 1) {
|
|
@@ -2361,50 +2415,6 @@
|
|
|
2361
2415
|
});
|
|
2362
2416
|
});
|
|
2363
2417
|
};
|
|
2364
|
-
/**
|
|
2365
|
-
* List all available models that can be used
|
|
2366
|
-
* This lists is a combination of all available models from all execution tools
|
|
2367
|
-
*/
|
|
2368
|
-
MultipleLlmExecutionTools.prototype.listModels = function () {
|
|
2369
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2370
|
-
var availableModels, _a, _b, llmExecutionTools, models, e_2_1;
|
|
2371
|
-
var e_2, _c;
|
|
2372
|
-
return __generator(this, function (_d) {
|
|
2373
|
-
switch (_d.label) {
|
|
2374
|
-
case 0:
|
|
2375
|
-
availableModels = [];
|
|
2376
|
-
_d.label = 1;
|
|
2377
|
-
case 1:
|
|
2378
|
-
_d.trys.push([1, 6, 7, 8]);
|
|
2379
|
-
_a = __values(this.llmExecutionTools), _b = _a.next();
|
|
2380
|
-
_d.label = 2;
|
|
2381
|
-
case 2:
|
|
2382
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
2383
|
-
llmExecutionTools = _b.value;
|
|
2384
|
-
return [4 /*yield*/, llmExecutionTools.listModels()];
|
|
2385
|
-
case 3:
|
|
2386
|
-
models = _d.sent();
|
|
2387
|
-
availableModels.push.apply(availableModels, __spreadArray([], __read(models), false));
|
|
2388
|
-
_d.label = 4;
|
|
2389
|
-
case 4:
|
|
2390
|
-
_b = _a.next();
|
|
2391
|
-
return [3 /*break*/, 2];
|
|
2392
|
-
case 5: return [3 /*break*/, 8];
|
|
2393
|
-
case 6:
|
|
2394
|
-
e_2_1 = _d.sent();
|
|
2395
|
-
e_2 = { error: e_2_1 };
|
|
2396
|
-
return [3 /*break*/, 8];
|
|
2397
|
-
case 7:
|
|
2398
|
-
try {
|
|
2399
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
2400
|
-
}
|
|
2401
|
-
finally { if (e_2) throw e_2.error; }
|
|
2402
|
-
return [7 /*endfinally*/];
|
|
2403
|
-
case 8: return [2 /*return*/, availableModels];
|
|
2404
|
-
}
|
|
2405
|
-
});
|
|
2406
|
-
});
|
|
2407
|
-
};
|
|
2408
2418
|
return MultipleLlmExecutionTools;
|
|
2409
2419
|
}());
|
|
2410
2420
|
/**
|
|
@@ -3861,6 +3871,13 @@
|
|
|
3861
3871
|
// TODO: [🧠] Maybe put here some suffix
|
|
3862
3872
|
return llmTools.description;
|
|
3863
3873
|
},
|
|
3874
|
+
checkConfiguration: function () {
|
|
3875
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3876
|
+
return __generator(this, function (_a) {
|
|
3877
|
+
return [2 /*return*/, /* not await */ llmTools.checkConfiguration()];
|
|
3878
|
+
});
|
|
3879
|
+
});
|
|
3880
|
+
},
|
|
3864
3881
|
listModels: function () {
|
|
3865
3882
|
return /* not await */ llmTools.listModels();
|
|
3866
3883
|
},
|
|
@@ -6502,6 +6519,20 @@
|
|
|
6502
6519
|
return CallbackInterfaceTools;
|
|
6503
6520
|
}());
|
|
6504
6521
|
|
|
6522
|
+
/**
|
|
6523
|
+
* @@@
|
|
6524
|
+
*
|
|
6525
|
+
* Note: `$` is used to indicate that this function is not a pure function - it access global
|
|
6526
|
+
*
|
|
6527
|
+
* @public exported from `@promptbook/utils`
|
|
6528
|
+
*/
|
|
6529
|
+
function $getGlobalScope() {
|
|
6530
|
+
return Function('return this')();
|
|
6531
|
+
}
|
|
6532
|
+
/***
|
|
6533
|
+
* TODO: !!!!! Make private and promptbook registry from this
|
|
6534
|
+
*/
|
|
6535
|
+
|
|
6505
6536
|
/**
|
|
6506
6537
|
* Register is @@@
|
|
6507
6538
|
*
|
|
@@ -6516,13 +6547,30 @@
|
|
|
6516
6547
|
return this.storage;
|
|
6517
6548
|
};
|
|
6518
6549
|
Register.prototype.register = function (registered) {
|
|
6519
|
-
//
|
|
6520
|
-
|
|
6521
|
-
this.storage.
|
|
6550
|
+
// <- TODO: What to return here
|
|
6551
|
+
var packageName = registered.packageName, className = registered.className;
|
|
6552
|
+
var existingRegistrationIndex = this.storage.findIndex(function (item) { return item.packageName === packageName && item.className === className; });
|
|
6553
|
+
var existingRegistration = this.storage[existingRegistrationIndex];
|
|
6554
|
+
if (existingRegistration) {
|
|
6555
|
+
console.warn("!!!!!! Re-registering ".concat(packageName, ".").concat(className, " again"));
|
|
6556
|
+
this.storage[existingRegistrationIndex] = registered;
|
|
6557
|
+
}
|
|
6558
|
+
else {
|
|
6559
|
+
this.storage.push(registered);
|
|
6560
|
+
}
|
|
6522
6561
|
};
|
|
6523
6562
|
return Register;
|
|
6524
6563
|
}());
|
|
6525
6564
|
|
|
6565
|
+
// TODO: !!!!!! Move this logic to Register and rename to $Register
|
|
6566
|
+
var globalScope = $getGlobalScope();
|
|
6567
|
+
if (globalScope.$llmToolsMetadataRegister === undefined) {
|
|
6568
|
+
globalScope.$llmToolsMetadataRegister = [];
|
|
6569
|
+
}
|
|
6570
|
+
else if (!Array.isArray(globalScope.$llmToolsMetadataRegister)) {
|
|
6571
|
+
throw new UnexpectedError("Expected $llmToolsMetadataRegister to be an array, but got ".concat(typeof globalScope.$llmToolsMetadataRegister));
|
|
6572
|
+
}
|
|
6573
|
+
var _ = globalScope.$llmToolsMetadataRegister;
|
|
6526
6574
|
/**
|
|
6527
6575
|
* @@@
|
|
6528
6576
|
*
|
|
@@ -6530,9 +6578,8 @@
|
|
|
6530
6578
|
* @singleton Only one instance of each register is created per build, but thare can be more @@@
|
|
6531
6579
|
* @public exported from `@promptbook/core`
|
|
6532
6580
|
*/
|
|
6533
|
-
var $llmToolsMetadataRegister = new Register(
|
|
6534
|
-
|
|
6535
|
-
]);
|
|
6581
|
+
var $llmToolsMetadataRegister = new Register(_);
|
|
6582
|
+
$getGlobalScope().$llmToolsMetadataRegister;
|
|
6536
6583
|
|
|
6537
6584
|
/**
|
|
6538
6585
|
* @@@
|
|
@@ -6573,6 +6620,29 @@
|
|
|
6573
6620
|
enumerable: false,
|
|
6574
6621
|
configurable: true
|
|
6575
6622
|
});
|
|
6623
|
+
/**
|
|
6624
|
+
* Check the configuration of all execution tools
|
|
6625
|
+
*/
|
|
6626
|
+
RemoteLlmExecutionTools.prototype.checkConfiguration = function () {
|
|
6627
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6628
|
+
return __generator(this, function (_a) {
|
|
6629
|
+
return [2 /*return*/];
|
|
6630
|
+
});
|
|
6631
|
+
});
|
|
6632
|
+
};
|
|
6633
|
+
/**
|
|
6634
|
+
* List all available models that can be used
|
|
6635
|
+
*/
|
|
6636
|
+
RemoteLlmExecutionTools.prototype.listModels = function () {
|
|
6637
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6638
|
+
return __generator(this, function (_a) {
|
|
6639
|
+
return [2 /*return*/, (this.options.models ||
|
|
6640
|
+
[
|
|
6641
|
+
/* !!!!!! */
|
|
6642
|
+
])];
|
|
6643
|
+
});
|
|
6644
|
+
});
|
|
6645
|
+
};
|
|
6576
6646
|
/**
|
|
6577
6647
|
* Creates a connection to the remote proxy server.
|
|
6578
6648
|
*/
|
|
@@ -6667,19 +6737,6 @@
|
|
|
6667
6737
|
});
|
|
6668
6738
|
});
|
|
6669
6739
|
};
|
|
6670
|
-
/**
|
|
6671
|
-
* List all available models that can be used
|
|
6672
|
-
*/
|
|
6673
|
-
RemoteLlmExecutionTools.prototype.listModels = function () {
|
|
6674
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
6675
|
-
return __generator(this, function (_a) {
|
|
6676
|
-
return [2 /*return*/, (this.options.models ||
|
|
6677
|
-
[
|
|
6678
|
-
/* !!! */
|
|
6679
|
-
])];
|
|
6680
|
-
});
|
|
6681
|
-
});
|
|
6682
|
-
};
|
|
6683
6740
|
return RemoteLlmExecutionTools;
|
|
6684
6741
|
}());
|
|
6685
6742
|
/**
|
|
@@ -6876,12 +6933,10 @@
|
|
|
6876
6933
|
function AnthropicClaudeExecutionTools(options) {
|
|
6877
6934
|
if (options === void 0) { options = { isProxied: false }; }
|
|
6878
6935
|
this.options = options;
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
this.client = new Anthropic__default["default"](anthropicOptions);
|
|
6884
|
-
// <- TODO: !!!!!! Lazy-load client
|
|
6936
|
+
/**
|
|
6937
|
+
* Anthropic Claude API client.
|
|
6938
|
+
*/
|
|
6939
|
+
this.client = null;
|
|
6885
6940
|
}
|
|
6886
6941
|
Object.defineProperty(AnthropicClaudeExecutionTools.prototype, "title", {
|
|
6887
6942
|
get: function () {
|
|
@@ -6897,12 +6952,47 @@
|
|
|
6897
6952
|
enumerable: false,
|
|
6898
6953
|
configurable: true
|
|
6899
6954
|
});
|
|
6955
|
+
AnthropicClaudeExecutionTools.prototype.getClient = function () {
|
|
6956
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6957
|
+
var anthropicOptions;
|
|
6958
|
+
return __generator(this, function (_a) {
|
|
6959
|
+
if (this.client === null) {
|
|
6960
|
+
anthropicOptions = __assign({}, this.options);
|
|
6961
|
+
delete anthropicOptions.isVerbose;
|
|
6962
|
+
delete anthropicOptions.isProxied;
|
|
6963
|
+
this.client = new Anthropic__default["default"](anthropicOptions);
|
|
6964
|
+
}
|
|
6965
|
+
return [2 /*return*/, this.client];
|
|
6966
|
+
});
|
|
6967
|
+
});
|
|
6968
|
+
};
|
|
6969
|
+
/**
|
|
6970
|
+
* Check the `options` passed to `constructor`
|
|
6971
|
+
*/
|
|
6972
|
+
AnthropicClaudeExecutionTools.prototype.checkConfiguration = function () {
|
|
6973
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
6974
|
+
return __generator(this, function (_a) {
|
|
6975
|
+
switch (_a.label) {
|
|
6976
|
+
case 0: return [4 /*yield*/, this.getClient()];
|
|
6977
|
+
case 1:
|
|
6978
|
+
_a.sent();
|
|
6979
|
+
return [2 /*return*/];
|
|
6980
|
+
}
|
|
6981
|
+
});
|
|
6982
|
+
});
|
|
6983
|
+
};
|
|
6984
|
+
/**
|
|
6985
|
+
* List all available Anthropic Claude models that can be used
|
|
6986
|
+
*/
|
|
6987
|
+
AnthropicClaudeExecutionTools.prototype.listModels = function () {
|
|
6988
|
+
return ANTHROPIC_CLAUDE_MODELS;
|
|
6989
|
+
};
|
|
6900
6990
|
/**
|
|
6901
6991
|
* Calls Anthropic Claude API to use a chat model.
|
|
6902
6992
|
*/
|
|
6903
6993
|
AnthropicClaudeExecutionTools.prototype.callChatModel = function (prompt) {
|
|
6904
6994
|
return __awaiter(this, void 0, void 0, function () {
|
|
6905
|
-
var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, contentBlock, resultContent, usage;
|
|
6995
|
+
var content, parameters, modelRequirements, client, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, contentBlock, resultContent, usage;
|
|
6906
6996
|
return __generator(this, function (_a) {
|
|
6907
6997
|
switch (_a.label) {
|
|
6908
6998
|
case 0:
|
|
@@ -6910,6 +7000,9 @@
|
|
|
6910
7000
|
console.info('💬 Anthropic Claude callChatModel call');
|
|
6911
7001
|
}
|
|
6912
7002
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
7003
|
+
return [4 /*yield*/, this.getClient()];
|
|
7004
|
+
case 1:
|
|
7005
|
+
client = _a.sent();
|
|
6913
7006
|
// TODO: [☂] Use here more modelRequirements
|
|
6914
7007
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
6915
7008
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
@@ -6936,8 +7029,8 @@
|
|
|
6936
7029
|
if (this.options.isVerbose) {
|
|
6937
7030
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
6938
7031
|
}
|
|
6939
|
-
return [4 /*yield*/,
|
|
6940
|
-
case
|
|
7032
|
+
return [4 /*yield*/, client.messages.create(rawRequest)];
|
|
7033
|
+
case 2:
|
|
6941
7034
|
rawResponse = _a.sent();
|
|
6942
7035
|
if (this.options.isVerbose) {
|
|
6943
7036
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
@@ -7068,13 +7161,6 @@
|
|
|
7068
7161
|
AnthropicClaudeExecutionTools.prototype.getDefaultChatModel = function () {
|
|
7069
7162
|
return this.getDefaultModel('claude-3-opus');
|
|
7070
7163
|
};
|
|
7071
|
-
// <- Note: [🤖] getDefaultXxxModel
|
|
7072
|
-
/**
|
|
7073
|
-
* List all available Anthropic Claude models that can be used
|
|
7074
|
-
*/
|
|
7075
|
-
AnthropicClaudeExecutionTools.prototype.listModels = function () {
|
|
7076
|
-
return ANTHROPIC_CLAUDE_MODELS;
|
|
7077
|
-
};
|
|
7078
7164
|
return AnthropicClaudeExecutionTools;
|
|
7079
7165
|
}());
|
|
7080
7166
|
/**
|
|
@@ -7481,10 +7567,10 @@
|
|
|
7481
7567
|
*/
|
|
7482
7568
|
function AzureOpenAiExecutionTools(options) {
|
|
7483
7569
|
this.options = options;
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7570
|
+
/**
|
|
7571
|
+
* OpenAI Azure API client.
|
|
7572
|
+
*/
|
|
7573
|
+
this.client = null;
|
|
7488
7574
|
}
|
|
7489
7575
|
Object.defineProperty(AzureOpenAiExecutionTools.prototype, "title", {
|
|
7490
7576
|
get: function () {
|
|
@@ -7500,28 +7586,74 @@
|
|
|
7500
7586
|
enumerable: false,
|
|
7501
7587
|
configurable: true
|
|
7502
7588
|
});
|
|
7589
|
+
AzureOpenAiExecutionTools.prototype.getClient = function () {
|
|
7590
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7591
|
+
return __generator(this, function (_a) {
|
|
7592
|
+
if (this.client === null) {
|
|
7593
|
+
this.client = new openai.OpenAIClient("https://".concat(this.options.resourceName, ".openai.azure.com/"), new openai.AzureKeyCredential(this.options.apiKey));
|
|
7594
|
+
}
|
|
7595
|
+
return [2 /*return*/, this.client];
|
|
7596
|
+
});
|
|
7597
|
+
});
|
|
7598
|
+
};
|
|
7599
|
+
/**
|
|
7600
|
+
* Check the `options` passed to `constructor`
|
|
7601
|
+
*/
|
|
7602
|
+
AzureOpenAiExecutionTools.prototype.checkConfiguration = function () {
|
|
7603
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7604
|
+
return __generator(this, function (_a) {
|
|
7605
|
+
switch (_a.label) {
|
|
7606
|
+
case 0: return [4 /*yield*/, this.getClient()];
|
|
7607
|
+
case 1:
|
|
7608
|
+
_a.sent();
|
|
7609
|
+
return [2 /*return*/];
|
|
7610
|
+
}
|
|
7611
|
+
});
|
|
7612
|
+
});
|
|
7613
|
+
};
|
|
7614
|
+
/**
|
|
7615
|
+
* List all available Azure OpenAI models that can be used
|
|
7616
|
+
*/
|
|
7617
|
+
AzureOpenAiExecutionTools.prototype.listModels = function () {
|
|
7618
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7619
|
+
return __generator(this, function (_a) {
|
|
7620
|
+
// TODO: !!! Do here some filtering which models are really available as deployment
|
|
7621
|
+
// @see https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/deployments?api-version=2023-05-01
|
|
7622
|
+
return [2 /*return*/, OPENAI_MODELS.map(function (_a) {
|
|
7623
|
+
var modelTitle = _a.modelTitle, modelName = _a.modelName, modelVariant = _a.modelVariant;
|
|
7624
|
+
return ({
|
|
7625
|
+
modelTitle: "Azure ".concat(modelTitle),
|
|
7626
|
+
modelName: modelName,
|
|
7627
|
+
modelVariant: modelVariant,
|
|
7628
|
+
});
|
|
7629
|
+
})];
|
|
7630
|
+
});
|
|
7631
|
+
});
|
|
7632
|
+
};
|
|
7503
7633
|
/**
|
|
7504
7634
|
* Calls OpenAI API to use a chat model.
|
|
7505
7635
|
*/
|
|
7506
7636
|
AzureOpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
7507
7637
|
var _a, _b;
|
|
7508
7638
|
return __awaiter(this, void 0, void 0, function () {
|
|
7509
|
-
var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, messages, start, complete, rawRequest, rawResponse, resultContent, usage, error_1;
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
switch (_d.label) {
|
|
7639
|
+
var content, parameters, modelRequirements, client, modelName, modelSettings, rawPromptContent, messages, start, complete, rawRequest, rawResponse, resultContent, usage, error_1;
|
|
7640
|
+
return __generator(this, function (_c) {
|
|
7641
|
+
switch (_c.label) {
|
|
7513
7642
|
case 0:
|
|
7514
7643
|
if (this.options.isVerbose) {
|
|
7515
7644
|
console.info('💬 OpenAI callChatModel call');
|
|
7516
7645
|
}
|
|
7517
7646
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
7647
|
+
return [4 /*yield*/, this.getClient()];
|
|
7648
|
+
case 1:
|
|
7649
|
+
client = _c.sent();
|
|
7518
7650
|
// TODO: [☂] Use here more modelRequirements
|
|
7519
7651
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
7520
7652
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
7521
7653
|
}
|
|
7522
|
-
|
|
7523
|
-
case
|
|
7524
|
-
|
|
7654
|
+
_c.label = 2;
|
|
7655
|
+
case 2:
|
|
7656
|
+
_c.trys.push([2, 4, , 5]);
|
|
7525
7657
|
modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
7526
7658
|
modelSettings = {
|
|
7527
7659
|
maxTokens: modelRequirements.maxTokens,
|
|
@@ -7551,9 +7683,9 @@
|
|
|
7551
7683
|
console.info(colors__default["default"].bgWhite('messages'), JSON.stringify(messages, null, 4));
|
|
7552
7684
|
}
|
|
7553
7685
|
rawRequest = [modelName, messages, modelSettings];
|
|
7554
|
-
return [4 /*yield*/,
|
|
7555
|
-
case
|
|
7556
|
-
rawResponse =
|
|
7686
|
+
return [4 /*yield*/, client.getChatCompletions.apply(client, __spreadArray([], __read(rawRequest), false))];
|
|
7687
|
+
case 3:
|
|
7688
|
+
rawResponse = _c.sent();
|
|
7557
7689
|
if (this.options.isVerbose) {
|
|
7558
7690
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
7559
7691
|
}
|
|
@@ -7588,10 +7720,10 @@
|
|
|
7588
7720
|
rawResponse: rawResponse,
|
|
7589
7721
|
// <- [🗯]
|
|
7590
7722
|
}];
|
|
7591
|
-
case
|
|
7592
|
-
error_1 =
|
|
7723
|
+
case 4:
|
|
7724
|
+
error_1 = _c.sent();
|
|
7593
7725
|
throw this.transformAzureError(error_1);
|
|
7594
|
-
case
|
|
7726
|
+
case 5: return [2 /*return*/];
|
|
7595
7727
|
}
|
|
7596
7728
|
});
|
|
7597
7729
|
});
|
|
@@ -7602,22 +7734,24 @@
|
|
|
7602
7734
|
AzureOpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
7603
7735
|
var _a, _b;
|
|
7604
7736
|
return __awaiter(this, void 0, void 0, function () {
|
|
7605
|
-
var content, parameters, modelRequirements, modelName, modelSettings, start, complete, rawPromptContent, rawRequest, rawResponse, resultContent, usage, error_2;
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
switch (_d.label) {
|
|
7737
|
+
var content, parameters, modelRequirements, client, modelName, modelSettings, start, complete, rawPromptContent, rawRequest, rawResponse, resultContent, usage, error_2;
|
|
7738
|
+
return __generator(this, function (_c) {
|
|
7739
|
+
switch (_c.label) {
|
|
7609
7740
|
case 0:
|
|
7610
7741
|
if (this.options.isVerbose) {
|
|
7611
7742
|
console.info('🖋 OpenAI callCompletionModel call');
|
|
7612
7743
|
}
|
|
7613
7744
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
7745
|
+
return [4 /*yield*/, this.getClient()];
|
|
7746
|
+
case 1:
|
|
7747
|
+
client = _c.sent();
|
|
7614
7748
|
// TODO: [☂] Use here more modelRequirements
|
|
7615
7749
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
7616
7750
|
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
7617
7751
|
}
|
|
7618
|
-
|
|
7619
|
-
case
|
|
7620
|
-
|
|
7752
|
+
_c.label = 2;
|
|
7753
|
+
case 2:
|
|
7754
|
+
_c.trys.push([2, 4, , 5]);
|
|
7621
7755
|
modelName = prompt.modelRequirements.modelName || this.options.deploymentName;
|
|
7622
7756
|
modelSettings = {
|
|
7623
7757
|
maxTokens: modelRequirements.maxTokens || 2000,
|
|
@@ -7639,9 +7773,9 @@
|
|
|
7639
7773
|
[rawPromptContent],
|
|
7640
7774
|
modelSettings,
|
|
7641
7775
|
];
|
|
7642
|
-
return [4 /*yield*/,
|
|
7643
|
-
case
|
|
7644
|
-
rawResponse =
|
|
7776
|
+
return [4 /*yield*/, client.getCompletions.apply(client, __spreadArray([], __read(rawRequest), false))];
|
|
7777
|
+
case 3:
|
|
7778
|
+
rawResponse = _c.sent();
|
|
7645
7779
|
if (this.options.isVerbose) {
|
|
7646
7780
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
7647
7781
|
}
|
|
@@ -7673,10 +7807,10 @@
|
|
|
7673
7807
|
rawResponse: rawResponse,
|
|
7674
7808
|
// <- [🗯]
|
|
7675
7809
|
}];
|
|
7676
|
-
case
|
|
7677
|
-
error_2 =
|
|
7810
|
+
case 4:
|
|
7811
|
+
error_2 = _c.sent();
|
|
7678
7812
|
throw this.transformAzureError(error_2);
|
|
7679
|
-
case
|
|
7813
|
+
case 5: return [2 /*return*/];
|
|
7680
7814
|
}
|
|
7681
7815
|
});
|
|
7682
7816
|
});
|
|
@@ -7692,25 +7826,6 @@
|
|
|
7692
7826
|
var code = azureError.code, message = azureError.message;
|
|
7693
7827
|
return new PipelineExecutionError("".concat(code, ": ").concat(message));
|
|
7694
7828
|
};
|
|
7695
|
-
/**
|
|
7696
|
-
* List all available Azure OpenAI models that can be used
|
|
7697
|
-
*/
|
|
7698
|
-
AzureOpenAiExecutionTools.prototype.listModels = function () {
|
|
7699
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
7700
|
-
return __generator(this, function (_a) {
|
|
7701
|
-
// TODO: !!! Do here some filtering which models are really available as deployment
|
|
7702
|
-
// @see https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName/deployments?api-version=2023-05-01
|
|
7703
|
-
return [2 /*return*/, OPENAI_MODELS.map(function (_a) {
|
|
7704
|
-
var modelTitle = _a.modelTitle, modelName = _a.modelName, modelVariant = _a.modelVariant;
|
|
7705
|
-
return ({
|
|
7706
|
-
modelTitle: "Azure ".concat(modelTitle),
|
|
7707
|
-
modelName: modelName,
|
|
7708
|
-
modelVariant: modelVariant,
|
|
7709
|
-
});
|
|
7710
|
-
})];
|
|
7711
|
-
});
|
|
7712
|
-
});
|
|
7713
|
-
};
|
|
7714
7829
|
return AzureOpenAiExecutionTools;
|
|
7715
7830
|
}());
|
|
7716
7831
|
/**
|
|
@@ -7772,12 +7887,10 @@
|
|
|
7772
7887
|
function OpenAiExecutionTools(options) {
|
|
7773
7888
|
if (options === void 0) { options = {}; }
|
|
7774
7889
|
this.options = options;
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
this.client = new OpenAI__default["default"](__assign({}, openAiOptions));
|
|
7780
|
-
// <- TODO: !!!!!! Lazy-load client
|
|
7890
|
+
/**
|
|
7891
|
+
* OpenAI API client.
|
|
7892
|
+
*/
|
|
7893
|
+
this.client = null;
|
|
7781
7894
|
}
|
|
7782
7895
|
Object.defineProperty(OpenAiExecutionTools.prototype, "title", {
|
|
7783
7896
|
get: function () {
|
|
@@ -7793,12 +7906,54 @@
|
|
|
7793
7906
|
enumerable: false,
|
|
7794
7907
|
configurable: true
|
|
7795
7908
|
});
|
|
7909
|
+
OpenAiExecutionTools.prototype.getClient = function () {
|
|
7910
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7911
|
+
var openAiOptions;
|
|
7912
|
+
return __generator(this, function (_a) {
|
|
7913
|
+
if (this.client === null) {
|
|
7914
|
+
openAiOptions = __assign({}, this.options);
|
|
7915
|
+
delete openAiOptions.isVerbose;
|
|
7916
|
+
delete openAiOptions.user;
|
|
7917
|
+
this.client = new OpenAI__default["default"](__assign({}, openAiOptions));
|
|
7918
|
+
}
|
|
7919
|
+
return [2 /*return*/, this.client];
|
|
7920
|
+
});
|
|
7921
|
+
});
|
|
7922
|
+
};
|
|
7923
|
+
/**
|
|
7924
|
+
* Check the `options` passed to `constructor`
|
|
7925
|
+
*/
|
|
7926
|
+
OpenAiExecutionTools.prototype.checkConfiguration = function () {
|
|
7927
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
7928
|
+
return __generator(this, function (_a) {
|
|
7929
|
+
switch (_a.label) {
|
|
7930
|
+
case 0: return [4 /*yield*/, this.getClient()];
|
|
7931
|
+
case 1:
|
|
7932
|
+
_a.sent();
|
|
7933
|
+
return [2 /*return*/];
|
|
7934
|
+
}
|
|
7935
|
+
});
|
|
7936
|
+
});
|
|
7937
|
+
};
|
|
7938
|
+
/**
|
|
7939
|
+
* List all available OpenAI models that can be used
|
|
7940
|
+
*/
|
|
7941
|
+
OpenAiExecutionTools.prototype.listModels = function () {
|
|
7942
|
+
/*
|
|
7943
|
+
Note: Dynamic lising of the models
|
|
7944
|
+
const models = await this.openai.models.list({});
|
|
7945
|
+
|
|
7946
|
+
console.log({ models });
|
|
7947
|
+
console.log(models.data);
|
|
7948
|
+
*/
|
|
7949
|
+
return OPENAI_MODELS;
|
|
7950
|
+
};
|
|
7796
7951
|
/**
|
|
7797
7952
|
* Calls OpenAI API to use a chat model.
|
|
7798
7953
|
*/
|
|
7799
7954
|
OpenAiExecutionTools.prototype.callChatModel = function (prompt) {
|
|
7800
7955
|
return __awaiter(this, void 0, void 0, function () {
|
|
7801
|
-
var content, parameters, modelRequirements, expectFormat, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
7956
|
+
var content, parameters, modelRequirements, expectFormat, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
7802
7957
|
return __generator(this, function (_a) {
|
|
7803
7958
|
switch (_a.label) {
|
|
7804
7959
|
case 0:
|
|
@@ -7806,6 +7961,9 @@
|
|
|
7806
7961
|
console.info('💬 OpenAI callChatModel call', { prompt: prompt });
|
|
7807
7962
|
}
|
|
7808
7963
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements, expectFormat = prompt.expectFormat;
|
|
7964
|
+
return [4 /*yield*/, this.getClient()];
|
|
7965
|
+
case 1:
|
|
7966
|
+
client = _a.sent();
|
|
7809
7967
|
// TODO: [☂] Use here more modelRequirements
|
|
7810
7968
|
if (modelRequirements.modelVariant !== 'CHAT') {
|
|
7811
7969
|
throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
|
|
@@ -7842,8 +8000,8 @@
|
|
|
7842
8000
|
if (this.options.isVerbose) {
|
|
7843
8001
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
7844
8002
|
}
|
|
7845
|
-
return [4 /*yield*/,
|
|
7846
|
-
case
|
|
8003
|
+
return [4 /*yield*/, client.chat.completions.create(rawRequest)];
|
|
8004
|
+
case 2:
|
|
7847
8005
|
rawResponse = _a.sent();
|
|
7848
8006
|
if (this.options.isVerbose) {
|
|
7849
8007
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
@@ -7884,7 +8042,7 @@
|
|
|
7884
8042
|
*/
|
|
7885
8043
|
OpenAiExecutionTools.prototype.callCompletionModel = function (prompt) {
|
|
7886
8044
|
return __awaiter(this, void 0, void 0, function () {
|
|
7887
|
-
var content, parameters, modelRequirements, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
8045
|
+
var content, parameters, modelRequirements, client, modelName, modelSettings, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
7888
8046
|
return __generator(this, function (_a) {
|
|
7889
8047
|
switch (_a.label) {
|
|
7890
8048
|
case 0:
|
|
@@ -7892,6 +8050,9 @@
|
|
|
7892
8050
|
console.info('🖋 OpenAI callCompletionModel call', { prompt: prompt });
|
|
7893
8051
|
}
|
|
7894
8052
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
8053
|
+
return [4 /*yield*/, this.getClient()];
|
|
8054
|
+
case 1:
|
|
8055
|
+
client = _a.sent();
|
|
7895
8056
|
// TODO: [☂] Use here more modelRequirements
|
|
7896
8057
|
if (modelRequirements.modelVariant !== 'COMPLETION') {
|
|
7897
8058
|
throw new PipelineExecutionError('Use callCompletionModel only for COMPLETION variant');
|
|
@@ -7911,8 +8072,8 @@
|
|
|
7911
8072
|
if (this.options.isVerbose) {
|
|
7912
8073
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
7913
8074
|
}
|
|
7914
|
-
return [4 /*yield*/,
|
|
7915
|
-
case
|
|
8075
|
+
return [4 /*yield*/, client.completions.create(rawRequest)];
|
|
8076
|
+
case 2:
|
|
7916
8077
|
rawResponse = _a.sent();
|
|
7917
8078
|
if (this.options.isVerbose) {
|
|
7918
8079
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
@@ -7950,7 +8111,7 @@
|
|
|
7950
8111
|
*/
|
|
7951
8112
|
OpenAiExecutionTools.prototype.callEmbeddingModel = function (prompt) {
|
|
7952
8113
|
return __awaiter(this, void 0, void 0, function () {
|
|
7953
|
-
var content, parameters, modelRequirements, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
8114
|
+
var content, parameters, modelRequirements, client, modelName, rawPromptContent, rawRequest, start, complete, rawResponse, resultContent, usage;
|
|
7954
8115
|
return __generator(this, function (_a) {
|
|
7955
8116
|
switch (_a.label) {
|
|
7956
8117
|
case 0:
|
|
@@ -7958,6 +8119,9 @@
|
|
|
7958
8119
|
console.info('🖋 OpenAI embedding call', { prompt: prompt });
|
|
7959
8120
|
}
|
|
7960
8121
|
content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
|
|
8122
|
+
return [4 /*yield*/, this.getClient()];
|
|
8123
|
+
case 1:
|
|
8124
|
+
client = _a.sent();
|
|
7961
8125
|
// TODO: [☂] Use here more modelRequirements
|
|
7962
8126
|
if (modelRequirements.modelVariant !== 'EMBEDDING') {
|
|
7963
8127
|
throw new PipelineExecutionError('Use embed only for EMBEDDING variant');
|
|
@@ -7972,8 +8136,8 @@
|
|
|
7972
8136
|
if (this.options.isVerbose) {
|
|
7973
8137
|
console.info(colors__default["default"].bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
|
|
7974
8138
|
}
|
|
7975
|
-
return [4 /*yield*/,
|
|
7976
|
-
case
|
|
8139
|
+
return [4 /*yield*/, client.embeddings.create(rawRequest)];
|
|
8140
|
+
case 2:
|
|
7977
8141
|
rawResponse = _a.sent();
|
|
7978
8142
|
if (this.options.isVerbose) {
|
|
7979
8143
|
console.info(colors__default["default"].bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
|
|
@@ -8039,20 +8203,6 @@
|
|
|
8039
8203
|
OpenAiExecutionTools.prototype.getDefaultEmbeddingModel = function () {
|
|
8040
8204
|
return this.getDefaultModel('text-embedding-3-large');
|
|
8041
8205
|
};
|
|
8042
|
-
// <- Note: [🤖] getDefaultXxxModel
|
|
8043
|
-
/**
|
|
8044
|
-
* List all available OpenAI models that can be used
|
|
8045
|
-
*/
|
|
8046
|
-
OpenAiExecutionTools.prototype.listModels = function () {
|
|
8047
|
-
/*
|
|
8048
|
-
Note: Dynamic lising of the models
|
|
8049
|
-
const models = await this.openai.models.list({});
|
|
8050
|
-
|
|
8051
|
-
console.log({ models });
|
|
8052
|
-
console.log(models.data);
|
|
8053
|
-
*/
|
|
8054
|
-
return OPENAI_MODELS;
|
|
8055
|
-
};
|
|
8056
8206
|
return OpenAiExecutionTools;
|
|
8057
8207
|
}());
|
|
8058
8208
|
/**
|