@promptbook/core 0.89.0 → 0.92.0-3
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/README.md +4 -0
- package/esm/index.es.js +77 -2
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +2 -0
- package/esm/typings/src/llm-providers/_common/filterModels.d.ts +15 -0
- package/package.json +1 -1
- package/umd/index.umd.js +77 -1
- package/umd/index.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
<blockquote style="color: #ff8811">
|
|
27
|
+
<b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
|
|
28
|
+
</blockquote>
|
|
29
|
+
|
|
26
30
|
## 📦 Package `@promptbook/core`
|
|
27
31
|
|
|
28
32
|
- Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
|
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.92.0-3';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9904,6 +9904,81 @@ const BoilerplateFormfactorDefinition = {
|
|
|
9904
9904
|
},
|
|
9905
9905
|
};
|
|
9906
9906
|
|
|
9907
|
+
/**
|
|
9908
|
+
* Creates a wrapper around LlmExecutionTools that only exposes models matching the filter function
|
|
9909
|
+
*
|
|
9910
|
+
* @param llmTools The original LLM execution tools to wrap
|
|
9911
|
+
* @param modelFilter Function that determines whether a model should be included
|
|
9912
|
+
* @returns A new LlmExecutionTools instance with filtered models
|
|
9913
|
+
*
|
|
9914
|
+
* @public exported from `@promptbook/core`
|
|
9915
|
+
*/
|
|
9916
|
+
function filterModels(llmTools, modelFilter) {
|
|
9917
|
+
const filteredTools = {
|
|
9918
|
+
// Keep all properties from the original llmTools
|
|
9919
|
+
...llmTools,
|
|
9920
|
+
get description() {
|
|
9921
|
+
return `${llmTools.description} (filtered)`;
|
|
9922
|
+
},
|
|
9923
|
+
// Override listModels to filter the models
|
|
9924
|
+
async listModels() {
|
|
9925
|
+
const originalModels = await llmTools.listModels();
|
|
9926
|
+
// Handle both synchronous and Promise return types
|
|
9927
|
+
if (originalModels instanceof Promise) {
|
|
9928
|
+
return originalModels.then((models) => models.filter(modelFilter));
|
|
9929
|
+
}
|
|
9930
|
+
else {
|
|
9931
|
+
return originalModels.filter(modelFilter);
|
|
9932
|
+
}
|
|
9933
|
+
},
|
|
9934
|
+
};
|
|
9935
|
+
// Helper function to validate if a model is allowed
|
|
9936
|
+
async function isModelAllowed(modelName) {
|
|
9937
|
+
const models = await filteredTools.listModels();
|
|
9938
|
+
return models.some((model) => model.modelName === modelName);
|
|
9939
|
+
}
|
|
9940
|
+
// Override callChatModel if it exists in the original tools
|
|
9941
|
+
if (llmTools.callChatModel) {
|
|
9942
|
+
filteredTools.callChatModel = async (prompt) => {
|
|
9943
|
+
var _a;
|
|
9944
|
+
const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
|
|
9945
|
+
// If a specific model is requested, check if it's allowed
|
|
9946
|
+
if (modelName && !(await isModelAllowed(modelName))) {
|
|
9947
|
+
throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for chat calls`);
|
|
9948
|
+
}
|
|
9949
|
+
return llmTools.callChatModel(prompt);
|
|
9950
|
+
};
|
|
9951
|
+
}
|
|
9952
|
+
// Override callCompletionModel if it exists in the original tools
|
|
9953
|
+
if (llmTools.callCompletionModel) {
|
|
9954
|
+
filteredTools.callCompletionModel = async (prompt) => {
|
|
9955
|
+
var _a;
|
|
9956
|
+
const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
|
|
9957
|
+
// If a specific model is requested, check if it's allowed
|
|
9958
|
+
if (modelName && !(await isModelAllowed(modelName))) {
|
|
9959
|
+
throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for completion calls`);
|
|
9960
|
+
}
|
|
9961
|
+
return llmTools.callCompletionModel(prompt);
|
|
9962
|
+
};
|
|
9963
|
+
}
|
|
9964
|
+
// Override callEmbeddingModel if it exists in the original tools
|
|
9965
|
+
if (llmTools.callEmbeddingModel) {
|
|
9966
|
+
filteredTools.callEmbeddingModel = async (prompt) => {
|
|
9967
|
+
var _a;
|
|
9968
|
+
const modelName = (_a = prompt.modelRequirements) === null || _a === void 0 ? void 0 : _a.modelName;
|
|
9969
|
+
// If a specific model is requested, check if it's allowed
|
|
9970
|
+
if (modelName && !(await isModelAllowed(modelName))) {
|
|
9971
|
+
throw new PipelineExecutionError(`Model ${modelName} is not allowed by the filter for embedding calls`);
|
|
9972
|
+
}
|
|
9973
|
+
return llmTools.callEmbeddingModel(prompt);
|
|
9974
|
+
};
|
|
9975
|
+
}
|
|
9976
|
+
return filteredTools;
|
|
9977
|
+
}
|
|
9978
|
+
/**
|
|
9979
|
+
* TODO: !!! [models] Test that this is working
|
|
9980
|
+
*/
|
|
9981
|
+
|
|
9907
9982
|
/**
|
|
9908
9983
|
* @@@
|
|
9909
9984
|
*
|
|
@@ -11055,5 +11130,5 @@ class PrefixStorage {
|
|
|
11055
11130
|
}
|
|
11056
11131
|
}
|
|
11057
11132
|
|
|
11058
|
-
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
|
|
11133
|
+
export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, ADMIN_EMAIL, ADMIN_GITHUB_NAME, AbstractFormatError, AuthenticationError, BOOK_LANGUAGE_VERSION, BlackholeStorage, BoilerplateError, BoilerplateFormfactorDefinition, CLAIM, CLI_APP_ID, CallbackInterfaceTools, ChatbotFormfactorDefinition, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_BOOKS_DIRNAME, DEFAULT_BOOK_OUTPUT_PARAMETER_NAME, DEFAULT_BOOK_TITLE, DEFAULT_CSV_SETTINGS, DEFAULT_DOWNLOAD_CACHE_DIRNAME, DEFAULT_EXECUTION_CACHE_DIRNAME, DEFAULT_GET_PIPELINE_COLLECTION_FUNCTION_NAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_PROMPT_TASK_TITLE, DEFAULT_REMOTE_SERVER_URL, DEFAULT_SCRAPE_CACHE_DIRNAME, DEFAULT_TASK_TITLE, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, FORMFACTOR_DEFINITIONS, GENERIC_PIPELINE_INTERFACE, GeneratorFormfactorDefinition, GenericFormfactorDefinition, ImageGeneratorFormfactorDefinition, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MatcherFormfactorDefinition, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NAME, NonTaskSectionTypes, NotFoundError, NotYetImplementedError, ORDER_OF_PIPELINE_JSON, PLAYGROUND_APP_ID, PROMPTBOOK_ENGINE_VERSION, PROMPTBOOK_ERRORS, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, PromptbookFetchError, REMOTE_SERVER_URLS, RESERVED_PARAMETER_NAMES, SET_IS_VERBOSE, SectionTypes, SheetsFormfactorDefinition, TaskTypes, TextFormatDefinition, TranslatorFormfactorDefinition, UNCERTAIN_USAGE, UNCERTAIN_ZERO_VALUE, UnexpectedError, WrappedError, ZERO_USAGE, ZERO_VALUE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _BoilerplateScraperMetadataRegistration, _DeepseekMetadataRegistration, _DocumentScraperMetadataRegistration, _GoogleMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _MarkitdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, book, cacheLlmTools, collectionToJson, compilePipeline, countUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, extractParameterNamesFromTask, filterModels, getPipelineInterface, identificationToPromptbookToken, isPassingExpectations, isPipelineImplementingInterface, isPipelineInterfacesEqual, isPipelinePrepared, isValidPipelineString, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, parsePipeline, pipelineJsonToString, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTasks, prettifyPipelineString, promptbookFetch, promptbookTokenToIdentification, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline, validatePipelineString };
|
|
11059
11134
|
//# sourceMappingURL=index.es.js.map
|