@promptbook/fake-llm 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.
package/esm/index.es.js
CHANGED
|
@@ -20,7 +20,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
20
20
|
* @generated
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-
|
|
23
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.105.0-9';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6165,6 +6165,46 @@ class UseMcpCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6165
6165
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
6166
6166
|
*/
|
|
6167
6167
|
|
|
6168
|
+
/**
|
|
6169
|
+
* A search engine implementation that uses the SerpApi to fetch Google search results.
|
|
6170
|
+
*
|
|
6171
|
+
* @private <- TODO: !!!! Export via some package
|
|
6172
|
+
*/
|
|
6173
|
+
class SerpSearchEngine {
|
|
6174
|
+
get title() {
|
|
6175
|
+
return 'SerpApi Search Engine';
|
|
6176
|
+
}
|
|
6177
|
+
get description() {
|
|
6178
|
+
return 'Search engine that uses SerpApi to fetch Google search results';
|
|
6179
|
+
}
|
|
6180
|
+
checkConfiguration() {
|
|
6181
|
+
if (!process.env.SERP_API_KEY) {
|
|
6182
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
6183
|
+
}
|
|
6184
|
+
}
|
|
6185
|
+
async search(query) {
|
|
6186
|
+
const apiKey = process.env.SERP_API_KEY;
|
|
6187
|
+
if (!apiKey) {
|
|
6188
|
+
throw new Error('SERP_API_KEY is not configured');
|
|
6189
|
+
}
|
|
6190
|
+
const url = new URL('https://serpapi.com/search');
|
|
6191
|
+
url.searchParams.set('q', query);
|
|
6192
|
+
url.searchParams.set('api_key', apiKey);
|
|
6193
|
+
url.searchParams.set('engine', 'google');
|
|
6194
|
+
const response = await fetch(url.toString());
|
|
6195
|
+
if (!response.ok) {
|
|
6196
|
+
const body = await response.text();
|
|
6197
|
+
throw new Error(`SerpApi failed with status ${response.status}: ${response.statusText}\n${body}`);
|
|
6198
|
+
}
|
|
6199
|
+
const data = (await response.json());
|
|
6200
|
+
return (data.organic_results || []).map((item) => ({
|
|
6201
|
+
title: item.title,
|
|
6202
|
+
url: item.link,
|
|
6203
|
+
snippet: item.snippet || '',
|
|
6204
|
+
}));
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
|
|
6168
6208
|
/**
|
|
6169
6209
|
* USE SEARCH ENGINE commitment definition
|
|
6170
6210
|
*
|
|
@@ -6241,18 +6281,13 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6241
6281
|
? existingTools
|
|
6242
6282
|
: [
|
|
6243
6283
|
...existingTools,
|
|
6244
|
-
{ type: 'web_search' },
|
|
6245
|
-
// <- Note: [🔰] This is just using simple native search tool by OpenAI @see https://platform.openai.com/docs/guides/tools-web-search
|
|
6246
|
-
// In future we will use proper MCP search tool:
|
|
6247
|
-
/*
|
|
6248
|
-
|
|
6249
6284
|
{
|
|
6250
6285
|
name: 'web_search',
|
|
6251
|
-
description: spaceTrim(`
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6286
|
+
description: spaceTrim$1(`
|
|
6287
|
+
Search the internet for information.
|
|
6288
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
6289
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
6290
|
+
`),
|
|
6256
6291
|
parameters: {
|
|
6257
6292
|
type: 'object',
|
|
6258
6293
|
properties: {
|
|
@@ -6264,7 +6299,6 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6264
6299
|
required: ['query'],
|
|
6265
6300
|
},
|
|
6266
6301
|
},
|
|
6267
|
-
*/
|
|
6268
6302
|
];
|
|
6269
6303
|
// Return requirements with updated tools and metadata
|
|
6270
6304
|
return {
|
|
@@ -6276,6 +6310,33 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
|
|
|
6276
6310
|
},
|
|
6277
6311
|
};
|
|
6278
6312
|
}
|
|
6313
|
+
/**
|
|
6314
|
+
* Gets the `web_search` tool function implementation.
|
|
6315
|
+
*/
|
|
6316
|
+
getToolFunctions() {
|
|
6317
|
+
return {
|
|
6318
|
+
async web_search(args) {
|
|
6319
|
+
console.log('!!!! [Tool] web_search called', { args });
|
|
6320
|
+
const { query } = args;
|
|
6321
|
+
if (!query) {
|
|
6322
|
+
throw new Error('Search query is required');
|
|
6323
|
+
}
|
|
6324
|
+
const searchEngine = new SerpSearchEngine();
|
|
6325
|
+
const results = await searchEngine.search(query);
|
|
6326
|
+
return spaceTrim$1((block) => `
|
|
6327
|
+
Search results for "${query}":
|
|
6328
|
+
|
|
6329
|
+
${block(results
|
|
6330
|
+
.map((result) => spaceTrim$1(`
|
|
6331
|
+
- **${result.title}**
|
|
6332
|
+
${result.url}
|
|
6333
|
+
${result.snippet}
|
|
6334
|
+
`))
|
|
6335
|
+
.join('\n\n'))}
|
|
6336
|
+
`);
|
|
6337
|
+
},
|
|
6338
|
+
};
|
|
6339
|
+
}
|
|
6279
6340
|
}
|
|
6280
6341
|
/**
|
|
6281
6342
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|