@promptbook/wizard 0.105.0-7 → 0.105.0-9
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { string_javascript_name } from '../../_packages/types.index';
|
|
1
2
|
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
3
|
+
import { ToolFunction } from '../../scripting/javascript/JavascriptExecutionToolsOptions';
|
|
2
4
|
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
5
|
/**
|
|
4
6
|
* USE SEARCH ENGINE commitment definition
|
|
@@ -32,6 +34,10 @@ export declare class UseSearchEngineCommitmentDefinition extends BaseCommitmentD
|
|
|
32
34
|
*/
|
|
33
35
|
get documentation(): string;
|
|
34
36
|
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the `web_search` tool function implementation.
|
|
39
|
+
*/
|
|
40
|
+
getToolFunctions(): Record<string_javascript_name, ToolFunction>;
|
|
35
41
|
}
|
|
36
42
|
/**
|
|
37
43
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.105.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.105.0-8`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/wizard",
|
|
3
|
-
"version": "0.105.0-
|
|
3
|
+
"version": "0.105.0-9",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"module": "./esm/index.es.js",
|
|
96
96
|
"typings": "./esm/typings/src/_packages/wizard.index.d.ts",
|
|
97
97
|
"peerDependencies": {
|
|
98
|
-
"@promptbook/core": "0.105.0-
|
|
98
|
+
"@promptbook/core": "0.105.0-9"
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@ai-sdk/deepseek": "0.1.17",
|
package/umd/index.umd.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
* @generated
|
|
49
49
|
* @see https://github.com/webgptorg/promptbook
|
|
50
50
|
*/
|
|
51
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
51
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-9';
|
|
52
52
|
/**
|
|
53
53
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
54
54
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -17725,6 +17725,46 @@
|
|
|
17725
17725
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17726
17726
|
*/
|
|
17727
17727
|
|
|
17728
|
+
/**
|
|
17729
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
17730
|
+
*
|
|
17731
|
+
* @private <- TODO: !!!! Export via some package
|
|
17732
|
+
*/
|
|
17733
|
+
class SerpSearchEngine {
|
|
17734
|
+
get title() {
|
|
17735
|
+
return 'SerpApi Search Engine';
|
|
17736
|
+
}
|
|
17737
|
+
get description() {
|
|
17738
|
+
return 'Search engine that uses SerpApi to fetch Google search results';
|
|
17739
|
+
}
|
|
17740
|
+
checkConfiguration() {
|
|
17741
|
+
if (!process.env.SERP_API_KEY) {
|
|
17742
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
17743
|
+
}
|
|
17744
|
+
}
|
|
17745
|
+
async search(query) {
|
|
17746
|
+
const apiKey = process.env.SERP_API_KEY;
|
|
17747
|
+
if (!apiKey) {
|
|
17748
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
17749
|
+
}
|
|
17750
|
+
const url = new URL('https://serpapi.com/search');
|
|
17751
|
+
url.searchParams.set('q', query);
|
|
17752
|
+
url.searchParams.set('api_key', apiKey);
|
|
17753
|
+
url.searchParams.set('engine', 'google');
|
|
17754
|
+
const response = await fetch(url.toString());
|
|
17755
|
+
if (!response.ok) {
|
|
17756
|
+
const body = await response.text();
|
|
17757
|
+
throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
|
|
17758
|
+
}
|
|
17759
|
+
const data = (await response.json());
|
|
17760
|
+
return (data.organic_results || []).map((item) => ({
|
|
17761
|
+
title: item.title,
|
|
17762
|
+
url: item.link,
|
|
17763
|
+
snippet: item.snippet || '',
|
|
17764
|
+
}));
|
|
17765
|
+
}
|
|
17766
|
+
}
|
|
17767
|
+
|
|
17728
17768
|
/**
|
|
17729
17769
|
* USE SEARCH ENGINE commitment definition
|
|
17730
17770
|
*
|
|
@@ -17801,18 +17841,13 @@
|
|
|
17801
17841
|
? existingTools
|
|
17802
17842
|
: [
|
|
17803
17843
|
...existingTools,
|
|
17804
|
-
{ type: 'web_search' },
|
|
17805
|
-
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
17806
|
-
// In future we will use proper MCP search tool:
|
|
17807
|
-
/*
|
|
17808
|
-
|
|
17809
17844
|
{
|
|
17810
17845
|
name: 'web_search',
|
|
17811
|
-
description: spaceTrim(`
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
|
|
17815
|
-
|
|
17846
|
+
description: spaceTrim$1.spaceTrim(`
|
|
17847
|
+
Search the internet for information.
|
|
17848
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
17849
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
17850
|
+
`),
|
|
17816
17851
|
parameters: {
|
|
17817
17852
|
type: 'object',
|
|
17818
17853
|
properties: {
|
|
@@ -17824,7 +17859,6 @@
|
|
|
17824
17859
|
required: ['query'],
|
|
17825
17860
|
},
|
|
17826
17861
|
},
|
|
17827
|
-
*/
|
|
17828
17862
|
];
|
|
17829
17863
|
// Return requirements with updated tools and metadata
|
|
17830
17864
|
return {
|
|
@@ -17836,6 +17870,33 @@
|
|
|
17836
17870
|
},
|
|
17837
17871
|
};
|
|
17838
17872
|
}
|
|
17873
|
+
/**
|
|
17874
|
+
* Gets the `web_search` tool function implementation.
|
|
17875
|
+
*/
|
|
17876
|
+
getToolFunctions() {
|
|
17877
|
+
return {
|
|
17878
|
+
async web_search(args) {
|
|
17879
|
+
console.log('!!!! [Tool] web_search called', { args });
|
|
17880
|
+
const { query } = args;
|
|
17881
|
+
if (!query) {
|
|
17882
|
+
throw new Error('Search query is required');
|
|
17883
|
+
}
|
|
17884
|
+
const searchEngine = new SerpSearchEngine();
|
|
17885
|
+
const results = await searchEngine.search(query);
|
|
17886
|
+
return spaceTrim$1.spaceTrim((block) => `
|
|
17887
|
+
Search results for "${query}":
|
|
17888
|
+
|
|
17889
|
+
${block(results
|
|
17890
|
+
.map((result) => spaceTrim$1.spaceTrim(`
|
|
17891
|
+
- **${result.title}**
|
|
17892
|
+
${result.url}
|
|
17893
|
+
${result.snippet}
|
|
17894
|
+
`))
|
|
17895
|
+
.join('\n\n'))}
|
|
17896
|
+
`);
|
|
17897
|
+
},
|
|
17898
|
+
};
|
|
17899
|
+
}
|
|
17839
17900
|
}
|
|
17840
17901
|
/**
|
|
17841
17902
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -20114,6 +20175,16 @@
|
|
|
20114
20175
|
}
|
|
20115
20176
|
}
|
|
20116
20177
|
}
|
|
20178
|
+
if (shouldCache && promptResult.toolCalls !== undefined) {
|
|
20179
|
+
// Note: Do not cache results that contain tool calls because they are dynamic and should be always fresh
|
|
20180
|
+
// For example, it doesn't make sense to cache the message 'What time is it? 3:30 pm' because when the question is asked another time, it can be a different time.
|
|
20181
|
+
shouldCache = false;
|
|
20182
|
+
if (isVerbose) {
|
|
20183
|
+
console.info('Not caching result that contains tool calls for key:', key, {
|
|
20184
|
+
toolCalls: promptResult.toolCalls,
|
|
20185
|
+
});
|
|
20186
|
+
}
|
|
20187
|
+
}
|
|
20117
20188
|
if (shouldCache) {
|
|
20118
20189
|
await storage.setItem(key, {
|
|
20119
20190
|
date: $getCurrentDate(),
|