@promptbook/openai 0.94.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 (75) hide show
  1. package/README.md +59 -6
  2. package/esm/index.es.js +607 -9
  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 +14 -4
  9. package/esm/typings/src/_packages/{wizzard.index.d.ts → wizard.index.d.ts} +6 -2
  10. package/esm/typings/src/cli/cli-commands/prettify.d.ts +1 -1
  11. package/esm/typings/src/cli/cli-commands/test-command.d.ts +1 -1
  12. package/esm/typings/src/config.d.ts +1 -1
  13. package/esm/typings/src/conversion/archive/loadArchive.d.ts +1 -1
  14. package/esm/typings/src/conversion/archive/saveArchive.d.ts +2 -2
  15. package/esm/typings/src/conversion/prettify/renderPipelineMermaidOptions.d.ts +1 -1
  16. package/esm/typings/src/dialogs/callback/CallbackInterfaceTools.d.ts +1 -1
  17. package/esm/typings/src/execution/AbstractTaskResult.d.ts +2 -2
  18. package/esm/typings/src/execution/createPipelineExecutor/$OngoingTaskResult.d.ts +8 -0
  19. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +1 -1
  20. package/esm/typings/src/execution/execution-report/ExecutionPromptReportJson.d.ts +2 -2
  21. package/esm/typings/src/execution/translation/automatic-translate/translateMessages.d.ts +1 -1
  22. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +53 -0
  23. package/esm/typings/src/llm-providers/_common/register/{$provideLlmToolsForWizzardOrCli.d.ts → $provideLlmToolsForWizardOrCli.d.ts} +2 -2
  24. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  25. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  26. package/esm/typings/src/llm-providers/anthropic-claude/register-configuration.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/anthropic-claude/register-constructor.d.ts +1 -1
  28. package/esm/typings/src/llm-providers/azure-openai/register-configuration.d.ts +1 -1
  29. package/esm/typings/src/llm-providers/azure-openai/register-constructor.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/deepseek/register-configuration.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/deepseek/register-constructor.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/google/register-configuration.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/google/register-constructor.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/ollama/register-configuration.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/ollama/register-constructor.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +2 -2
  38. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +4 -4
  39. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionToolsOptions.d.ts +52 -0
  40. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +3 -5
  41. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +74 -0
  42. package/esm/typings/src/llm-providers/openai/register-configuration.d.ts +13 -2
  43. package/esm/typings/src/llm-providers/openai/register-constructor.d.ts +16 -2
  44. package/esm/typings/src/remote-server/socket-types/listModels/PromptbookServer_ListModels_Request.d.ts +1 -1
  45. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -1
  46. package/esm/typings/src/scrapers/_boilerplate/register-constructor.d.ts +1 -1
  47. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +2 -2
  48. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  49. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +1 -1
  50. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  51. package/esm/typings/src/scrapers/document/register-constructor.d.ts +1 -1
  52. package/esm/typings/src/scrapers/document/register-metadata.d.ts +2 -2
  53. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  54. package/esm/typings/src/scrapers/document-legacy/register-constructor.d.ts +1 -1
  55. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +2 -2
  56. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -4
  57. package/esm/typings/src/scrapers/markdown/register-constructor.d.ts +1 -1
  58. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +2 -2
  59. package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -1
  60. package/esm/typings/src/scrapers/markitdown/register-constructor.d.ts +1 -1
  61. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +2 -2
  62. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  63. package/esm/typings/src/scrapers/pdf/register-constructor.d.ts +1 -1
  64. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +2 -2
  65. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  66. package/esm/typings/src/scrapers/website/register-constructor.d.ts +1 -1
  67. package/esm/typings/src/scrapers/website/register-metadata.d.ts +2 -2
  68. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  69. package/esm/typings/src/utils/files/listAllFiles.d.ts +1 -1
  70. package/esm/typings/src/version.d.ts +1 -1
  71. package/esm/typings/src/{wizzard → wizard}/$getCompiledBook.d.ts +2 -2
  72. package/esm/typings/src/{wizzard/wizzard.d.ts → wizard/wizard.d.ts} +6 -6
  73. package/package.json +3 -14
  74. package/umd/index.umd.js +611 -12
  75. package/umd/index.umd.js.map +1 -1
@@ -35,7 +35,7 @@ export type CreatePipelineExecutorOptions = PrepareAndScrapeOptions & {
35
35
  *
36
36
  * @default false
37
37
  */
38
- readonly isNotPreparedWarningSupressed?: boolean;
38
+ readonly isNotPreparedWarningSuppressed?: boolean;
39
39
  };
40
40
  /**
41
41
  * TODO: [🧎][🧠] Move `csvSettings` to some better place
@@ -8,7 +8,7 @@ import type { PromptResult } from '../PromptResult';
8
8
  */
9
9
  export type ExecutionPromptReportJson = {
10
10
  /**
11
- * The prompt wich was executed
11
+ * The prompt which was executed
12
12
  */
13
13
  readonly prompt: Omit<Prompt, 'pipelineUrl'>;
14
14
  /**
@@ -16,7 +16,7 @@ export type ExecutionPromptReportJson = {
16
16
  */
17
17
  readonly result?: PromptResult;
18
18
  /**
19
- * The error which occured during LLM execution or during postprocessing or expectation checking
19
+ * The error which occurred during LLM execution or during postprocessing or expectation checking
20
20
  *
21
21
  * Note: It makes sense to have both error and result defined, for example when the result not pass expectations
22
22
  */
@@ -7,6 +7,6 @@ export declare function translateMessages({ automaticTranslator, from, to, }: {
7
7
  automaticTranslator: AutomaticTranslator;
8
8
  } & TranslatorOptions): Promise<void>;
9
9
  /**
10
- * TODO: [😶] Unite floder listing
10
+ * TODO: [😶] Unite folder listing
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
12
  */
@@ -0,0 +1,53 @@
1
+ import type { FormatCommand } from '../../commands/FORMAT/FormatCommand';
2
+ import { ExpectError } from '../../errors/ExpectError';
3
+ import type { Expectations } from '../../pipeline/PipelineJson/Expectations';
4
+ import type { string_postprocessing_function_name } from '../../types/typeAliases';
5
+ /**
6
+ * Options for validating a prompt result
7
+ */
8
+ export interface ValidatePromptResultOptions {
9
+ /**
10
+ * The result string to validate
11
+ */
12
+ resultString: string;
13
+ /**
14
+ * Expectations for the result (word count, sentence count, etc.)
15
+ */
16
+ expectations?: Expectations;
17
+ /**
18
+ * Expected format of the result (e.g., 'JSON')
19
+ */
20
+ format?: FormatCommand['format'];
21
+ /**
22
+ * List of postprocessing function names that should be applied
23
+ * Note: This is for validation purposes only - postprocessing should be done before calling this function
24
+ */
25
+ postprocessingFunctionNames?: ReadonlyArray<string_postprocessing_function_name>;
26
+ }
27
+ /**
28
+ * Result of prompt result validation
29
+ */
30
+ export interface ValidatePromptResultResult {
31
+ /**
32
+ * Whether the result is valid (passes all expectations and format checks)
33
+ */
34
+ isValid: boolean;
35
+ /**
36
+ * The processed result string (may be modified if format extraction was needed)
37
+ */
38
+ processedResultString: string;
39
+ /**
40
+ * Error that occurred during validation, if any
41
+ */
42
+ error?: ExpectError;
43
+ }
44
+ /**
45
+ * Validates a prompt result against expectations and format requirements.
46
+ * This function provides a common abstraction for result validation that can be used
47
+ * by both execution logic and caching logic to ensure consistency.
48
+ *
49
+ * @param options - The validation options including result string, expectations, and format
50
+ * @returns Validation result with processed string and validity status
51
+ * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
52
+ */
53
+ export declare function validatePromptResult(options: ValidatePromptResultOptions): ValidatePromptResultResult;
@@ -5,7 +5,7 @@ import type { string_url } from '../../../types/typeAliases';
5
5
  import type { really_any } from '../../../utils/organization/really_any';
6
6
  import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
7
7
  import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
8
- type ProvideLlmToolsForWizzardOrCliOptions = {
8
+ type ProvideLlmToolsForWizardOrCliOptions = {
9
9
  /**
10
10
  * If true, user will be always prompted for login
11
11
  *
@@ -48,7 +48,7 @@ type ProvideLlmToolsForWizzardOrCliOptions = {
48
48
  *
49
49
  * @private within the repository - for CLI utils
50
50
  */
51
- export declare function $provideLlmToolsForWizzardOrCli(options?: ProvideLlmToolsForWizzardOrCliOptions): Promise<LlmExecutionToolsWithTotalUsage>;
51
+ export declare function $provideLlmToolsForWizardOrCli(options?: ProvideLlmToolsForWizardOrCliOptions): Promise<LlmExecutionToolsWithTotalUsage>;
52
52
  export {};
53
53
  /**
54
54
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
@@ -7,7 +7,7 @@ import type { Prompt } from '../../types/Prompt';
7
7
  import type { string_markdown } from '../../types/typeAliases';
8
8
  import type { string_markdown_text } from '../../types/typeAliases';
9
9
  import type { string_title } from '../../types/typeAliases';
10
- import type { AnthropicClaudeExecutionToolsDirectOptions } from './AnthropicClaudeExecutionToolsOptions';
10
+ import type { AnthropicClaudeExecutionToolsNonProxiedOptions } from './AnthropicClaudeExecutionToolsOptions';
11
11
  /**
12
12
  * Execution Tools for calling Anthropic Claude API.
13
13
  *
@@ -15,7 +15,7 @@ import type { AnthropicClaudeExecutionToolsDirectOptions } from './AnthropicClau
15
15
  * @deprecated use `createAnthropicClaudeExecutionTools` instead
16
16
  */
17
17
  export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools {
18
- protected readonly options: AnthropicClaudeExecutionToolsDirectOptions;
18
+ protected readonly options: AnthropicClaudeExecutionToolsNonProxiedOptions;
19
19
  /**
20
20
  * Anthropic Claude API client.
21
21
  */
@@ -26,7 +26,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
26
26
  *
27
27
  * @param options which are relevant are directly passed to the Anthropic Claude client
28
28
  */
29
- constructor(options?: AnthropicClaudeExecutionToolsDirectOptions);
29
+ constructor(options?: AnthropicClaudeExecutionToolsNonProxiedOptions);
30
30
  get title(): string_title & string_markdown_text;
31
31
  get description(): string_markdown;
32
32
  getClient(): Promise<Anthropic>;
@@ -7,14 +7,14 @@ import type { RemoteClientOptions } from '../../remote-server/types/RemoteClient
7
7
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
8
8
  * @public exported from `@promptbook/anthropic-claude`
9
9
  */
10
- export type AnthropicClaudeExecutionToolsOptions = AnthropicClaudeExecutionToolsDirectOptions | AnthropicClaudeExecutionToolsProxiedOptions;
10
+ export type AnthropicClaudeExecutionToolsOptions = AnthropicClaudeExecutionToolsNonProxiedOptions | AnthropicClaudeExecutionToolsProxiedOptions;
11
11
  /**
12
12
  * Options for directly used `AnthropicClaudeExecutionTools`
13
13
  *
14
14
  * This extends Anthropic's `ClientOptions` with are directly passed to the Anthropic client.
15
15
  * @public exported from `@promptbook/anthropic-claude`
16
16
  */
17
- export type AnthropicClaudeExecutionToolsDirectOptions = CommonToolsOptions & ClientOptions & {
17
+ export type AnthropicClaudeExecutionToolsNonProxiedOptions = CommonToolsOptions & ClientOptions & {
18
18
  isProxied?: false;
19
19
  };
20
20
  /**
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _AnthropicClaudeMetadataRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/anthropic-claude`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  *
11
11
  */
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _AzureOpenAiMetadataRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/azure-openai`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _AzureOpenAiRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _DeepseekMetadataRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/deepseek`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _DeepseekRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _GoogleMetadataRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/google`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _GoogleRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _OllamaMetadataRegistration: Registration;
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/ollama`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _OllamaRegistration: Registration;
@@ -29,7 +29,7 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
29
29
  callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
30
30
  }
31
31
  /**
32
- * TODO: [🧠][🧙‍♂️] Maybe there can be some wizzard for thoose who want to use just OpenAI
32
+ * TODO: [🧠][🧙‍♂️] Maybe there can be some wizard for those who want to use just OpenAI
33
33
  * TODO: Maybe make custom OpenAiError
34
34
  * TODO: [🧠][🈁] Maybe use `isDeterministic` from options
35
35
  * TODO: [🧠][🌰] Allow to pass `title` for tracking purposes
@@ -1,12 +1,12 @@
1
1
  import type { ClientOptions } from 'openai';
2
2
  import type { string_token } from '../../types/typeAliases';
3
- import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
3
+ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
4
4
  /**
5
5
  * Options for `createOpenAiAssistantExecutionTools` and `OpenAiAssistantExecutionTools`
6
6
  *
7
7
  * @public exported from `@promptbook/openai`
8
8
  */
9
- export type OpenAiAssistantExecutionToolsOptions = OpenAiExecutionToolsOptions & ClientOptions & {
9
+ export type OpenAiAssistantExecutionToolsOptions = OpenAiCompatibleExecutionToolsOptions & ClientOptions & {
10
10
  /**
11
11
  * Which assistant to use
12
12
  */
@@ -11,14 +11,14 @@ import type { string_markdown_text } from '../../types/typeAliases';
11
11
  import type { string_model_name } from '../../types/typeAliases';
12
12
  import type { string_title } from '../../types/typeAliases';
13
13
  import { computeOpenAiUsage } from './computeOpenAiUsage';
14
- import type { OpenAiExecutionToolsOptions } from './OpenAiExecutionToolsOptions';
14
+ import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
15
15
  /**
16
- * Execution Tools for calling OpenAI API or other OpeenAI compatible provider
16
+ * Execution Tools for calling OpenAI API or other OpenAI compatible provider
17
17
  *
18
18
  * @public exported from `@promptbook/openai`
19
19
  */
20
20
  export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecutionTools {
21
- protected readonly options: OpenAiExecutionToolsOptions;
21
+ protected readonly options: OpenAiCompatibleExecutionToolsNonProxiedOptions;
22
22
  /**
23
23
  * OpenAI API client.
24
24
  */
@@ -32,7 +32,7 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
32
32
  *
33
33
  * @param options which are relevant are directly passed to the OpenAI compatible client
34
34
  */
35
- constructor(options: OpenAiExecutionToolsOptions);
35
+ constructor(options: OpenAiCompatibleExecutionToolsNonProxiedOptions);
36
36
  abstract get title(): string_title & string_markdown_text;
37
37
  abstract get description(): string_markdown;
38
38
  getClient(): Promise<OpenAI>;
@@ -0,0 +1,52 @@
1
+ import type { ClientOptions } from 'openai';
2
+ import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
+ import type { RemoteClientOptions } from '../../remote-server/types/RemoteClientOptions';
4
+ /**
5
+ * Options for `createOpenAiCompatibleExecutionTools` and `OpenAiCompatibleExecutionTools`
6
+ *
7
+ * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
8
+ * Rest is used by the `OpenAiCompatibleExecutionTools`.
9
+ *
10
+ * @public exported from `@promptbook/openai`
11
+ */
12
+ export type OpenAiCompatibleExecutionToolsOptions = OpenAiCompatibleExecutionToolsNonProxiedOptions | OpenAiCompatibleExecutionToolsProxiedOptions;
13
+ /**
14
+ * Options for directly used `OpenAiCompatibleExecutionTools`
15
+ *
16
+ * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
17
+ * @public exported from `@promptbook/openai`
18
+ */
19
+ export type OpenAiCompatibleExecutionToolsNonProxiedOptions = CommonToolsOptions & ClientOptions & {
20
+ /**
21
+ * Base URL for the OpenAI-compatible API endpoint
22
+ *
23
+ * This allows connecting to any OpenAI-compatible LLM service by specifying their API endpoint.
24
+ *
25
+ * @example 'https://https://promptbook.s5.ptbk.io/' (Promptbook)
26
+ * @example 'https://api.openai.com/v1' (OpenAI)
27
+ * @example 'http://localhost:11434/v1' (Ollama)
28
+ * @example 'https://api.deepseek.com/v1' (DeepSeek)
29
+ */
30
+ baseURL?: string;
31
+ isProxied?: false;
32
+ };
33
+ /**
34
+ * Options for proxied `OpenAiCompatibleExecutionTools`
35
+ *
36
+ * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
37
+ * @public exported from `@promptbook/openai`
38
+ */
39
+ export type OpenAiCompatibleExecutionToolsProxiedOptions = CommonToolsOptions & ClientOptions & {
40
+ /**
41
+ * Base URL for the OpenAI-compatible API endpoint
42
+ *
43
+ * This allows connecting to any OpenAI-compatible LLM service by specifying their API endpoint.
44
+ *
45
+ * @example 'https://https://promptbook.s5.ptbk.io/' (Promptbook)
46
+ * @example 'https://api.openai.com/v1' (OpenAI)
47
+ * @example 'http://localhost:11434/v1' (Ollama)
48
+ * @example 'https://api.deepseek.com/v1' (DeepSeek)
49
+ */
50
+ baseURL?: string;
51
+ isProxied: true;
52
+ } & Pick<RemoteClientOptions<undefined>, 'remoteServerUrl'>;
@@ -1,11 +1,9 @@
1
- import type { ClientOptions } from 'openai';
2
- import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
1
+ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
3
2
  /**
4
3
  * Options for `createOpenAiExecutionTools` and `OpenAiExecutionTools`
5
4
  *
6
- * This extends OpenAI's `ClientOptions` with are directly passed to the OpenAI client.
7
- * Rest is used by the `OpenAiExecutionTools`.
5
+ * This extends OpenAiCompatibleExecutionToolsOptions.
8
6
  *
9
7
  * @public exported from `@promptbook/openai`
10
8
  */
11
- export type OpenAiExecutionToolsOptions = CommonToolsOptions & ClientOptions;
9
+ export type OpenAiExecutionToolsOptions = OpenAiCompatibleExecutionToolsOptions;
@@ -0,0 +1,74 @@
1
+ import type { AvailableModel } from '../../execution/AvailableModel';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { Usage } from '../../execution/Usage';
4
+ import type { string_markdown } from '../../types/typeAliases';
5
+ import type { string_markdown_text } from '../../types/typeAliases';
6
+ import type { string_model_name } from '../../types/typeAliases';
7
+ import type { string_title } from '../../types/typeAliases';
8
+ import { RemoteLlmExecutionTools } from '../remote/RemoteLlmExecutionTools';
9
+ import { computeOpenAiUsage } from './computeOpenAiUsage';
10
+ import { OpenAiCompatibleExecutionTools } from './OpenAiCompatibleExecutionTools';
11
+ import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
12
+ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleExecutionToolsOptions';
13
+ /**
14
+ * Execution Tools for calling OpenAI compatible API
15
+ *
16
+ * Note: This can be used for any OpenAI compatible APIs
17
+ *
18
+ * @public exported from `@promptbook/openai`
19
+ */
20
+ export declare const createOpenAiCompatibleExecutionTools: ((options: OpenAiCompatibleExecutionToolsOptions & {
21
+ /**
22
+ * The model name to use for all operations
23
+ *
24
+ * This will be the only model available through this LLM provider and it will be a chat model.
25
+ * Other variants won't be available for now.
26
+ */
27
+ defaultModelName: string_model_name;
28
+ }) => OpenAiCompatibleExecutionTools | RemoteLlmExecutionTools) & {
29
+ packageName: string;
30
+ className: string;
31
+ };
32
+ /**
33
+ * Execution Tools for calling ONE SPECIFIC PRECONFIGURED OpenAI compatible provider
34
+ *
35
+ * @private for `createOpenAiCompatibleExecutionTools`
36
+ */
37
+ export declare class HardcodedOpenAiCompatibleExecutionTools extends OpenAiCompatibleExecutionTools implements LlmExecutionTools {
38
+ private readonly defaultModelName;
39
+ protected readonly options: OpenAiCompatibleExecutionToolsNonProxiedOptions;
40
+ /**
41
+ * Creates OpenAI compatible Execution Tools.
42
+ *
43
+ * @param options which are relevant are directly passed to the OpenAI compatible client
44
+ */
45
+ constructor(defaultModelName: string_model_name, options: OpenAiCompatibleExecutionToolsNonProxiedOptions);
46
+ get title(): string_title & string_markdown_text;
47
+ get description(): string_markdown;
48
+ /**
49
+ * List all available models (non dynamically)
50
+ *
51
+ * Note: Purpose of this is to provide more information about models than standard listing from API
52
+ */
53
+ protected get HARDCODED_MODELS(): ReadonlyArray<AvailableModel>;
54
+ /**
55
+ * Computes the usage
56
+ */
57
+ protected computeUsage(...args: Parameters<typeof computeOpenAiUsage>): Usage;
58
+ /**
59
+ * Default model for chat variant.
60
+ */
61
+ protected getDefaultChatModel(): AvailableModel;
62
+ /**
63
+ * Default model for completion variant.
64
+ */
65
+ protected getDefaultCompletionModel(): AvailableModel;
66
+ /**
67
+ * Default model for completion variant.
68
+ */
69
+ protected getDefaultEmbeddingModel(): AvailableModel;
70
+ }
71
+ /**
72
+ * TODO: [🦺] Is there some way how to put `packageName` and `className` on top and function definition on bottom?
73
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
74
+ */
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/core`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _OpenAiMetadataRegistration: Registration;
@@ -15,10 +15,21 @@ export declare const _OpenAiMetadataRegistration: Registration;
15
15
  * Note: [🏐] Configurations registrations are done in the metadata registration section, but the constructor registration is handled separately.
16
16
  *
17
17
  * @public exported from `@promptbook/core`
18
- * @public exported from `@promptbook/wizzard`
18
+ * @public exported from `@promptbook/wizard`
19
19
  * @public exported from `@promptbook/cli`
20
20
  */
21
21
  export declare const _OpenAiAssistantMetadataRegistration: Registration;
22
+ /**
23
+ * Registration of the OpenAI Compatible metadata
24
+ *
25
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be instantiated directly.
26
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
27
+ *
28
+ * @public exported from `@promptbook/core`
29
+ * @public exported from `@promptbook/wizard`
30
+ * @public exported from `@promptbook/cli`
31
+ */
32
+ export declare const _OpenAiCompatibleMetadataRegistration: Registration;
22
33
  /**
23
34
  * Note: [💞] Ignore a discrepancy between file name and entity name
24
35
  */
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
6
  *
7
7
  * @public exported from `@promptbook/openai`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _OpenAiRegistration: Registration;
@@ -15,10 +15,24 @@ export declare const _OpenAiRegistration: Registration;
15
15
  * Note: [🏐] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
16
16
  *
17
17
  * @public exported from `@promptbook/openai`
18
- * @public exported from `@promptbook/wizzard`
18
+ * @public exported from `@promptbook/wizard`
19
19
  * @public exported from `@promptbook/cli`
20
20
  */
21
21
  export declare const _OpenAiAssistantRegistration: Registration;
22
+ /**
23
+ * Registration of the OpenAI Compatible provider
24
+ *
25
+ * Note: [🏐] Configurations registrations are done in register-constructor.ts BUT constructor register-constructor.ts
26
+ *
27
+ * @public exported from `@promptbook/openai`
28
+ * @public exported from `@promptbook/wizard`
29
+ * @public exported from `@promptbook/cli`
30
+ */
31
+ export declare const _OpenAiCompatibleRegistration: Registration;
32
+ /**
33
+ * Note: OpenAiCompatibleExecutionTools is an abstract class and cannot be registered directly.
34
+ * It serves as a base class for OpenAiExecutionTools and other compatible implementations.
35
+ */
22
36
  /**
23
37
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
24
38
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -13,5 +13,5 @@ export type PromptbookServer_ListModels_Request<TCustomOptions> = {
13
13
  readonly identification: Identification<TCustomOptions>;
14
14
  };
15
15
  /**
16
- * TODO: [🧠] Listing models inanonymous mode does not make sence - keeping only to preserve consistency
16
+ * TODO: [🧠] Listing models inanonymous mode does not make sense - keeping only to preserve consistency
17
17
  */
@@ -12,7 +12,7 @@ export declare const createBoilerplateScraper: ((tools: Pick<ExecutionTools, 'll
12
12
  className: string;
13
13
  mimeTypes: string[];
14
14
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
15
- isAvilableInBrowser: false;
15
+ isAvailableInBrowser: false;
16
16
  requiredExecutables: never[];
17
17
  }>;
18
18
  /**
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/boilerplate`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _BoilerplateScraperRegistration: Registration;
@@ -10,7 +10,7 @@ export declare const boilerplateScraperMetadata: import("type-fest/source/readon
10
10
  className: string;
11
11
  mimeTypes: string[];
12
12
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
13
- isAvilableInBrowser: false;
13
+ isAvailableInBrowser: false;
14
14
  requiredExecutables: never[];
15
15
  }>;
16
16
  /**
@@ -19,7 +19,7 @@ export declare const boilerplateScraperMetadata: import("type-fest/source/readon
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
- * @public exported from `@promptbook/wizzard`
22
+ * @public exported from `@promptbook/wizard`
23
23
  * @public exported from `@promptbook/cli`
24
24
  */
25
25
  export declare const _BoilerplateScraperMetadataRegistration: Registration;
@@ -12,7 +12,7 @@ export declare function prepareKnowledgePieces(knowledgeSources: ReadonlyArray<K
12
12
  /**
13
13
  * TODO: [🧊] In future one preparation can take data from previous preparation and save tokens and time
14
14
  * Put `knowledgePieces` into `PrepareKnowledgeOptions`
15
- * TODO: [🪂] More than max things can run in parallel by acident [1,[2a,2b,_],[3a,3b,_]]
15
+ * TODO: [🪂] More than max things can run in parallel by accident [1,[2a,2b,_],[3a,3b,_]]
16
16
  * TODO: [🧠][❎] Do here proper M:N mapping
17
17
  * [x] One source can make multiple pieces
18
18
  * [ ] One piece can have multiple sources
@@ -33,7 +33,7 @@ export type ScraperAndConverterMetadata = Registered & {
33
33
  *
34
34
  * Note: [🌏] Only `MarkdownScraper` makes sense to be available in the browser, for scraping non-markdown sources in the browser use a remote server
35
35
  */
36
- readonly isAvilableInBrowser: boolean;
36
+ readonly isAvailableInBrowser: boolean;
37
37
  /**
38
38
  * List of executables required by this scraper or converter to function properly.
39
39
  * For example, PDF scrapers may require 'pandoc' to be installed on the system.
@@ -12,7 +12,7 @@ export declare const createDocumentScraper: ((tools: Pick<ExecutionTools, 'llm'>
12
12
  className: string;
13
13
  mimeTypes: string[];
14
14
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
15
- isAvilableInBrowser: false;
15
+ isAvailableInBrowser: false;
16
16
  requiredExecutables: "Pandoc"[];
17
17
  }>;
18
18
  /**
@@ -5,7 +5,7 @@ import type { Registration } from '../../utils/$Register';
5
5
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
6
6
  *
7
7
  * @public exported from `@promptbook/documents`
8
- * @public exported from `@promptbook/wizzard`
8
+ * @public exported from `@promptbook/wizard`
9
9
  * @public exported from `@promptbook/cli`
10
10
  */
11
11
  export declare const _DocumentScraperRegistration: Registration;
@@ -10,7 +10,7 @@ export declare const documentScraperMetadata: import("type-fest/source/readonly-
10
10
  className: string;
11
11
  mimeTypes: string[];
12
12
  documentationUrl: "https://github.com/webgptorg/promptbook/discussions/@@";
13
- isAvilableInBrowser: false;
13
+ isAvailableInBrowser: false;
14
14
  requiredExecutables: "Pandoc"[];
15
15
  }>;
16
16
  /**
@@ -19,7 +19,7 @@ export declare const documentScraperMetadata: import("type-fest/source/readonly-
19
19
  * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available known scrapers
20
20
  *
21
21
  * @public exported from `@promptbook/core`
22
- * @public exported from `@promptbook/wizzard`
22
+ * @public exported from `@promptbook/wizard`
23
23
  * @public exported from `@promptbook/cli`
24
24
  */
25
25
  export declare const _DocumentScraperMetadataRegistration: Registration;