@promptbook/openai 0.103.0-37 → 0.103.0-40

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.
Files changed (44) hide show
  1. package/README.md +7 -9
  2. package/esm/index.es.js +39 -11
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +0 -81
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -10
  6. package/esm/typings/src/_packages/node.index.d.ts +4 -2
  7. package/esm/typings/src/_packages/types.index.d.ts +3 -1
  8. package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +1 -1
  9. package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +14 -0
  10. package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-pipelines-server.d.ts} +2 -2
  11. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +36 -0
  12. package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +88 -0
  13. package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
  14. package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
  15. package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -10
  16. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
  17. package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
  18. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
  19. package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
  20. package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
  21. package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
  22. package/esm/typings/src/config.d.ts +8 -1
  23. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  24. package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -0
  25. package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
  26. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +9 -4
  27. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +0 -4
  28. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +17 -1
  29. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  30. package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -1
  31. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +22 -8
  32. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
  33. package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
  34. package/esm/typings/src/version.d.ts +1 -1
  35. package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
  36. package/package.json +4 -3
  37. package/umd/index.umd.js +42 -15
  38. package/umd/index.umd.js.map +1 -1
  39. package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
  40. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
  41. /package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.test.d.ts → agent-collection/constructors/AgentCollectionInDirectory.test.d.ts} +0 -0
  42. /package/esm/typings/src/collection/{constructors/createCollectionFromJson.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
  43. /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
  44. /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
package/README.md CHANGED
@@ -82,7 +82,7 @@ The package offers three main integration paths:
82
82
  ```typescript
83
83
  import { createPipelineExecutor } from '@promptbook/core';
84
84
  import {
85
- createCollectionFromDirectory,
85
+ createPipelineCollectionFromDirectory,
86
86
  $provideExecutionToolsForNode,
87
87
  $provideFilesystemForNode,
88
88
  $provideScrapersForNode,
@@ -110,7 +110,7 @@ const tools = {
110
110
  };
111
111
 
112
112
  // ▶ Create whole pipeline collection
113
- const collection = await createCollectionFromDirectory('./books', tools);
113
+ const collection = await createPipelineCollectionFromDirectory('./books', tools);
114
114
 
115
115
  // ▶ Get single Pipeline
116
116
  const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book`);
@@ -164,7 +164,7 @@ console.info(joke);
164
164
  You can just use `$provideExecutionToolsForNode` function to create all required tools from environment variables like `ANTHROPIC_CLAUDE_API_KEY` and `OPENAI_API_KEY` automatically.
165
165
 
166
166
  ```typescript
167
- import { createPipelineExecutor, createCollectionFromDirectory } from '@promptbook/core';
167
+ import { createPipelineExecutor, createPipelineCollectionFromDirectory } from '@promptbook/core';
168
168
  import { JavascriptExecutionTools } from '@promptbook/javascript';
169
169
  import { $provideExecutionToolsForNode } from '@promptbook/node';
170
170
  import { $provideFilesystemForNode } from '@promptbook/node';
@@ -174,7 +174,7 @@ import { $provideFilesystemForNode } from '@promptbook/node';
174
174
  const tools = await $provideExecutionToolsForNode();
175
175
 
176
176
  // ▶ Create whole pipeline collection
177
- const collection = await createCollectionFromDirectory('./books', tools);
177
+ const collection = await createPipelineCollectionFromDirectory('./books', tools);
178
178
 
179
179
  // ▶ Get single Pipeline
180
180
  const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book`);
@@ -202,7 +202,7 @@ You can use multiple LLM providers in one Promptbook execution. The best model w
202
202
  ```typescript
203
203
  import { createPipelineExecutor } from '@promptbook/core';
204
204
  import {
205
- createCollectionFromDirectory,
205
+ createPipelineCollectionFromDirectory,
206
206
  $provideExecutionToolsForNode,
207
207
  $provideFilesystemForNode,
208
208
  } from '@promptbook/node';
@@ -246,7 +246,7 @@ const tools = {
246
246
  };
247
247
 
248
248
  // ▶ Create whole pipeline collection
249
- const collection = await createCollectionFromDirectory('./books', tools);
249
+ const collection = await createPipelineCollectionFromDirectory('./books', tools);
250
250
 
251
251
  // ▶ Get single Pipeline
252
252
  const pipeline = await collection.getPipelineByUrl(`https://promptbook.studio/my-collection/write-article.book`);
@@ -292,7 +292,7 @@ import { startRemoteServer } from '@promptbook/remote-server';
292
292
  // Start the server
293
293
  await startRemoteServer({
294
294
  port: 3000,
295
- collection: await createCollectionFromDirectory('./books'),
295
+ collection: await createPipelineCollectionFromDirectory('./books'),
296
296
  isAnonymousModeAllowed: true,
297
297
  isApplicationModeAllowed: true,
298
298
  });
@@ -329,8 +329,6 @@ This allows you to:
329
329
  - Integrate Promptbook into existing OpenAI-based applications
330
330
  - Use Promptbook books as models in other AI frameworks
331
331
 
332
-
333
-
334
332
  ## 📦 Exported Entities
335
333
 
336
334
  ### Version Information
package/esm/index.es.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import colors from 'colors';
2
+ import { forEver } from 'waitasecond';
2
3
  import spaceTrim$1, { spaceTrim } from 'spacetrim';
3
4
  import { randomBytes } from 'crypto';
4
5
  import Bottleneck from 'bottleneck';
@@ -19,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '1.0.0';
19
20
  * @generated
20
21
  * @see https://github.com/webgptorg/promptbook
21
22
  */
22
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-37';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-40';
23
24
  /**
24
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
25
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -3626,6 +3627,12 @@ class OpenAiExecutionTools extends OpenAiCompatibleExecutionTools {
3626
3627
  *
3627
3628
  * This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
3628
3629
  *
3630
+ * Note: [🦖] There are several different things in Promptbook:
3631
+ * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
3632
+ * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
3633
+ * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
3634
+ * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
3635
+ *
3629
3636
  * @public exported from `@promptbook/openai`
3630
3637
  */
3631
3638
  class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
@@ -3791,10 +3798,32 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
3791
3798
  },
3792
3799
  });
3793
3800
  }
3794
- async createNewAssistant() {
3801
+ async playground() {
3802
+ const client = await this.getClient();
3803
+ // List all assistants
3804
+ const assistants = await client.beta.assistants.list();
3805
+ console.log('!!! Assistants:', assistants);
3806
+ // Get details of a specific assistant
3807
+ const assistantId = 'asst_MO8fhZf4dGloCfXSHeLcIik0';
3808
+ const assistant = await client.beta.assistants.retrieve(assistantId);
3809
+ console.log('!!! Assistant Details:', assistant);
3810
+ // Update an assistant
3811
+ const updatedAssistant = await client.beta.assistants.update(assistantId, {
3812
+ name: assistant.name + '(M)',
3813
+ description: 'Updated description via Promptbook',
3814
+ metadata: {
3815
+ [Math.random().toString(36).substring(2, 15)]: new Date().toISOString(),
3816
+ },
3817
+ });
3818
+ console.log('!!! Updated Assistant:', updatedAssistant);
3819
+ await forEver();
3820
+ }
3821
+ async createNewAssistant(options) {
3795
3822
  if (!this.isCreatingNewAssistantsAllowed) {
3796
3823
  throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
3797
3824
  }
3825
+ await this.playground();
3826
+ const { name, instructions } = options;
3798
3827
  const client = await this.getClient();
3799
3828
  /*
3800
3829
  TODO: !!!
@@ -3842,21 +3871,20 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
3842
3871
  uploadedFiles.push(file.id);
3843
3872
  }
3844
3873
  */
3874
+ alert('!!!! Creating new OpenAI assistant');
3845
3875
  // 3️⃣ Create assistant with uploaded files
3846
3876
  const assistant = await client.beta.assistants.create({
3847
- name: 'Next.js documentation assistant',
3848
- description: 'Assistant that can answer questions about Next.js and working with APIs.',
3877
+ name,
3878
+ description: 'Assistant created via Promptbook',
3849
3879
  model: 'gpt-4o',
3850
- instructions: spaceTrim$1(`
3851
- Answer clearly and comprehensively.
3852
- Quote parts from uploaded files if needed.
3853
- `),
3854
- // <- TODO: !!!! Generate the `instructions` from passed `agentSource` (generate outside of this class)
3855
- tools: [{ type: 'code_interpreter' }, { type: 'file_search' }],
3880
+ instructions,
3881
+ tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
3856
3882
  // !!!! file_ids: uploadedFiles,
3857
3883
  });
3858
- // TODO: !!!! Change Czech to English
3859
3884
  console.log(`✅ Assistant created: ${assistant.id}`);
3885
+ // TODO: !!!! Try listing existing assistants
3886
+ // TODO: !!!! Try marking existing assistants by DISCRIMINANT
3887
+ // TODO: !!!! Allow to update and reconnect to existing assistants
3860
3888
  return new OpenAiAssistantExecutionTools({
3861
3889
  ...this.options,
3862
3890
  isCreatingNewAssistantsAllowed: false,