@promptbook/openai 0.95.0 → 0.98.0-10

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 (25) hide show
  1. package/README.md +63 -2
  2. package/esm/index.es.js +602 -4
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/anthropic-claude.index.d.ts +2 -2
  5. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +2 -0
  7. package/esm/typings/src/_packages/openai.index.d.ts +10 -0
  8. package/esm/typings/src/_packages/types.index.d.ts +12 -2
  9. package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
  10. package/esm/typings/src/config.d.ts +1 -1
  11. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +8 -0
  12. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +53 -0
  13. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  14. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  15. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +2 -2
  16. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +4 -4
  17. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +52 -0
  18. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +3 -5
  19. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +74 -0
  20. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +11 -0
  21. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +14 -0
  22. package/esm/typings/src/version.d.ts +1 -1
  23. package/package.json +3 -2
  24. package/umd/index.umd.js +606 -7
  25. package/umd/index.umd.js.map +1 -1
package/README.md CHANGED
@@ -25,6 +25,10 @@ Write AI applications using plain human language across multiple models and plat
25
25
 
26
26
 
27
27
 
28
+ <blockquote style="color: #ff8811">
29
+ <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>.
30
+ </blockquote>
31
+
28
32
  ## 📦 Package `@promptbook/openai`
29
33
 
30
34
  - Promptbooks are [divided into several](#-packages) packages, all are published from [single monorepo](https://github.com/webgptorg/promptbook).
@@ -94,7 +98,7 @@ const { isSuccessful, errors, outputParameters, executionReport } = result;
94
98
  console.info(outputParameters);
95
99
  ```
96
100
 
97
- ## 🤺 Usage with OpenAI`s Assistants (GPTs)
101
+ ## 🤺 Usage with OpenAI's Assistants (GPTs)
98
102
 
99
103
  > TODO: Write a guide how to use OpenAI's Assistants with Promptbook
100
104
 
@@ -197,7 +201,7 @@ const llm = [
197
201
  // <- TODO: [🧱] Implement in a functional (not new Class) way
198
202
  {
199
203
  resourceName: process.env.AZUREOPENAI_RESOURCE_NAME,
200
- deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME,
204
+ deploymentName: process.env.AZUREOPENAI_DEPLOYMENT_NAME
201
205
  apiKey: process.env.AZUREOPENAI_API_KEY,
202
206
  },
203
207
  ),
@@ -245,6 +249,55 @@ See the other model integrations:
245
249
 
246
250
 
247
251
 
252
+ ## 🤖 Using Promptbook as an OpenAI-compatible model
253
+
254
+ You can use Promptbook books as if they were OpenAI models by using the OpenAI-compatible endpoint. This allows you to use the standard OpenAI SDK with Promptbook books.
255
+
256
+ First, start the Promptbook server:
257
+
258
+ ```typescript
259
+ import { startRemoteServer } from '@promptbook/remote-server';
260
+
261
+ // Start the server
262
+ await startRemoteServer({
263
+ port: 3000,
264
+ collection: await createCollectionFromDirectory('./books'),
265
+ isAnonymousModeAllowed: true,
266
+ isApplicationModeAllowed: true,
267
+ });
268
+ ```
269
+
270
+ Then use the standard OpenAI SDK with the server URL:
271
+
272
+ ```typescript
273
+ import OpenAI from 'openai';
274
+
275
+ // Create OpenAI client pointing to your Promptbook server
276
+ const openai = new OpenAI({
277
+ baseURL: 'http://localhost:3000', // Your Promptbook server URL
278
+ apiKey: 'not-needed', // API key is not needed for Promptbook
279
+ });
280
+
281
+ // Use any Promptbook book as a model
282
+ const response = await openai.chat.completions.create({
283
+ model: 'https://promptbook.studio/my-collection/write-article.book', // Book URL as model name
284
+ messages: [
285
+ {
286
+ role: 'user',
287
+ content: 'Write a short story about a cat',
288
+ },
289
+ ],
290
+ });
291
+
292
+ console.log(response.choices[0].message.content);
293
+ ```
294
+
295
+ This allows you to:
296
+
297
+ - Use Promptbook books with any OpenAI-compatible client
298
+ - Integrate Promptbook into existing OpenAI-based applications
299
+ - Use Promptbook books as models in other AI frameworks
300
+
248
301
 
249
302
  ---
250
303
 
@@ -259,6 +312,8 @@ Rest of the documentation is common for **entire promptbook ecosystem**:
259
312
 
260
313
  During the computer revolution, we have seen [multiple generations of computer languages](https://github.com/webgptorg/promptbook/discussions/180), from the physical rewiring of the vacuum tubes through low-level machine code to the high-level languages like Python or JavaScript. And now, we're on the edge of the **next revolution**!
261
314
 
315
+
316
+
262
317
  It's a revolution of writing software in **plain human language** that is understandable and executable by both humans and machines – and it's going to change everything!
263
318
 
264
319
  The incredible growth in power of microprocessors and the Moore's Law have been the driving force behind the ever-more powerful languages, and it's been an amazing journey! Similarly, the large language models (like GPT or Claude) are the next big thing in language technology, and they're set to transform the way we interact with computers.
@@ -384,6 +439,8 @@ Join our growing community of developers and users:
384
439
 
385
440
  _A concise, Markdown-based DSL for crafting AI workflows and automations._
386
441
 
442
+
443
+
387
444
  ### Introduction
388
445
 
389
446
  Book is a Markdown-based language that simplifies the creation of AI applications, workflows, and automations. With human-readable commands, you can define inputs, outputs, personas, knowledge sources, and actions—without needing model-specific details.
@@ -433,6 +490,8 @@ Personas can have access to different knowledge, tools and actions. They can als
433
490
 
434
491
  - [PERSONA](https://github.com/webgptorg/promptbook/blob/main/documents/commands/PERSONA.md)
435
492
 
493
+
494
+
436
495
  ### **3. How:** Knowledge, Instruments and Actions
437
496
 
438
497
  The resources used by the personas are used to do the work.
@@ -532,6 +591,8 @@ The following glossary is used to clarify certain concepts:
532
591
 
533
592
  _Note: This section is not a complete dictionary, more list of general AI / LLM terms that has connection with Promptbook_
534
593
 
594
+
595
+
535
596
  ### 💯 Core concepts
536
597
 
537
598
  - [📚 Collection of pipelines](https://github.com/webgptorg/promptbook/discussions/65)