@promptbook/wizard 0.105.0-4 → 0.105.0-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.es.js +84 -6
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/browser.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +12 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +6 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +3 -6
- package/esm/typings/src/book-components/Chat/types/ChatMessage.d.ts +9 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +3 -1
- package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +7 -0
- package/esm/typings/src/search-engines/_index.d.ts +6 -0
- package/esm/typings/src/search-engines/google/GoogleSearchEngine.d.ts +18 -0
- package/esm/typings/src/search-engines/serp/SerpSearchEngine.d.ts +15 -0
- package/esm/typings/src/speech-recognition/BrowserSpeechRecognition.d.ts +21 -0
- package/esm/typings/src/speech-recognition/OpenAiSpeechRecognition.d.ts +32 -0
- package/esm/typings/src/types/SpeechRecognition.d.ts +58 -0
- package/esm/typings/src/types/typeAliases.d.ts +4 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -2
- package/umd/index.umd.js +84 -6
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -36,7 +36,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
36
36
|
* @generated
|
|
37
37
|
* @see https://github.com/webgptorg/promptbook
|
|
38
38
|
*/
|
|
39
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
39
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-5';
|
|
40
40
|
/**
|
|
41
41
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
42
42
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -5832,20 +5832,29 @@ class OpenAiCompatibleExecutionTools {
|
|
|
5832
5832
|
});
|
|
5833
5833
|
return availableModels;
|
|
5834
5834
|
}
|
|
5835
|
+
/**
|
|
5836
|
+
* Calls OpenAI compatible API to use a chat model.
|
|
5837
|
+
*/
|
|
5835
5838
|
/**
|
|
5836
5839
|
* Calls OpenAI compatible API to use a chat model.
|
|
5837
5840
|
*/
|
|
5838
5841
|
async callChatModel(prompt) {
|
|
5842
|
+
return this.callChatModelStream(prompt, () => { });
|
|
5843
|
+
}
|
|
5844
|
+
/**
|
|
5845
|
+
* Calls OpenAI compatible API to use a chat model with streaming.
|
|
5846
|
+
*/
|
|
5847
|
+
async callChatModelStream(prompt, onProgress) {
|
|
5839
5848
|
// Deep clone prompt and modelRequirements to avoid mutation across calls
|
|
5840
5849
|
const clonedPrompt = JSON.parse(JSON.stringify(prompt));
|
|
5841
5850
|
// Use local Set for retried parameters to ensure independence and thread safety
|
|
5842
5851
|
const retriedUnsupportedParameters = new Set();
|
|
5843
|
-
return this.callChatModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters);
|
|
5852
|
+
return this.callChatModelWithRetry(clonedPrompt, clonedPrompt.modelRequirements, [], retriedUnsupportedParameters, onProgress);
|
|
5844
5853
|
}
|
|
5845
5854
|
/**
|
|
5846
5855
|
* Internal method that handles parameter retry for chat model calls
|
|
5847
5856
|
*/
|
|
5848
|
-
async callChatModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set()) {
|
|
5857
|
+
async callChatModelWithRetry(prompt, currentModelRequirements, attemptStack = [], retriedUnsupportedParameters = new Set(), onProgress) {
|
|
5849
5858
|
var _a;
|
|
5850
5859
|
if (this.options.isVerbose) {
|
|
5851
5860
|
console.info(`💬 ${this.title} callChatModel call`, { prompt, currentModelRequirements });
|
|
@@ -5951,6 +5960,23 @@ class OpenAiCompatibleExecutionTools {
|
|
|
5951
5960
|
const usage = this.computeUsage(content || '', responseMessage.content || '', rawResponse);
|
|
5952
5961
|
totalUsage = addUsage(totalUsage, usage);
|
|
5953
5962
|
if (responseMessage.tool_calls && responseMessage.tool_calls.length > 0) {
|
|
5963
|
+
if (onProgress) {
|
|
5964
|
+
onProgress({
|
|
5965
|
+
content: responseMessage.content || '',
|
|
5966
|
+
modelName: rawResponse.model || modelName,
|
|
5967
|
+
timing: { start, complete: $getCurrentDate() },
|
|
5968
|
+
usage: totalUsage,
|
|
5969
|
+
toolCalls: responseMessage.tool_calls.map((toolCall) => ({
|
|
5970
|
+
name: toolCall.function.name,
|
|
5971
|
+
arguments: toolCall.function.arguments,
|
|
5972
|
+
result: '',
|
|
5973
|
+
rawToolCall: toolCall,
|
|
5974
|
+
})),
|
|
5975
|
+
rawPromptContent,
|
|
5976
|
+
rawRequest,
|
|
5977
|
+
rawResponse,
|
|
5978
|
+
});
|
|
5979
|
+
}
|
|
5954
5980
|
await forEachAsync(responseMessage.tool_calls, {}, async (toolCall) => {
|
|
5955
5981
|
const functionName = toolCall.function.name;
|
|
5956
5982
|
const functionArgs = toolCall.function.arguments;
|
|
@@ -6078,7 +6104,7 @@ class OpenAiCompatibleExecutionTools {
|
|
|
6078
6104
|
});
|
|
6079
6105
|
// Remove the unsupported parameter and retry
|
|
6080
6106
|
const modifiedModelRequirements = removeUnsupportedModelRequirement(currentModelRequirements, unsupportedParameter);
|
|
6081
|
-
return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters);
|
|
6107
|
+
return this.callChatModelWithRetry(prompt, modifiedModelRequirements, attemptStack, retriedUnsupportedParameters, onProgress);
|
|
6082
6108
|
}
|
|
6083
6109
|
}
|
|
6084
6110
|
throw new PipelineExecutionError(`Tool calling loop did not return a result from ${this.title}`);
|
|
@@ -8192,6 +8218,15 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
8192
8218
|
// [🐱🚀] When tools are present, we need to use the non-streaming Runs API
|
|
8193
8219
|
// because streaming doesn't support tool execution flow properly
|
|
8194
8220
|
if (hasTools) {
|
|
8221
|
+
onProgress({
|
|
8222
|
+
content: '',
|
|
8223
|
+
modelName: 'assistant',
|
|
8224
|
+
timing: { start, complete: $getCurrentDate() },
|
|
8225
|
+
usage: UNCERTAIN_USAGE,
|
|
8226
|
+
rawPromptContent,
|
|
8227
|
+
rawRequest: null,
|
|
8228
|
+
rawResponse: null,
|
|
8229
|
+
});
|
|
8195
8230
|
const rawRequest = {
|
|
8196
8231
|
assistant_id: this.assistantId,
|
|
8197
8232
|
thread: {
|
|
@@ -8215,6 +8250,23 @@ class OpenAiAssistantExecutionTools extends OpenAiExecutionTools {
|
|
|
8215
8250
|
if (toolCall.type === 'function') {
|
|
8216
8251
|
const functionName = toolCall.function.name;
|
|
8217
8252
|
const functionArgs = JSON.parse(toolCall.function.arguments);
|
|
8253
|
+
onProgress({
|
|
8254
|
+
content: '',
|
|
8255
|
+
modelName: 'assistant',
|
|
8256
|
+
timing: { start, complete: $getCurrentDate() },
|
|
8257
|
+
usage: UNCERTAIN_USAGE,
|
|
8258
|
+
rawPromptContent,
|
|
8259
|
+
rawRequest: null,
|
|
8260
|
+
rawResponse: null,
|
|
8261
|
+
toolCalls: [
|
|
8262
|
+
{
|
|
8263
|
+
name: functionName,
|
|
8264
|
+
arguments: toolCall.function.arguments,
|
|
8265
|
+
result: '',
|
|
8266
|
+
rawToolCall: toolCall,
|
|
8267
|
+
},
|
|
8268
|
+
],
|
|
8269
|
+
});
|
|
8218
8270
|
if (this.options.isVerbose) {
|
|
8219
8271
|
console.info(`🔧 Executing tool: ${functionName}`, functionArgs);
|
|
8220
8272
|
}
|
|
@@ -18747,26 +18799,52 @@ function parseAgentSource(agentSource) {
|
|
|
18747
18799
|
});
|
|
18748
18800
|
continue;
|
|
18749
18801
|
}
|
|
18802
|
+
if (commitment.type === 'FROM') {
|
|
18803
|
+
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
18804
|
+
if (content === 'Adam' || content === '' /* <- Note: Adam is implicit */) {
|
|
18805
|
+
continue;
|
|
18806
|
+
}
|
|
18807
|
+
let label = content;
|
|
18808
|
+
let iconName = 'SquareArrowOutUpRight'; // Inheritance remote
|
|
18809
|
+
if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
18810
|
+
label = content.split('/').pop() || content;
|
|
18811
|
+
iconName = 'SquareArrowUpRight'; // Inheritance local
|
|
18812
|
+
}
|
|
18813
|
+
if (content === 'VOID') {
|
|
18814
|
+
label = 'VOID';
|
|
18815
|
+
iconName = 'ShieldAlert'; // [🧠] Or some other icon for VOID
|
|
18816
|
+
}
|
|
18817
|
+
capabilities.push({
|
|
18818
|
+
type: 'inheritance',
|
|
18819
|
+
label,
|
|
18820
|
+
iconName,
|
|
18821
|
+
agentUrl: content,
|
|
18822
|
+
});
|
|
18823
|
+
continue;
|
|
18824
|
+
}
|
|
18750
18825
|
if (commitment.type === 'IMPORT') {
|
|
18751
18826
|
const content = spaceTrim$2(commitment.content).split('\n')[0] || '';
|
|
18752
18827
|
let label = content;
|
|
18753
|
-
|
|
18828
|
+
let iconName = 'ExternalLink'; // Import remote
|
|
18754
18829
|
try {
|
|
18755
18830
|
if (content.startsWith('http://') || content.startsWith('https://')) {
|
|
18756
18831
|
const url = new URL(content);
|
|
18757
18832
|
label = url.hostname.replace(/^www\./, '') + '.../' + url.pathname.split('/').pop();
|
|
18833
|
+
iconName = 'ExternalLink';
|
|
18758
18834
|
}
|
|
18759
18835
|
else if (content.startsWith('./') || content.startsWith('../') || content.startsWith('/')) {
|
|
18760
18836
|
label = content.split('/').pop() || content;
|
|
18837
|
+
iconName = 'Link'; // Import local
|
|
18761
18838
|
}
|
|
18762
18839
|
}
|
|
18763
18840
|
catch (e) {
|
|
18764
18841
|
// Invalid URL or path, keep default label
|
|
18765
18842
|
}
|
|
18766
18843
|
capabilities.push({
|
|
18767
|
-
type: '
|
|
18844
|
+
type: 'import',
|
|
18768
18845
|
label,
|
|
18769
18846
|
iconName,
|
|
18847
|
+
agentUrl: content,
|
|
18770
18848
|
});
|
|
18771
18849
|
continue;
|
|
18772
18850
|
}
|