@promptbook/cli 0.77.0-0 → 0.77.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 CHANGED
@@ -298,7 +298,7 @@ Or you can install them separately:
298
298
  - **[@promptbook/openai](https://www.npmjs.com/package/@promptbook/openai)** - Execution tools for OpenAI API, wrapper around OpenAI SDK
299
299
  - **[@promptbook/anthropic-claude](https://www.npmjs.com/package/@promptbook/anthropic-claude)** - Execution tools for Anthropic Claude API, wrapper around Anthropic Claude SDK
300
300
  - **[@promptbook/vercel](https://www.npmjs.com/package/@promptbook/vercel)** - Adapter for Vercel functionalities
301
- - **[@promptbook/gemini](https://www.npmjs.com/package/@promptbook/gemini)** - Integration with Google's Gemini API
301
+ - **[@promptbook/google](https://www.npmjs.com/package/@promptbook/google)** - Integration with Google's Gemini API
302
302
  - **[@promptbook/azure-openai](https://www.npmjs.com/package/@promptbook/azure-openai)** - Execution tools for Azure OpenAI API
303
303
  - **[@promptbook/langtail](https://www.npmjs.com/package/@promptbook/langtail)** - Execution tools for Langtail API, wrapper around Langtail SDK
304
304
  - **[@promptbook/fake-llm](https://www.npmjs.com/package/@promptbook/fake-llm)** - Mocked execution tools for testing the library and saving the tokens
package/esm/index.es.js CHANGED
@@ -37,7 +37,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
37
37
  *
38
38
  * @see https://github.com/webgptorg/promptbook
39
39
  */
40
- var PROMPTBOOK_ENGINE_VERSION = '0.76.0';
40
+ var PROMPTBOOK_ENGINE_VERSION = '0.77.0-2';
41
41
  /**
42
42
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
43
43
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -13466,6 +13466,222 @@ var _AzureOpenAiRegistration = $llmToolsRegister.register(createAzureOpenAiExecu
13466
13466
  * Note: [💞] Ignore a discrepancy between file name and entity name
13467
13467
  */
13468
13468
 
13469
+ /**
13470
+ * Registration of LLM provider metadata
13471
+ *
13472
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
13473
+ *
13474
+ * @public exported from `@promptbook/core`
13475
+ * @public exported from `@promptbook/cli`
13476
+ */
13477
+ var _GoogleMetadataRegistration = $llmToolsMetadataRegister.register({
13478
+ title: 'Google Gemini',
13479
+ packageName: '@promptbook/google',
13480
+ className: 'GoogleExecutionTools',
13481
+ getBoilerplateConfiguration: function () {
13482
+ return {
13483
+ title: 'Google Gemini (boilerplate)',
13484
+ packageName: '@promptbook/google',
13485
+ className: 'GoogleExecutionTools',
13486
+ options: {
13487
+ apiKey: 'sk-ant-api03-',
13488
+ isProxied: true,
13489
+ remoteUrl: DEFAULT_REMOTE_URL,
13490
+ path: DEFAULT_REMOTE_URL_PATH,
13491
+ },
13492
+ };
13493
+ },
13494
+ createConfigurationFromEnv: function (env) {
13495
+ // Note: Note using `process.env` BUT `env` to pass in the environment variables dynamically
13496
+ if (typeof env.GOOGLE_GEMINI_API_KEY === 'string') {
13497
+ return {
13498
+ title: 'Google Gemini (from env)',
13499
+ packageName: '@promptbook/google',
13500
+ className: 'GoogleExecutionTools',
13501
+ options: {
13502
+ apiKey: env.GOOGLE_GEMINI_API_KEY,
13503
+ },
13504
+ };
13505
+ }
13506
+ return null;
13507
+ },
13508
+ });
13509
+ /**
13510
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13511
+ */
13512
+
13513
+ /**
13514
+ * !!!!!!
13515
+ *
13516
+ * @public exported from `@promptbook/vercel`
13517
+ */
13518
+ function createExecutionToolsFromVercelProvider(options) {
13519
+ var vercelProvider = options.vercelProvider, availableModels = options.availableModels, userId = options.userId, _a = options.additionalChatSettings, additionalChatSettings = _a === void 0 ? {} : _a;
13520
+ return {
13521
+ title: '!!!',
13522
+ description: "!!! (through Vercel)",
13523
+ checkConfiguration: function () {
13524
+ // TODO: !!!!!!
13525
+ return Promise.resolve();
13526
+ },
13527
+ listModels: function () {
13528
+ return __awaiter(this, void 0, void 0, function () {
13529
+ return __generator(this, function (_a) {
13530
+ return [2 /*return*/, availableModels];
13531
+ });
13532
+ });
13533
+ },
13534
+ callChatModel: function (prompt) {
13535
+ var _a;
13536
+ return __awaiter(this, void 0, void 0, function () {
13537
+ var content, parameters, modelRequirements, modelName, model, rawPromptContent, rawRequest, start, rawResponse, complete, usage;
13538
+ return __generator(this, function (_b) {
13539
+ switch (_b.label) {
13540
+ case 0:
13541
+ content = prompt.content, parameters = prompt.parameters, modelRequirements = prompt.modelRequirements;
13542
+ if (modelRequirements.modelVariant !== 'CHAT') {
13543
+ throw new PipelineExecutionError('Use callChatModel only for CHAT variant');
13544
+ }
13545
+ modelName = modelRequirements.modelName ||
13546
+ ((_a = availableModels.find(function (_a) {
13547
+ var modelVariant = _a.modelVariant;
13548
+ return modelVariant === 'CHAT';
13549
+ })) === null || _a === void 0 ? void 0 : _a.modelName);
13550
+ if (!modelName) {
13551
+ throw new PipelineExecutionError(spaceTrim$1("\n Can not determine which model to use.\n\n You need to provide at least one of:\n 1) In `createExecutionToolsFromVercelProvider` options, provide `availableModels` with at least one model\n 2) In `prompt.modelRequirements`, provide `modelName` with the name of the model to use\n \n "));
13552
+ }
13553
+ return [4 /*yield*/, vercelProvider.chat(modelName, __assign({ user: (userId === null || userId === void 0 ? void 0 : userId.toString()) || undefined }, additionalChatSettings))];
13554
+ case 1:
13555
+ model = _b.sent();
13556
+ rawPromptContent = replaceParameters(content, __assign(__assign({}, parameters), { modelName: modelName }));
13557
+ rawRequest = {
13558
+ // <- TODO: [☂]
13559
+ inputFormat: 'messages',
13560
+ mode: {
13561
+ type: 'regular',
13562
+ tools: [
13563
+ /* !!!!!! */
13564
+ ],
13565
+ },
13566
+ prompt: __spreadArray(__spreadArray([], __read((modelRequirements.systemMessage === undefined
13567
+ ? []
13568
+ : [
13569
+ {
13570
+ role: 'system',
13571
+ content: modelRequirements.systemMessage,
13572
+ },
13573
+ ])), false), [
13574
+ {
13575
+ role: 'user',
13576
+ content: [
13577
+ {
13578
+ type: 'text',
13579
+ text: rawPromptContent,
13580
+ },
13581
+ ],
13582
+ },
13583
+ ], false),
13584
+ };
13585
+ start = $getCurrentDate();
13586
+ if (options.isVerbose) {
13587
+ console.info(colors.bgWhite('rawRequest'), JSON.stringify(rawRequest, null, 4));
13588
+ }
13589
+ return [4 /*yield*/, model.doGenerate(rawRequest)];
13590
+ case 2:
13591
+ rawResponse = _b.sent();
13592
+ /*
13593
+ TODO: !!!!!! Handle errors
13594
+ .catch((error) => {
13595
+ if (options.isVerbose) {
13596
+ console.info(colors.bgRed('error'), error);
13597
+ }
13598
+ throw error;
13599
+ });
13600
+ */
13601
+ if (options.isVerbose) {
13602
+ console.info(colors.bgWhite('rawResponse'), JSON.stringify(rawResponse, null, 4));
13603
+ }
13604
+ if (rawResponse.text === undefined) {
13605
+ throw new PipelineExecutionError('No response message');
13606
+ }
13607
+ complete = $getCurrentDate();
13608
+ usage = UNCERTAIN_USAGE;
13609
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('createExecutionToolsFromVercelProvider ChatPromptResult', {
13610
+ content: rawResponse.text,
13611
+ modelName: modelName,
13612
+ timing: {
13613
+ start: start,
13614
+ complete: complete,
13615
+ },
13616
+ usage: usage,
13617
+ rawPromptContent: rawPromptContent,
13618
+ rawRequest: rawRequest,
13619
+ rawResponse: {
13620
+ /* TODO: !!!!!! UnexpectedError: createExecutionToolsFromVercelProvider ChatPromptResult.rawResponse.response.timestamp is Date */
13621
+ },
13622
+ // <- [🗯]
13623
+ })];
13624
+ }
13625
+ });
13626
+ });
13627
+ },
13628
+ };
13629
+ }
13630
+
13631
+ /**
13632
+ * Execution Tools for calling Google Gemini API.
13633
+ *
13634
+ * @public exported from `@promptbook/google`
13635
+ */
13636
+ var createGoogleExecutionTools = Object.assign(function (options) {
13637
+ // Note: [🔘] There is a compatibility when using import from '@ai-sdk/google'
13638
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
13639
+ var createGoogleGenerativeAI = require('@ai-sdk/google').createGoogleGenerativeAI;
13640
+ var googleGeminiVercelProvider = createGoogleGenerativeAI(__assign({}, options));
13641
+ return createExecutionToolsFromVercelProvider(__assign({ vercelProvider: googleGeminiVercelProvider, availableModels: [
13642
+ // TODO: !!!!!! Maybe list models in same way as in other providers
13643
+ 'gemini-1.5-flash',
13644
+ 'gemini-1.5-flash-latest',
13645
+ 'gemini-1.5-flash-001',
13646
+ 'gemini-1.5-flash-002',
13647
+ 'gemini-1.5-flash-exp-0827',
13648
+ 'gemini-1.5-flash-8b',
13649
+ 'gemini-1.5-flash-8b-latest',
13650
+ 'gemini-1.5-flash-8b-exp-0924',
13651
+ 'gemini-1.5-flash-8b-exp-0827',
13652
+ 'gemini-1.5-pro-latest',
13653
+ 'gemini-1.5-pro',
13654
+ 'gemini-1.5-pro-001',
13655
+ 'gemini-1.5-pro-002',
13656
+ 'gemini-1.5-pro-exp-0827',
13657
+ 'gemini-1.0-pro',
13658
+ ].map(function (modelName) { return ({ modelName: modelName, modelVariant: 'CHAT' }); }) }, options));
13659
+ }, {
13660
+ packageName: '@promptbook/google',
13661
+ className: 'GoogleExecutionTools',
13662
+ });
13663
+ /**
13664
+ * TODO: [🧠][main] !!!! Make anonymous this with all LLM providers
13665
+ * TODO: [🧠][🧱][main] !!!! Maybe change all `new GoogleExecutionTools` -> `createGoogleExecutionTools` in manual
13666
+ * TODO: [🧠] Maybe auto-detect usage in browser and determine default value of `isProxied`
13667
+ * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
13668
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
13669
+ */
13670
+
13671
+ /**
13672
+ * Registration of LLM provider
13673
+ *
13674
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
13675
+ *
13676
+ * @public exported from `@promptbook/google`
13677
+ * @public exported from `@promptbook/cli`
13678
+ */
13679
+ var _GoogleRegistration = $llmToolsRegister.register(createGoogleExecutionTools);
13680
+ /**
13681
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
13682
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13683
+ */
13684
+
13469
13685
  /**
13470
13686
  * Registration of LLM provider metadata
13471
13687
  *
@@ -15369,5 +15585,5 @@ var _WebsiteScraperRegistration = $scrapersRegister.register(createWebsiteScrape
15369
15585
  * Note: [💞] Ignore a discrepancy between file name and entity name
15370
15586
  */
15371
15587
 
15372
- export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _CLI, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
15588
+ export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION, _AnthropicClaudeMetadataRegistration, _AnthropicClaudeRegistration, _AzureOpenAiMetadataRegistration, _AzureOpenAiRegistration, _CLI, _DocumentScraperMetadataRegistration, _DocumentScraperRegistration, _GoogleMetadataRegistration, _GoogleRegistration, _LegacyDocumentScraperMetadataRegistration, _LegacyDocumentScraperRegistration, _MarkdownScraperMetadataRegistration, _MarkdownScraperRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiAssistantRegistration, _OpenAiMetadataRegistration, _OpenAiRegistration, _PdfScraperMetadataRegistration, _PdfScraperRegistration, _WebsiteScraperMetadataRegistration, _WebsiteScraperRegistration };
15373
15589
  //# sourceMappingURL=index.es.js.map