@promptbook/remote-server 0.105.0-7 → 0.105.0-8
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
CHANGED
|
@@ -33,7 +33,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
33
33
|
* @generated
|
|
34
34
|
* @see https://github.com/webgptorg/promptbook
|
|
35
35
|
*/
|
|
36
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
36
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-8';
|
|
37
37
|
/**
|
|
38
38
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
39
39
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -11551,6 +11551,46 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11551
11551
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
11552
11552
|
*/
|
|
11553
11553
|
|
|
11554
|
+
/**
|
|
11555
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
11556
|
+
*
|
|
11557
|
+
* @private <- TODO: !!!! Export via some package
|
|
11558
|
+
*/
|
|
11559
|
+
class SerpSearchEngine {
|
|
11560
|
+
get title() {
|
|
11561
|
+
return 'SerpApi Search Engine';
|
|
11562
|
+
}
|
|
11563
|
+
get description() {
|
|
11564
|
+
return 'Search engine that uses SerpApi to fetch Google search results';
|
|
11565
|
+
}
|
|
11566
|
+
checkConfiguration() {
|
|
11567
|
+
if (!process.env.SERP_API_KEY) {
|
|
11568
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
11569
|
+
}
|
|
11570
|
+
}
|
|
11571
|
+
async search(query) {
|
|
11572
|
+
const apiKey = process.env.SERP_API_KEY;
|
|
11573
|
+
if (!apiKey) {
|
|
11574
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
11575
|
+
}
|
|
11576
|
+
const url = new URL('https://serpapi.com/search');
|
|
11577
|
+
url.searchParams.set('q', query);
|
|
11578
|
+
url.searchParams.set('api_key', apiKey);
|
|
11579
|
+
url.searchParams.set('engine', 'google');
|
|
11580
|
+
const response = await fetch(url.toString());
|
|
11581
|
+
if (!response.ok) {
|
|
11582
|
+
const body = await response.text();
|
|
11583
|
+
throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
|
|
11584
|
+
}
|
|
11585
|
+
const data = (await response.json());
|
|
11586
|
+
return (data.organic_results || []).map((item) => ({
|
|
11587
|
+
title: item.title,
|
|
11588
|
+
url: item.link,
|
|
11589
|
+
snippet: item.snippet || '',
|
|
11590
|
+
}));
|
|
11591
|
+
}
|
|
11592
|
+
}
|
|
11593
|
+
|
|
11554
11594
|
/**
|
|
11555
11595
|
* USE SEARCH ENGINE commitment definition
|
|
11556
11596
|
*
|
|
@@ -11627,18 +11667,13 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11627
11667
|
? existingTools
|
|
11628
11668
|
: [
|
|
11629
11669
|
...existingTools,
|
|
11630
|
-
{ type: 'web_search' },
|
|
11631
|
-
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
11632
|
-
// In future we will use proper MCP search tool:
|
|
11633
|
-
/*
|
|
11634
|
-
|
|
11635
11670
|
{
|
|
11636
11671
|
name: 'web_search',
|
|
11637
|
-
description: spaceTrim(`
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11672
|
+
description: spaceTrim$1(`
|
|
11673
|
+
Search the internet for information.
|
|
11674
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
11675
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
11676
|
+
`),
|
|
11642
11677
|
parameters: {
|
|
11643
11678
|
type: 'object',
|
|
11644
11679
|
properties: {
|
|
@@ -11650,7 +11685,6 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11650
11685
|
required: ['query'],
|
|
11651
11686
|
},
|
|
11652
11687
|
},
|
|
11653
|
-
*/
|
|
11654
11688
|
];
|
|
11655
11689
|
// Return requirements with updated tools and metadata
|
|
11656
11690
|
return {
|
|
@@ -11662,6 +11696,33 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
11662
11696
|
},
|
|
11663
11697
|
};
|
|
11664
11698
|
}
|
|
11699
|
+
/**
|
|
11700
|
+
* Gets the `web_search` tool function implementation.
|
|
11701
|
+
*/
|
|
11702
|
+
getToolFunctions() {
|
|
11703
|
+
return {
|
|
11704
|
+
async web_search(args) {
|
|
11705
|
+
console.log('!!!! [Tool] web_search called', { args });
|
|
11706
|
+
const { query } = args;
|
|
11707
|
+
if (!query) {
|
|
11708
|
+
throw new Error('Search query is required');
|
|
11709
|
+
}
|
|
11710
|
+
const searchEngine = new SerpSearchEngine();
|
|
11711
|
+
const results = await searchEngine.search(query);
|
|
11712
|
+
return spaceTrim$1((block) => `
|
|
11713
|
+
Search results for "${query}":
|
|
11714
|
+
|
|
11715
|
+
${block(results
|
|
11716
|
+
.map((result) => spaceTrim$1(`
|
|
11717
|
+
- **${result.title}**
|
|
11718
|
+
${result.url}
|
|
11719
|
+
${result.snippet}
|
|
11720
|
+
`))
|
|
11721
|
+
.join('\n\n'))}
|
|
11722
|
+
`);
|
|
11723
|
+
},
|
|
11724
|
+
};
|
|
11725
|
+
}
|
|
11665
11726
|
}
|
|
11666
11727
|
/**
|
|
11667
11728
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|