@promptbook/legacy-documents 0.105.0-3 → 0.105.0-30

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 (110) hide show
  1. package/README.md +36 -77
  2. package/esm/index.es.js +1 -1
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/browser.index.d.ts +4 -0
  5. package/esm/typings/src/_packages/components.index.d.ts +20 -0
  6. package/esm/typings/src/_packages/core.index.d.ts +19 -11
  7. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  8. package/esm/typings/src/_packages/openai.index.d.ts +2 -0
  9. package/esm/typings/src/_packages/types.index.d.ts +44 -2
  10. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  11. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
  12. package/esm/typings/src/book-2.0/agent-source/parseTeamCommitment.d.ts +28 -0
  13. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +5 -0
  14. package/esm/typings/src/book-components/Chat/AgentChip/AgentChip.d.ts +67 -0
  15. package/esm/typings/src/book-components/Chat/AgentChip/index.d.ts +2 -0
  16. package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +33 -1
  17. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +89 -11
  18. package/esm/typings/src/book-components/Chat/Chat/ChatSoundToggle.d.ts +23 -0
  19. package/esm/typings/src/book-components/Chat/Chat/ClockIcon.d.ts +9 -0
  20. package/esm/typings/src/book-components/Chat/LlmChat/FriendlyErrorMessage.d.ts +20 -0
  21. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  22. package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +35 -0
  23. package/esm/typings/src/book-components/Chat/SourceChip/index.d.ts +2 -0
  24. package/esm/typings/src/book-components/Chat/effects/ChatEffectsSystem.d.ts +14 -0
  25. package/esm/typings/src/book-components/Chat/effects/components/ConfettiEffect.d.ts +18 -0
  26. package/esm/typings/src/book-components/Chat/effects/components/HeartsEffect.d.ts +18 -0
  27. package/esm/typings/src/book-components/Chat/effects/configs/defaultEffectConfigs.d.ts +7 -0
  28. package/esm/typings/src/book-components/Chat/effects/index.d.ts +18 -0
  29. package/esm/typings/src/book-components/Chat/effects/types/ChatEffect.d.ts +20 -0
  30. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectConfig.d.ts +21 -0
  31. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectType.d.ts +6 -0
  32. package/esm/typings/src/book-components/Chat/effects/types/ChatEffectsSystemProps.d.ts +32 -0
  33. package/esm/typings/src/book-components/Chat/effects/utils/detectEffects.d.ts +12 -0
  34. package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +37 -0
  35. package/esm/typings/src/book-components/Chat/utils/createTeamToolNameFromUrl.d.ts +12 -0
  36. package/esm/typings/src/book-components/Chat/utils/getToolCallChipletText.d.ts +40 -0
  37. package/esm/typings/src/book-components/Chat/utils/loadAgentProfile.d.ts +69 -0
  38. package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +53 -0
  39. package/esm/typings/src/book-components/Chat/utils/resolveCitationUrl.d.ts +11 -0
  40. package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +64 -0
  41. package/esm/typings/src/book-components/icons/EmailIcon.d.ts +15 -0
  42. package/esm/typings/src/commitments/NOTE/NOTE.d.ts +2 -2
  43. package/esm/typings/src/commitments/TEAM/TEAM.d.ts +45 -0
  44. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.d.ts +44 -0
  45. package/esm/typings/src/commitments/TEMPLATE/TEMPLATE.test.d.ts +1 -0
  46. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +19 -1
  47. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContent.d.ts +22 -0
  48. package/esm/typings/src/commitments/USE_BROWSER/fetchUrlContentViaBrowser.d.ts +13 -0
  49. package/esm/typings/src/commitments/USE_EMAIL/USE_EMAIL.d.ts +48 -0
  50. package/esm/typings/src/commitments/USE_EMAIL/resolveSendEmailToolForNode.d.ts +11 -0
  51. package/esm/typings/src/commitments/USE_EMAIL/sendEmailViaBrowser.d.ts +18 -0
  52. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.d.ts +46 -0
  53. package/esm/typings/src/commitments/USE_IMAGE_GENERATOR/USE_IMAGE_GENERATOR.test.d.ts +1 -0
  54. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +11 -0
  55. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.test.d.ts +1 -0
  56. package/esm/typings/src/commitments/USE_TIME/USE_TIME.d.ts +6 -0
  57. package/esm/typings/src/commitments/_base/BaseCommitmentDefinition.d.ts +6 -0
  58. package/esm/typings/src/commitments/_base/CommitmentDefinition.d.ts +6 -0
  59. package/esm/typings/src/commitments/_base/formatOptionalInstructionBlock.d.ts +6 -0
  60. package/esm/typings/src/commitments/_common/commitmentToolFunctions.d.ts +26 -0
  61. package/esm/typings/src/commitments/_common/getAllCommitmentDefinitions.d.ts +8 -0
  62. package/esm/typings/src/commitments/_common/getAllCommitmentTypes.d.ts +8 -0
  63. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForBrowser.d.ts +9 -0
  64. package/esm/typings/src/commitments/_common/getAllCommitmentsToolFunctionsForNode.d.ts +13 -0
  65. package/esm/typings/src/commitments/_common/getAllCommitmentsToolTitles.d.ts +7 -0
  66. package/esm/typings/src/commitments/_common/getCommitmentDefinition.d.ts +10 -0
  67. package/esm/typings/src/commitments/_common/getGroupedCommitmentDefinitions.d.ts +17 -0
  68. package/esm/typings/src/commitments/_common/isCommitmentSupported.d.ts +9 -0
  69. package/esm/typings/src/commitments/index.d.ts +5 -58
  70. package/esm/typings/src/constants.d.ts +129 -0
  71. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +1 -0
  72. package/esm/typings/src/execution/AvailableModel.d.ts +5 -4
  73. package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
  74. package/esm/typings/src/execution/PromptResult.d.ts +2 -19
  75. package/esm/typings/src/execution/utils/$provideExecutionToolsForNode.d.ts +1 -0
  76. package/esm/typings/src/llm-providers/agent/Agent.d.ts +7 -1
  77. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
  78. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +7 -0
  79. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +1 -0
  80. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +1 -1
  81. package/esm/typings/src/llm-providers/google/createGoogleExecutionTools.d.ts +1 -0
  82. package/esm/typings/src/llm-providers/openai/OpenAiAgentExecutionTools.d.ts +43 -0
  83. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +4 -2
  84. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +8 -1
  85. package/esm/typings/src/llm-providers/openai/utils/uploadFilesToOpenAi.d.ts +7 -0
  86. package/esm/typings/src/pipeline/prompt-notation.d.ts +27 -2
  87. package/esm/typings/src/pipeline/prompt-notation.test.d.ts +1 -1
  88. package/esm/typings/src/scrapers/_common/register/$provideFilesystemForNode.d.ts +1 -0
  89. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -0
  90. package/esm/typings/src/scrapers/_common/register/$provideScriptingForNode.d.ts +1 -0
  91. package/esm/typings/src/search-engines/SearchEngine.d.ts +1 -1
  92. package/esm/typings/src/search-engines/_index.d.ts +6 -0
  93. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
  94. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
  95. package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
  96. package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
  97. package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
  98. package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +35 -0
  99. package/esm/typings/src/types/ModelRequirements.d.ts +6 -0
  100. package/esm/typings/src/types/Prompt.d.ts +12 -0
  101. package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
  102. package/esm/typings/src/types/ToolCall.d.ts +37 -0
  103. package/esm/typings/src/types/typeAliases.d.ts +4 -0
  104. package/esm/typings/src/utils/misc/linguisticHash.d.ts +6 -0
  105. package/esm/typings/src/utils/misc/linguisticHash.test.d.ts +1 -0
  106. package/esm/typings/src/version.d.ts +1 -1
  107. package/esm/typings/src/wizard/wizard.d.ts +1 -4
  108. package/package.json +2 -2
  109. package/umd/index.umd.js +1 -1
  110. package/umd/index.umd.js.map +1 -1
@@ -71,6 +71,135 @@ export declare const RESERVED_PARAMETER_RESTRICTED: string;
71
71
  * @public exported from `@promptbook/core`
72
72
  */
73
73
  export declare const RESERVED_PARAMETER_NAMES: readonly ["content", "context", "knowledge", "examples", "modelName", "currentDate"];
74
+ /**
75
+ * Limits for IDs, names, and other strings
76
+ *
77
+ * @public exported from `@promptbook/core`
78
+ */
79
+ export declare const LIMITS: {
80
+ /**
81
+ * Minimum length of a name (e.g. agent name, persona name)
82
+ */
83
+ readonly NAME_MIN_LENGTH: 3;
84
+ /**
85
+ * Recommended maximum length of a name
86
+ */
87
+ readonly NAME_MAX_LENGTH: 20;
88
+ /**
89
+ * Maximum length of a short description or a hash
90
+ */
91
+ readonly SHORT_TEXT_MAX_LENGTH: 30;
92
+ /**
93
+ * Gone
94
+ */
95
+ readonly GONE: 410;
96
+ /**
97
+ * Gateway timeout
98
+ */
99
+ readonly GATEWAY_TIMEOUT: 504;
100
+ /**
101
+ * Too many requests
102
+ */
103
+ readonly TOO_MANY_REQUESTS: 429;
104
+ /**
105
+ * Maximum length of a file path segment
106
+ */
107
+ readonly FILE_PATH_SEGMENT_MAX_LENGTH: 8;
108
+ /**
109
+ * Default length of a short name (e.g. for default agent names)
110
+ */
111
+ readonly SHORT_NAME_LENGTH: 6;
112
+ };
113
+ /**
114
+ * Common time intervals in milliseconds
115
+ *
116
+ * @public exported from `@promptbook/core`
117
+ */
118
+ export declare const TIME_INTERVALS: {
119
+ /**
120
+ * Hundred milliseconds
121
+ */
122
+ readonly HUNDRED_MILLISECONDS: 100;
123
+ /**
124
+ * One second in milliseconds
125
+ */
126
+ readonly SECOND: 1000;
127
+ /**
128
+ * Two seconds in milliseconds
129
+ */
130
+ readonly TWO_SECONDS: 2000;
131
+ /**
132
+ * One minute in milliseconds
133
+ */
134
+ readonly MINUTE: 60000;
135
+ /**
136
+ * Thirty seconds in milliseconds
137
+ */
138
+ readonly THIRTY_SECONDS: 30000;
139
+ /**
140
+ * Five seconds in milliseconds
141
+ */
142
+ readonly FIVE_SECONDS: 5000;
143
+ };
144
+ /**
145
+ * Common ports and network limits
146
+ *
147
+ * @public exported from `@promptbook/core`
148
+ */
149
+ export declare const NETWORK_LIMITS: {
150
+ /**
151
+ * Maximum valid port number
152
+ */
153
+ readonly MAX_PORT: 65535;
154
+ };
155
+ /**
156
+ * Common color and image constants
157
+ *
158
+ * @public exported from `@promptbook/core`
159
+ */
160
+ export declare const COLOR_CONSTANTS: {
161
+ /**
162
+ * Maximum value for a color channel (0-255)
163
+ */
164
+ readonly MAX_CHANNEL_VALUE: 255;
165
+ /**
166
+ * Number of possible colors in 24-bit color (0xFFFFFF)
167
+ */
168
+ readonly MAX_24BIT_COLOR: 16777215;
169
+ /**
170
+ * Base for hexadecimal strings
171
+ */
172
+ readonly HEX_BASE: 16;
173
+ /**
174
+ * Length of a hex color without alpha (e.g. "FF0000")
175
+ */
176
+ readonly HEX_COLOR_LENGTH: 6;
177
+ /**
178
+ * Full circle in degrees
179
+ */
180
+ readonly FULL_CIRCLE_DEGREES: 360;
181
+ /**
182
+ * Half circle in degrees
183
+ */
184
+ readonly HALF_CIRCLE_DEGREES: 180;
185
+ };
186
+ /**
187
+ * HTTP Status Codes
188
+ *
189
+ * @public exported from `@promptbook/core`
190
+ */
191
+ export declare const HTTP_STATUS_CODES: {
192
+ readonly OK: 200;
193
+ readonly CREATED: 201;
194
+ readonly BAD_REQUEST: 400;
195
+ readonly UNAUTHORIZED: 401;
196
+ readonly NOT_FOUND: 404;
197
+ readonly INTERNAL_SERVER_ERROR: 500;
198
+ readonly BAD_GATEWAY: 502;
199
+ readonly SERVICE_UNAVAILABLE: 503;
200
+ readonly GATEWAY_TIMEOUT: 504;
201
+ readonly TOO_MANY_REQUESTS: 429;
202
+ };
74
203
  /**
75
204
  * Note: [💞] Ignore a discrepancy between file name and entity name
76
205
  */
@@ -9,4 +9,5 @@ export declare function $provideExecutablesForNode(options?: PrepareAndScrapeOpt
9
9
  /**
10
10
  * TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
12
13
  */
@@ -1,8 +1,5 @@
1
1
  import type { ModelVariant } from '../types/ModelVariant';
2
- import type { number_usd } from '../types/typeAliases';
3
- import type { string_model_description } from '../types/typeAliases';
4
- import type { string_model_name } from '../types/typeAliases';
5
- import type { string_title } from '../types/typeAliases';
2
+ import type { number_usd, string_model_description, string_model_name, string_title, string_url } from '../types/typeAliases';
6
3
  /**
7
4
  * Represents a model that can be used for prompt execution
8
5
  */
@@ -40,6 +37,10 @@ export type AvailableModel = {
40
37
  readonly prompt: number_usd;
41
38
  readonly output: number_usd;
42
39
  };
40
+ /**
41
+ * URL to the model (or provider) documentation
42
+ */
43
+ readonly documentationUrl?: string_url;
43
44
  /**
44
45
  * If the model is deprecated, it should not be used for new tasks
45
46
  */
@@ -56,7 +56,9 @@ export type LlmExecutionTools = {
56
56
  /**
57
57
  * Calls a chat model with streaming
58
58
  */
59
- callChatModelStream?(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
59
+ callChatModelStream?(prompt: Prompt, onProgress: (chunk: ChatPromptResult & {
60
+ isFinished?: boolean;
61
+ }) => void): Promise<ChatPromptResult>;
60
62
  /**
61
63
  * Calls a voice chat model
62
64
  */
@@ -1,5 +1,5 @@
1
+ import type { ToolCall } from '../types/ToolCall';
1
2
  import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
2
- import type { TODO_any } from '../utils/organization/TODO_any';
3
3
  import type { TODO_object } from '../utils/organization/TODO_object';
4
4
  import type { EmbeddingVector } from './EmbeddingVector';
5
5
  import type { Usage } from './Usage';
@@ -26,24 +26,7 @@ export type ChatPromptResult = CommonPromptResult & {
26
26
  /**
27
27
  * Optional tool calls made during the execution
28
28
  */
29
- readonly toolCalls?: ReadonlyArray<{
30
- /**
31
- * Name of the tool
32
- */
33
- readonly name: string;
34
- /**
35
- * Arguments of the tool call
36
- */
37
- readonly arguments: string;
38
- /**
39
- * Result of the tool call
40
- */
41
- readonly result: string;
42
- /**
43
- * Raw tool call from the model
44
- */
45
- readonly rawToolCall: TODO_any;
46
- }>;
29
+ readonly toolCalls?: ReadonlyArray<ToolCall>;
47
30
  };
48
31
  /**
49
32
  * Image prompt result
@@ -10,4 +10,5 @@ import type { ExecutionTools } from '../ExecutionTools';
10
10
  export declare function $provideExecutionToolsForNode(options?: PrepareAndScrapeOptions): Promise<ExecutionTools>;
11
11
  /**
12
12
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
13
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
13
14
  */
@@ -14,7 +14,8 @@ import type { AgentOptions } from './AgentOptions';
14
14
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
15
15
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
16
16
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
17
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
17
+ * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
18
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
18
19
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
19
20
  *
20
21
  * @public exported from `@promptbook/core`
@@ -67,11 +68,16 @@ export declare class Agent extends AgentLlmExecutionTools implements LlmExecutio
67
68
  description?: string;
68
69
  [key: string]: string | undefined;
69
70
  };
71
+ /**
72
+ * Human-readable titles for tool functions
73
+ */
74
+ toolTitles: Record<string, string>;
70
75
  /**
71
76
  * Not used in Agent, always returns empty array
72
77
  */
73
78
  get parameters(): Array<BookParameter>;
74
79
  readonly agentSource: BehaviorSubject<string_book>;
80
+ private readonly teacherAgent;
75
81
  constructor(options: AgentOptions);
76
82
  /**
77
83
  * Calls the chat model with agent-specific system prompt and requirements with streaming
@@ -16,7 +16,8 @@ import type { CreateAgentLlmExecutionToolsOptions } from './CreateAgentLlmExecut
16
16
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
17
17
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
18
18
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
19
- * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
19
+ * - `OpenAiAgentExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with agent capabilities (using Responses API), recommended for usage in `Agent` or `AgentLlmExecutionTools`
20
+ * - `OpenAiAssistantExecutionTools` - (Deprecated) which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities
20
21
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
21
22
  *
22
23
  * @public exported from `@promptbook/core`
@@ -27,6 +28,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
27
28
  * Cache of OpenAI assistants to avoid creating duplicates
28
29
  */
29
30
  private static assistantCache;
31
+ /**
32
+ * Cache of OpenAI vector stores to avoid creating duplicates
33
+ */
34
+ private static vectorStoreCache;
30
35
  /**
31
36
  * Cached model requirements to avoid re-parsing the agent source
32
37
  */
@@ -2,6 +2,7 @@ import type { string_book } from '../../book-2.0/agent-source/string_book';
2
2
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
3
  import type { ExecutionTools } from '../../execution/ExecutionTools';
4
4
  import type { Updatable } from '../../types/Updatable';
5
+ import { Agent } from './Agent';
5
6
  /**
6
7
  * Options for creating an Agent
7
8
  */
@@ -16,4 +17,10 @@ export type AgentOptions = CommonToolsOptions & {
16
17
  * The source of the agent
17
18
  */
18
19
  agentSource: Updatable<string_book>;
20
+ /**
21
+ * Teacher agent for self-learning
22
+ *
23
+ * Note: If provided, the agent can do full self-learning from the teacher agent during its operation.
24
+ */
25
+ teacherAgent: Agent | null;
19
26
  };
@@ -23,6 +23,7 @@ export declare class RemoteAgent extends Agent {
23
23
  private agentUrl;
24
24
  private _remoteAgentName;
25
25
  private _remoteAgentHash;
26
+ toolTitles: Record<string, string>;
26
27
  private _isVoiceCallingEnabled;
27
28
  private constructor();
28
29
  get agentName(): string_agent_name;
@@ -3,7 +3,7 @@ import type { string_agent_url } from '../../types/typeAliases';
3
3
  /**
4
4
  * Options for creating a Remote Agent
5
5
  */
6
- export type RemoteAgentOptions = CommonToolsOptions & {
6
+ export type RemoteAgentOptions = Omit<CommonToolsOptions, 'teacherAgent'> & {
7
7
  /**
8
8
  * Url of the remote agent
9
9
  */
@@ -10,5 +10,6 @@ export declare const createGoogleExecutionTools: ((options: GoogleExecutionTools
10
10
  className: string;
11
11
  };
12
12
  /**
13
+ * TODO: !!!!! Rename to `createGoogleLlmExecutionTools`, `...GoogleLlmExecutionTools`
13
14
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
14
15
  */
@@ -0,0 +1,43 @@
1
+ import OpenAI from 'openai';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import type { ChatPromptResult } from '../../execution/PromptResult';
4
+ import type { Prompt } from '../../types/Prompt';
5
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
6
+ import type { OpenAiCompatibleExecutionToolsNonProxiedOptions } from './OpenAiCompatibleExecutionToolsOptions';
7
+ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
8
+ /**
9
+ * Options for OpenAiAgentExecutionTools
10
+ */
11
+ export type OpenAiAgentExecutionToolsOptions = OpenAiCompatibleExecutionToolsNonProxiedOptions & {
12
+ /**
13
+ * ID of the vector store to use for file search
14
+ */
15
+ readonly vectorStoreId?: string;
16
+ };
17
+ /**
18
+ * Execution Tools for calling OpenAI API using the Responses API (Agents)
19
+ *
20
+ * @public exported from `@promptbook/openai`
21
+ */
22
+ export declare class OpenAiAgentExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
23
+ readonly vectorStoreId?: string;
24
+ constructor(options: OpenAiAgentExecutionToolsOptions);
25
+ get title(): string_title & string_markdown_text;
26
+ get description(): string_markdown;
27
+ /**
28
+ * Calls OpenAI API to use a chat model with streaming.
29
+ */
30
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
31
+ /**
32
+ * Creates a vector store from knowledge sources
33
+ */
34
+ static createVectorStore(client: OpenAI, name: string, knowledgeSources: ReadonlyArray<string>): Promise<string>;
35
+ /**
36
+ * Discriminant for type guards
37
+ */
38
+ protected get discriminant(): string;
39
+ /**
40
+ * Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAgentExecutionTools`
41
+ */
42
+ static isOpenAiAgentExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAgentExecutionTools;
43
+ }
@@ -18,6 +18,7 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
18
18
  * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
19
19
  *
20
20
  * @public exported from `@promptbook/openai`
21
+ * @deprecated Use `OpenAiAgentExecutionTools` instead which uses the new OpenAI Responses API
21
22
  */
22
23
  export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
23
24
  readonly assistantId: string_token;
@@ -33,11 +34,11 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
33
34
  /**
34
35
  * Calls OpenAI API to use a chat model.
35
36
  */
36
- callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
37
+ callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
37
38
  /**
38
39
  * Calls OpenAI API to use a chat model with streaming.
39
40
  */
40
- callChatModelStream(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
41
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
41
42
  /**
42
43
  * Get an existing assistant tool wrapper
43
44
  */
@@ -94,6 +95,7 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
94
95
  static isOpenAiAssistantExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAssistantExecutionTools;
95
96
  }
96
97
  /**
98
+ * TODO: !!!!! [✨🥚] Knowledge should work both with and without scrapers
97
99
  * TODO: [🙎] In `OpenAiAssistantExecutionTools` Allow to create abstract assistants with `isCreatingNewAssistantsAllowed`
98
100
  * TODO: [🧠][🧙‍♂️] Maybe there can be some wizard for those who want to use just OpenAI
99
101
  * TODO: Maybe make custom OpenAiError
@@ -39,10 +39,17 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
39
39
  * List all available OpenAI compatible models that can be used
40
40
  */
41
41
  listModels(): Promise<ReadonlyArray<AvailableModel>>;
42
+ /**
43
+ * Calls OpenAI compatible API to use a chat model.
44
+ */
42
45
  /**
43
46
  * Calls OpenAI compatible API to use a chat model.
44
47
  */
45
48
  callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
49
+ /**
50
+ * Calls OpenAI compatible API to use a chat model with streaming.
51
+ */
52
+ callChatModelStream(prompt: Prompt, onProgress: (chunk: ChatPromptResult) => void): Promise<ChatPromptResult>;
46
53
  /**
47
54
  * Internal method that handles parameter retry for chat model calls
48
55
  */
@@ -66,7 +73,7 @@ export declare abstract class OpenAiCompatibleExecutionTools implements LlmExecu
66
73
  /**
67
74
  * Calls OpenAI compatible API to use a image generation model
68
75
  */
69
- callImageGenerationModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements'>): Promise<ImagePromptResult>;
76
+ callImageGenerationModel(prompt: Prompt): Promise<ImagePromptResult>;
70
77
  /**
71
78
  * Internal method that handles parameter retry for image generation model calls
72
79
  */
@@ -0,0 +1,7 @@
1
+ import OpenAI from 'openai';
2
+ /**
3
+ * Uploads files to OpenAI and returns their IDs
4
+ *
5
+ * @private utility for `OpenAiAssistantExecutionTools` and `OpenAiCompatibleExecutionTools`
6
+ */
7
+ export declare function uploadFilesToOpenAi(client: OpenAI, files: Array<File>): Promise<Array<string>>;
@@ -1,4 +1,28 @@
1
1
  import type { string_prompt } from '../types/typeAliases';
2
+ import type { really_unknown } from '../utils/organization/really_unknown';
3
+ /**
4
+ * Prompt string wrapper to retain prompt context across interpolations.
5
+ *
6
+ * @public exported from `@promptbook/utils`
7
+ */
8
+ export declare class PromptString extends String {
9
+ /**
10
+ * @param value Prompt content.
11
+ */
12
+ constructor(value: string_prompt);
13
+ /**
14
+ * Returns the prompt as a primitive string.
15
+ */
16
+ toString(): string_prompt;
17
+ /**
18
+ * Returns the prompt as a primitive string for implicit coercion.
19
+ */
20
+ valueOf(): string_prompt;
21
+ /**
22
+ * Ensures template literal coercion returns the raw string.
23
+ */
24
+ [Symbol.toPrimitive](): string_prompt;
25
+ }
2
26
  /**
3
27
  * Tag function for notating a prompt as template literal
4
28
  *
@@ -9,10 +33,10 @@ import type { string_prompt } from '../types/typeAliases';
9
33
  *
10
34
  * @param strings
11
35
  * @param values
12
- * @returns the prompt string
36
+ * @returns prompt content wrapped as a PromptString
13
37
  * @public exported from `@promptbook/utils`
14
38
  */
15
- export declare function prompt(strings: TemplateStringsArray, ...values: Array<string>): string_prompt;
39
+ export declare function prompt(strings: TemplateStringsArray, ...values: Array<really_unknown>): PromptString;
16
40
  /**
17
41
  * Tag function for notating a prompt as template literal
18
42
  *
@@ -26,6 +50,7 @@ export declare function prompt(strings: TemplateStringsArray, ...values: Array<s
26
50
  */
27
51
  export declare const promptTemplate: typeof prompt;
28
52
  /**
53
+ * TODO: Maybe split into multiple files
29
54
  * TODO: [🧠][🈴] Where is the best location for this file
30
55
  * Note: [💞] Ignore a discrepancy between file name and entity name
31
56
  */
@@ -1,4 +1,4 @@
1
1
  export {};
2
2
  /**
3
- * TODO: [🧠][🈴] Where is the best location for this file
3
+ * TODO: [??][??] Where is the best location for this file
4
4
  */
@@ -9,4 +9,5 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
9
9
  export declare function $provideFilesystemForNode(options?: Pick<PrepareAndScrapeOptions, 'isVerbose'>): FilesystemTools;
10
10
  /**
11
11
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
12
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
12
13
  */
@@ -10,4 +10,5 @@ import type { Scraper } from '../Scraper';
10
10
  export declare function $provideScrapersForNode(tools: Pick<ExecutionTools, 'fs' | 'llm' | 'executables'>, options?: PrepareAndScrapeOptions): Promise<ReadonlyArray<Scraper>>;
11
11
  /**
12
12
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
13
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
13
14
  */
@@ -8,4 +8,5 @@ import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeO
8
8
  export declare function $provideScriptingForNode(options?: PrepareAndScrapeOptions): Promise<ReadonlyArray<ScriptExecutionTools>>;
9
9
  /**
10
10
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
11
+ * TODO: [🏓] Unite `xxxForServer` and `xxxForNode` naming
11
12
  */
@@ -5,5 +5,5 @@ export type SearchEngine = {
5
5
  readonly title: string_title & string_markdown_text;
6
6
  readonly description?: string_markdown;
7
7
  checkConfiguration(): Promisable<void>;
8
- search(query: string): Promise<SearchResult[]>;
8
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
9
9
  };
@@ -0,0 +1,6 @@
1
+ export * from './bing/BingSearchEngine';
2
+ export * from './dummy/DummySearchEngine';
3
+ export * from './google/GoogleSearchEngine';
4
+ export * from './SearchEngine';
5
+ export * from './SearchResult';
6
+ export * from './serp/SerpSearchEngine';
@@ -11,5 +11,5 @@ export declare class BingSearchEngine implements SearchEngine {
11
11
  get title(): string_title & string_markdown_text;
12
12
  get description(): string_markdown;
13
13
  checkConfiguration(): Promisable<void>;
14
- search(query: string): Promise<SearchResult[]>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
15
  }
@@ -11,5 +11,5 @@ export declare class DummySearchEngine implements SearchEngine {
11
11
  get title(): string_title & string_markdown_text;
12
12
  get description(): string_markdown;
13
13
  checkConfiguration(): Promisable<void>;
14
- search(query: string): Promise<SearchResult[]>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
15
  }
@@ -0,0 +1,18 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
3
+ import type { SearchEngine } from '../SearchEngine';
4
+ import type { SearchResult } from '../SearchResult';
5
+ /**
6
+ * A search engine implementation that uses the Google Custom Search JSON API.
7
+ *
8
+ * @private <- TODO: !!!! Export via some package
9
+ */
10
+ export declare class GoogleSearchEngine implements SearchEngine {
11
+ get title(): string_title & string_markdown_text;
12
+ get description(): string_markdown;
13
+ /**
14
+ * @see https://developers.google.com/custom-search/v1/overview
15
+ */
16
+ checkConfiguration(): Promisable<void>;
17
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
18
+ }
@@ -0,0 +1,15 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
3
+ import type { SearchEngine } from '../SearchEngine';
4
+ import type { SearchResult } from '../SearchResult';
5
+ /**
6
+ * A search engine implementation that uses the SerpApi to fetch Google search results.
7
+ *
8
+ * @private <- TODO: !!!! Export via some package
9
+ */
10
+ export declare class SerpSearchEngine implements SearchEngine {
11
+ get title(): string_title & string_markdown_text;
12
+ get description(): string_markdown;
13
+ checkConfiguration(): Promisable<void>;
14
+ search(query: string, options?: Record<string, unknown>): Promise<SearchResult[]>;
15
+ }
@@ -0,0 +1,21 @@
1
+ import type { SpeechRecognition, SpeechRecognitionEvent, SpeechRecognitionStartOptions, SpeechRecognitionState } from '../types/SpeechRecognition';
2
+ /**
3
+ * Speech recognition using Web Speech API `SpeechRecognition` available in modern browsers
4
+ *
5
+ * @public exported from `@promptbook/browser`
6
+ */
7
+ export declare class BrowserSpeechRecognition implements SpeechRecognition {
8
+ private recognition;
9
+ private callbacks;
10
+ private _state;
11
+ get state(): SpeechRecognitionState;
12
+ constructor();
13
+ $start(options?: SpeechRecognitionStartOptions): void;
14
+ $stop(): void;
15
+ subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
16
+ private emit;
17
+ }
18
+ /**
19
+ * TODO: !!!! Search ACRY for `window` and put -> [🔵]
20
+ * Note: [🔵] Code in this file should never be published outside of `@promptbook/browser`
21
+ */
@@ -0,0 +1,35 @@
1
+ import type { SpeechRecognition, SpeechRecognitionEvent, SpeechRecognitionStartOptions, SpeechRecognitionState } from '../types/SpeechRecognition';
2
+ /**
3
+ * Options for OpenAiSpeechRecognition
4
+ */
5
+ export type OpenAiSpeechRecognitionOptions = {
6
+ /**
7
+ * OpenAI API base URL or proxy endpoint
8
+ * @default '/api/openai/v1'
9
+ */
10
+ readonly baseUrl?: string;
11
+ };
12
+ /**
13
+ * Speech recognition using OpenAI Whisper API to transcribe audio into text
14
+ *
15
+ * @private because it requires server-client communication with a proxy endpoint
16
+ *
17
+ * Note: This implementation uses a server-side proxy to avoid exposing the OpenAI API key on the client.
18
+ */
19
+ export declare class OpenAiSpeechRecognition implements SpeechRecognition {
20
+ private readonly options;
21
+ private mediaRecorder;
22
+ private audioContext;
23
+ private analyser;
24
+ private silenceTimeout;
25
+ private audioChunks;
26
+ private callbacks;
27
+ private _state;
28
+ get state(): SpeechRecognitionState;
29
+ constructor(options?: OpenAiSpeechRecognitionOptions);
30
+ $start(options?: SpeechRecognitionStartOptions): Promise<void>;
31
+ $stop(): void;
32
+ private transcribe;
33
+ subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
34
+ private emit;
35
+ }
@@ -129,6 +129,12 @@ export type CommonModelRequirements = {
129
129
  * Note: [🚉] This is fully serializable as JSON
130
130
  */
131
131
  readonly tools?: LlmToolDefinition[];
132
+ /**
133
+ * Optional list of knowledge source links that the model can use
134
+ *
135
+ * Note: [🚉] This is fully serializable as JSON
136
+ */
137
+ readonly knowledgeSources?: string[];
132
138
  };
133
139
  /**
134
140
  * TODO: [🧠][🈁] `seed` should maybe be somewhere else (not in `ModelRequirements`) (similar that `user` identification is not here)