@promptbook/anthropic-claude
Advanced tools
Comparing version 0.66.0-8 to 0.66.0-9
@@ -10,3 +10,3 @@ import Anthropic from '@anthropic-ai/sdk'; | ||
*/ | ||
var PROMPTBOOK_VERSION = '0.66.0-7'; | ||
var PROMPTBOOK_VERSION = '0.66.0-8'; | ||
// TODO: !!!! List here all the versions and annotate + put into script | ||
@@ -1125,4 +1125,11 @@ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var socket; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.makeConnection()]; | ||
case 1: | ||
socket = _a.sent(); | ||
socket.disconnect(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -1136,7 +1143,35 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var socket, promptResult; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (this.options.models || | ||
[ | ||
/* !!!!!! */ | ||
])]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.makeConnection()]; | ||
case 1: | ||
socket = _a.sent(); | ||
if (this.options.isAnonymous) { | ||
socket.emit('listModels-request', { | ||
isAnonymous: true, | ||
llmToolsConfiguration: this.options.llmToolsConfiguration, | ||
}); | ||
} | ||
else { | ||
socket.emit('listModels-request', { | ||
isAnonymous: false, | ||
clientId: this.options.clientId, | ||
}); | ||
} | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
socket.on('listModels-response', function (response) { | ||
resolve(response.models); | ||
socket.disconnect(); | ||
}); | ||
socket.on('error', function (error) { | ||
reject(new Error(error.errorMessage)); | ||
socket.disconnect(); | ||
}); | ||
})]; | ||
case 2: | ||
promptResult = _a.sent(); | ||
socket.disconnect(); | ||
return [2 /*return*/, promptResult]; | ||
} | ||
}); | ||
@@ -1208,3 +1243,4 @@ }); | ||
if (this.options.isAnonymous) { | ||
socket.emit('request', { | ||
socket.emit('prompt-request', { | ||
isAnonymous: true, | ||
llmToolsConfiguration: this.options.llmToolsConfiguration, | ||
@@ -1216,3 +1252,4 @@ prompt: prompt, | ||
else { | ||
socket.emit('request', { | ||
socket.emit('prompt-request', { | ||
isAnonymous: false, | ||
clientId: this.options.clientId, | ||
@@ -1224,3 +1261,3 @@ prompt: prompt, | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
socket.on('response', function (response) { | ||
socket.on('prompt-response', function (response) { | ||
resolve(response.promptResult); | ||
@@ -1245,2 +1282,3 @@ socket.disconnect(); | ||
/** | ||
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'` | ||
* TODO: [🍓] Allow to list compatible models with each variant | ||
@@ -1266,3 +1304,3 @@ * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable | ||
}, | ||
], models: ANTHROPIC_CLAUDE_MODELS })); | ||
] })); | ||
} | ||
@@ -1283,15 +1321,40 @@ return new AnthropicClaudeExecutionTools(options); | ||
/** | ||
* @@@ | ||
* | ||
* Note: `$` is used to indicate that this function is not a pure function - it access global scope | ||
* | ||
* @public exported from `@promptbook/utils` | ||
*/ | ||
function $getGlobalScope() { | ||
return Function('return this')(); | ||
} | ||
/*** | ||
* TODO: !!!!! Make private and promptbook registry from this | ||
*/ | ||
/** | ||
* Register is @@@ | ||
* | ||
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope. | ||
* | ||
* @private internal utility, exported are only signleton instances of this class | ||
*/ | ||
var Register = /** @class */ (function () { | ||
function Register(storage) { | ||
this.storage = storage; | ||
var $Register = /** @class */ (function () { | ||
function $Register(storageName) { | ||
this.storageName = storageName; | ||
storageName = "_promptbook_".concat(storageName); | ||
var globalScope = $getGlobalScope(); | ||
if (globalScope[storageName] === undefined) { | ||
globalScope[storageName] = []; | ||
} | ||
else if (!Array.isArray(globalScope[storageName])) { | ||
throw new UnexpectedError("Expected (global) ".concat(storageName, " to be an array, but got ").concat(typeof globalScope[storageName])); | ||
} | ||
this.storage = globalScope[storageName]; | ||
} | ||
Register.prototype.list = function () { | ||
$Register.prototype.list = function () { | ||
// <- TODO: ReadonlyDeep<Array<TRegistered>> | ||
return this.storage; | ||
}; | ||
Register.prototype.register = function (registered) { | ||
$Register.prototype.register = function (registered) { | ||
// <- TODO: What to return here | ||
@@ -1301,12 +1364,13 @@ var packageName = registered.packageName, className = registered.className; | ||
var existingRegistration = this.storage[existingRegistrationIndex]; | ||
// TODO: !!!!!! Global IS_VERBOSE mode | ||
if (!existingRegistration) { | ||
console.warn("[\uD83D\uDCE6] Registering ".concat(packageName, ".").concat(className, " again")); | ||
console.warn("[\uD83D\uDCE6] Registering `".concat(packageName, ".").concat(className, "` to `").concat(this.storageName, "`")); | ||
this.storage.push(registered); | ||
} | ||
else { | ||
console.warn("[\uD83D\uDCE6] Re-registering ".concat(packageName, ".").concat(className, " again")); | ||
console.warn("[\uD83D\uDCE6] Re-registering `".concat(packageName, ".").concat(className, "` to `").concat(this.storageName, "`")); | ||
this.storage[existingRegistrationIndex] = registered; | ||
} | ||
}; | ||
return Register; | ||
return $Register; | ||
}()); | ||
@@ -1321,5 +1385,3 @@ | ||
*/ | ||
var $llmToolsRegister = new Register([ | ||
// TODO: !!!!!! Take from global scope | ||
]); | ||
var $llmToolsRegister = new $Register('llm_execution_tools_constructors'); | ||
@@ -1332,2 +1394,3 @@ /** | ||
* @public exported from `@promptbook/anthropic-claude` | ||
* @public exported from `@promptbook/cli` | ||
*/ | ||
@@ -1339,9 +1402,3 @@ var _AnthropicClaudeRegistration = $llmToolsRegister.register(createAnthropicClaudeExecutionTools); | ||
console.log("!!!!!! Registering 1 Anthropic Claude provider"); | ||
/** | ||
* @public exported from `@promptbook/anthropic-claude` | ||
*/ | ||
var _ = undefined; | ||
export { ANTHROPIC_CLAUDE_MODELS, AnthropicClaudeExecutionTools, PROMPTBOOK_VERSION, _, _AnthropicClaudeRegistration, createAnthropicClaudeExecutionTools }; | ||
export { ANTHROPIC_CLAUDE_MODELS, AnthropicClaudeExecutionTools, PROMPTBOOK_VERSION, _AnthropicClaudeRegistration, createAnthropicClaudeExecutionTools }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -9,3 +9,2 @@ import { PROMPTBOOK_VERSION } from '../version'; | ||
import { _AnthropicClaudeRegistration } from '../llm-providers/anthropic-claude/register-constructor'; | ||
import { _ } from '../llm-providers/anthropic-claude/register1'; | ||
export { PROMPTBOOK_VERSION }; | ||
@@ -19,2 +18,1 @@ export { ANTHROPIC_CLAUDE_MODELS }; | ||
export { _AnthropicClaudeRegistration }; | ||
export { _ }; |
import { PROMPTBOOK_VERSION } from '../version'; | ||
import { _CLI } from '../cli/main'; | ||
import { _AnthropicClaudeMetadataRegistration } from '../llm-providers/anthropic-claude/register-configuration'; | ||
import { _AnthropicClaudeRegistration } from '../llm-providers/anthropic-claude/register-constructor'; | ||
import { _AzureOpenAiMetadataRegistration } from '../llm-providers/azure-openai/register-configuration'; | ||
import { _AzureOpenAiRegistration } from '../llm-providers/azure-openai/register-constructor'; | ||
import { _OpenAiMetadataRegistration } from '../llm-providers/openai/register-configuration'; | ||
import { _OpenAiRegistration } from '../llm-providers/openai/register-constructor'; | ||
export { PROMPTBOOK_VERSION }; | ||
export { _CLI }; | ||
export { _AnthropicClaudeMetadataRegistration }; | ||
export { _AnthropicClaudeRegistration }; | ||
export { _AzureOpenAiMetadataRegistration }; | ||
export { _AzureOpenAiRegistration }; | ||
export { _OpenAiMetadataRegistration }; | ||
export { _OpenAiRegistration }; |
@@ -47,8 +47,12 @@ import type { PipelineCollection } from '../collection/PipelineCollection'; | ||
import type { OpenAiExecutionToolsOptions } from '../llm-providers/openai/OpenAiExecutionToolsOptions'; | ||
import type { Promptbook_Server_Error } from '../llm-providers/remote/interfaces/Promptbook_Server_Error'; | ||
import type { Promptbook_Server_Progress } from '../llm-providers/remote/interfaces/Promptbook_Server_Progress'; | ||
import type { Promptbook_Server_Request } from '../llm-providers/remote/interfaces/Promptbook_Server_Request'; | ||
import type { Promptbook_Server_CollectionRequest } from '../llm-providers/remote/interfaces/Promptbook_Server_Request'; | ||
import type { Promptbook_Server_AnonymousRequest } from '../llm-providers/remote/interfaces/Promptbook_Server_Request'; | ||
import type { Promptbook_Server_Response } from '../llm-providers/remote/interfaces/Promptbook_Server_Response'; | ||
import type { PromptbookServer_Error } from '../llm-providers/remote/interfaces/PromptbookServer_Error'; | ||
import type { PromptbookServer_ListModels_Request } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request'; | ||
import type { PromptbookServer_ListModels_CollectionRequest } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request'; | ||
import type { PromptbookServer_ListModels_AnonymousRequest } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Request'; | ||
import type { PromptbookServer_ListModels_Response } from '../llm-providers/remote/interfaces/PromptbookServer_ListModels_Response'; | ||
import type { PromptbookServer_Prompt_Progress } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Progress'; | ||
import type { PromptbookServer_Prompt_Request } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request'; | ||
import type { PromptbookServer_Prompt_CollectionRequest } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request'; | ||
import type { PromptbookServer_Prompt_AnonymousRequest } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Request'; | ||
import type { PromptbookServer_Prompt_Response } from '../llm-providers/remote/interfaces/PromptbookServer_Prompt_Response'; | ||
import type { RemoteLlmExecutionToolsOptions } from '../llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions'; | ||
@@ -207,2 +211,3 @@ import type { RemoteServerOptions } from '../llm-providers/remote/interfaces/RemoteServerOptions'; | ||
import type { number_terabytes } from '../types/typeAliases'; | ||
import type { Registered } from '../utils/$Register'; | ||
import type { FromtoItems } from '../utils/FromtoItems'; | ||
@@ -220,3 +225,2 @@ import type { CodeBlock } from '../utils/markdown/extractAllBlocksFromMarkdown'; | ||
import type { TODO_any } from '../utils/organization/TODO_any'; | ||
import type { Registered } from '../utils/Register'; | ||
import type { string_promptbook_version } from '../version'; | ||
@@ -269,8 +273,12 @@ export type { PipelineCollection }; | ||
export type { OpenAiExecutionToolsOptions }; | ||
export type { Promptbook_Server_Error }; | ||
export type { Promptbook_Server_Progress }; | ||
export type { Promptbook_Server_Request }; | ||
export type { Promptbook_Server_CollectionRequest }; | ||
export type { Promptbook_Server_AnonymousRequest }; | ||
export type { Promptbook_Server_Response }; | ||
export type { PromptbookServer_Error }; | ||
export type { PromptbookServer_ListModels_Request }; | ||
export type { PromptbookServer_ListModels_CollectionRequest }; | ||
export type { PromptbookServer_ListModels_AnonymousRequest }; | ||
export type { PromptbookServer_ListModels_Response }; | ||
export type { PromptbookServer_Prompt_Progress }; | ||
export type { PromptbookServer_Prompt_Request }; | ||
export type { PromptbookServer_Prompt_CollectionRequest }; | ||
export type { PromptbookServer_Prompt_AnonymousRequest }; | ||
export type { PromptbookServer_Prompt_Response }; | ||
export type { RemoteLlmExecutionToolsOptions }; | ||
@@ -429,2 +437,3 @@ export type { RemoteServerOptions }; | ||
export type { number_terabytes }; | ||
export type { Registered }; | ||
export type { FromtoItems }; | ||
@@ -442,3 +451,2 @@ export type { CodeBlock }; | ||
export type { TODO_any }; | ||
export type { Registered }; | ||
export type { string_promptbook_version }; |
@@ -10,10 +10,10 @@ import { PROMPTBOOK_VERSION } from '../version'; | ||
import { extractBlock } from '../postprocessing/utils/extractBlock'; | ||
import { $currentDate } from '../utils/$currentDate'; | ||
import { clonePipeline } from '../utils/clonePipeline'; | ||
import { $currentDate } from '../utils/currentDate'; | ||
import { deepClone } from '../utils/deepClone'; | ||
import { $deepFreeze } from '../utils/deepFreeze'; | ||
import { $getGlobalScope } from '../utils/environment/getGlobalScope'; | ||
import { $isRunningInBrowser } from '../utils/environment/isRunningInBrowser'; | ||
import { $isRunningInNode } from '../utils/environment/isRunningInNode'; | ||
import { $isRunningInWebWorker } from '../utils/environment/isRunningInWebWorker'; | ||
import { $getGlobalScope } from '../utils/environment/$getGlobalScope'; | ||
import { $isRunningInBrowser } from '../utils/environment/$isRunningInBrowser'; | ||
import { $isRunningInNode } from '../utils/environment/$isRunningInNode'; | ||
import { $isRunningInWebWorker } from '../utils/environment/$isRunningInWebWorker'; | ||
import { countCharacters } from '../utils/expectation-counters/countCharacters'; | ||
@@ -51,3 +51,3 @@ import { countLines } from '../utils/expectation-counters/countLines'; | ||
import { parseNumber } from '../utils/parseNumber'; | ||
import { $randomSeed } from '../utils/random/randomSeed'; | ||
import { $randomSeed } from '../utils/random/$randomSeed'; | ||
import { removeEmojis } from '../utils/removeEmojis'; | ||
@@ -81,4 +81,4 @@ import { removeQuotes } from '../utils/removeQuotes'; | ||
export { extractBlock }; | ||
export { $currentDate }; | ||
export { clonePipeline }; | ||
export { $currentDate }; | ||
export { deepClone }; | ||
@@ -85,0 +85,0 @@ export { $deepFreeze }; |
@@ -0,3 +1,3 @@ | ||
import type { Registered } from '../utils/$Register'; | ||
import type { TODO_any } from '../utils/organization/TODO_any'; | ||
import type { Registered } from '../utils/Register'; | ||
import type { LlmExecutionTools } from './LlmExecutionTools'; | ||
@@ -4,0 +4,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Register } from '../../utils/Register'; | ||
import { $Register } from '../../utils/$Register'; | ||
import type { LlmToolsMetadata } from './LlmToolsMetadata'; | ||
@@ -10,2 +10,2 @@ /** | ||
*/ | ||
export declare const $llmToolsMetadataRegister: Register<LlmToolsMetadata>; | ||
export declare const $llmToolsMetadataRegister: $Register<LlmToolsMetadata>; |
import type { LlmExecutionToolsConstructor } from '../../execution/LlmExecutionToolsConstructor'; | ||
import { Register } from '../../utils/Register'; | ||
import { $Register } from '../../utils/$Register'; | ||
/** | ||
@@ -10,2 +10,2 @@ * @@@ | ||
*/ | ||
export declare const $llmToolsRegister: Register<LlmExecutionToolsConstructor>; | ||
export declare const $llmToolsRegister: $Register<LlmExecutionToolsConstructor>; |
@@ -16,2 +16,3 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration'; | ||
/** | ||
* TODO: [🧠][🪁] Maybe do allow to do auto-install if package not registered and not found | ||
* TODO: Add Azure OpenAI | ||
@@ -18,0 +19,0 @@ * TODO: [🧠][🍛] |
@@ -1,2 +0,2 @@ | ||
import '../../_packages/core.index'; | ||
import '../../_packages/cli.index'; | ||
import type { CreateLlmToolsFromConfigurationOptions } from './createLlmToolsFromConfiguration'; | ||
@@ -3,0 +3,0 @@ import type { LlmExecutionToolsWithTotalUsage } from './utils/count-total-usage/LlmExecutionToolsWithTotalUsage'; |
import type { string_title } from '../../types/typeAliases'; | ||
import type { Registered } from '../../utils/Register'; | ||
import type { Registered } from '../../utils/$Register'; | ||
import type { LlmToolsOptions } from './LlmToolsOptions'; | ||
@@ -4,0 +4,0 @@ /** |
import type { string_name } from '../../types/typeAliases'; | ||
import type { string_title } from '../../types/typeAliases'; | ||
import type { Registered } from '../../utils/Register'; | ||
import type { Registered } from '../../utils/$Register'; | ||
import type { LlmToolsConfiguration } from './LlmToolsConfiguration'; | ||
@@ -5,0 +5,0 @@ /** |
@@ -7,2 +7,3 @@ /** | ||
* @public exported from `@promptbook/anthropic-claude` | ||
* @public exported from `@promptbook/cli` | ||
*/ | ||
@@ -9,0 +10,0 @@ export declare const _AnthropicClaudeRegistration: void; |
@@ -7,2 +7,3 @@ /** | ||
* @public exported from `@promptbook/azure-openai` | ||
* @public exported from `@promptbook/cli` | ||
*/ | ||
@@ -9,0 +10,0 @@ export declare const _AzureOpenAiRegistration: void; |
@@ -7,2 +7,3 @@ /** | ||
* @public exported from `@promptbook/openai` | ||
* @public exported from `@promptbook/cli` | ||
*/ | ||
@@ -9,0 +10,0 @@ export declare const _OpenAiRegistration: void; |
@@ -1,2 +0,1 @@ | ||
import type { AvailableModel } from '../../../execution/AvailableModel'; | ||
import type { CommonExecutionToolsOptions } from '../../../execution/CommonExecutionToolsOptions'; | ||
@@ -26,8 +25,2 @@ import type { client_id } from '../../../types/typeAliases'; | ||
/** | ||
* If set, only these models will be listed as available | ||
* | ||
* TODO: [🧠] !!!!!! Figure out better solution | ||
*/ | ||
readonly models?: Array<AvailableModel>; | ||
/** | ||
* Mode of the server to connect to | ||
@@ -56,3 +49,4 @@ */ | ||
/** | ||
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'` | ||
* TODO: [🧠][🧜♂️] Maybe join remoteUrl and path into single value | ||
*/ |
@@ -57,2 +57,3 @@ import type { AvailableModel } from '../../execution/AvailableModel'; | ||
/** | ||
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'` | ||
* TODO: [🍓] Allow to list compatible models with each variant | ||
@@ -59,0 +60,0 @@ * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable |
@@ -14,2 +14,3 @@ import type { IDestroyable } from 'destroyable'; | ||
/** | ||
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'` | ||
* TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl | ||
@@ -16,0 +17,0 @@ * TODO: Handle progress - support streaming |
{ | ||
"name": "@promptbook/anthropic-claude", | ||
"version": "0.66.0-8", | ||
"version": "0.66.0-9", | ||
"description": "Supercharge your use of large language models", | ||
@@ -50,3 +50,3 @@ "private": false, | ||
"peerDependencies": { | ||
"@promptbook/core": "0.66.0-8" | ||
"@promptbook/core": "0.66.0-9" | ||
}, | ||
@@ -53,0 +53,0 @@ "dependencies": { |
@@ -17,3 +17,3 @@ (function (global, factory) { | ||
*/ | ||
var PROMPTBOOK_VERSION = '0.66.0-7'; | ||
var PROMPTBOOK_VERSION = '0.66.0-8'; | ||
// TODO: !!!! List here all the versions and annotate + put into script | ||
@@ -1132,4 +1132,11 @@ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var socket; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.makeConnection()]; | ||
case 1: | ||
socket = _a.sent(); | ||
socket.disconnect(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
@@ -1143,7 +1150,35 @@ }); | ||
return __awaiter(this, void 0, void 0, function () { | ||
var socket, promptResult; | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, (this.options.models || | ||
[ | ||
/* !!!!!! */ | ||
])]; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.makeConnection()]; | ||
case 1: | ||
socket = _a.sent(); | ||
if (this.options.isAnonymous) { | ||
socket.emit('listModels-request', { | ||
isAnonymous: true, | ||
llmToolsConfiguration: this.options.llmToolsConfiguration, | ||
}); | ||
} | ||
else { | ||
socket.emit('listModels-request', { | ||
isAnonymous: false, | ||
clientId: this.options.clientId, | ||
}); | ||
} | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
socket.on('listModels-response', function (response) { | ||
resolve(response.models); | ||
socket.disconnect(); | ||
}); | ||
socket.on('error', function (error) { | ||
reject(new Error(error.errorMessage)); | ||
socket.disconnect(); | ||
}); | ||
})]; | ||
case 2: | ||
promptResult = _a.sent(); | ||
socket.disconnect(); | ||
return [2 /*return*/, promptResult]; | ||
} | ||
}); | ||
@@ -1215,3 +1250,4 @@ }); | ||
if (this.options.isAnonymous) { | ||
socket.emit('request', { | ||
socket.emit('prompt-request', { | ||
isAnonymous: true, | ||
llmToolsConfiguration: this.options.llmToolsConfiguration, | ||
@@ -1223,3 +1259,4 @@ prompt: prompt, | ||
else { | ||
socket.emit('request', { | ||
socket.emit('prompt-request', { | ||
isAnonymous: false, | ||
clientId: this.options.clientId, | ||
@@ -1231,3 +1268,3 @@ prompt: prompt, | ||
return [4 /*yield*/, new Promise(function (resolve, reject) { | ||
socket.on('response', function (response) { | ||
socket.on('prompt-response', function (response) { | ||
resolve(response.promptResult); | ||
@@ -1252,2 +1289,3 @@ socket.disconnect(); | ||
/** | ||
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'` | ||
* TODO: [🍓] Allow to list compatible models with each variant | ||
@@ -1273,3 +1311,3 @@ * TODO: [🗯] RemoteLlmExecutionTools should extend Destroyable and implement IDestroyable | ||
}, | ||
], models: ANTHROPIC_CLAUDE_MODELS })); | ||
] })); | ||
} | ||
@@ -1290,15 +1328,40 @@ return new AnthropicClaudeExecutionTools(options); | ||
/** | ||
* @@@ | ||
* | ||
* Note: `$` is used to indicate that this function is not a pure function - it access global scope | ||
* | ||
* @public exported from `@promptbook/utils` | ||
*/ | ||
function $getGlobalScope() { | ||
return Function('return this')(); | ||
} | ||
/*** | ||
* TODO: !!!!! Make private and promptbook registry from this | ||
*/ | ||
/** | ||
* Register is @@@ | ||
* | ||
* Note: `$` is used to indicate that this function is not a pure function - it accesses and adds variables in global scope. | ||
* | ||
* @private internal utility, exported are only signleton instances of this class | ||
*/ | ||
var Register = /** @class */ (function () { | ||
function Register(storage) { | ||
this.storage = storage; | ||
var $Register = /** @class */ (function () { | ||
function $Register(storageName) { | ||
this.storageName = storageName; | ||
storageName = "_promptbook_".concat(storageName); | ||
var globalScope = $getGlobalScope(); | ||
if (globalScope[storageName] === undefined) { | ||
globalScope[storageName] = []; | ||
} | ||
else if (!Array.isArray(globalScope[storageName])) { | ||
throw new UnexpectedError("Expected (global) ".concat(storageName, " to be an array, but got ").concat(typeof globalScope[storageName])); | ||
} | ||
this.storage = globalScope[storageName]; | ||
} | ||
Register.prototype.list = function () { | ||
$Register.prototype.list = function () { | ||
// <- TODO: ReadonlyDeep<Array<TRegistered>> | ||
return this.storage; | ||
}; | ||
Register.prototype.register = function (registered) { | ||
$Register.prototype.register = function (registered) { | ||
// <- TODO: What to return here | ||
@@ -1308,12 +1371,13 @@ var packageName = registered.packageName, className = registered.className; | ||
var existingRegistration = this.storage[existingRegistrationIndex]; | ||
// TODO: !!!!!! Global IS_VERBOSE mode | ||
if (!existingRegistration) { | ||
console.warn("[\uD83D\uDCE6] Registering ".concat(packageName, ".").concat(className, " again")); | ||
console.warn("[\uD83D\uDCE6] Registering `".concat(packageName, ".").concat(className, "` to `").concat(this.storageName, "`")); | ||
this.storage.push(registered); | ||
} | ||
else { | ||
console.warn("[\uD83D\uDCE6] Re-registering ".concat(packageName, ".").concat(className, " again")); | ||
console.warn("[\uD83D\uDCE6] Re-registering `".concat(packageName, ".").concat(className, "` to `").concat(this.storageName, "`")); | ||
this.storage[existingRegistrationIndex] = registered; | ||
} | ||
}; | ||
return Register; | ||
return $Register; | ||
}()); | ||
@@ -1328,5 +1392,3 @@ | ||
*/ | ||
var $llmToolsRegister = new Register([ | ||
// TODO: !!!!!! Take from global scope | ||
]); | ||
var $llmToolsRegister = new $Register('llm_execution_tools_constructors'); | ||
@@ -1339,2 +1401,3 @@ /** | ||
* @public exported from `@promptbook/anthropic-claude` | ||
* @public exported from `@promptbook/cli` | ||
*/ | ||
@@ -1346,12 +1409,5 @@ var _AnthropicClaudeRegistration = $llmToolsRegister.register(createAnthropicClaudeExecutionTools); | ||
console.log("!!!!!! Registering 1 Anthropic Claude provider"); | ||
/** | ||
* @public exported from `@promptbook/anthropic-claude` | ||
*/ | ||
var _ = undefined; | ||
exports.ANTHROPIC_CLAUDE_MODELS = ANTHROPIC_CLAUDE_MODELS; | ||
exports.AnthropicClaudeExecutionTools = AnthropicClaudeExecutionTools; | ||
exports.PROMPTBOOK_VERSION = PROMPTBOOK_VERSION; | ||
exports._ = _; | ||
exports._AnthropicClaudeRegistration = _AnthropicClaudeRegistration; | ||
@@ -1358,0 +1414,0 @@ exports.createAnthropicClaudeExecutionTools = createAnthropicClaudeExecutionTools; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
588198
464
10721
2