@promptbook/core 0.104.0-11 → 0.104.0-13
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 +98 -31
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +5 -0
- package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/_common/string_chat_format_name.d.ts +1 -1
- package/esm/typings/src/commands/_common/types/Command.d.ts +1 -1
- package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
- package/esm/typings/src/commitments/_base/BookCommitment.d.ts +1 -1
- package/esm/typings/src/formfactors/_common/FormfactorDefinition.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
- package/esm/typings/src/search-engines/SearchResult.d.ts +4 -4
- package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
- package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
- package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
- package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +1 -1
- package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +98 -31
- package/umd/index.umd.js.map +1 -1
|
@@ -188,6 +188,7 @@ import type { BookTranspiler } from '../transpilers/_common/BookTranspiler';
|
|
|
188
188
|
import type { BookTranspilerOptions } from '../transpilers/_common/BookTranspilerOptions';
|
|
189
189
|
import type { IntermediateFilesStrategy } from '../types/IntermediateFilesStrategy';
|
|
190
190
|
import type { LlmCall } from '../types/LlmCall';
|
|
191
|
+
import type { LlmToolDefinition } from '../types/LlmToolDefinition';
|
|
191
192
|
import type { Message } from '../types/Message';
|
|
192
193
|
import type { ModelRequirements } from '../types/ModelRequirements';
|
|
193
194
|
import type { CompletionModelRequirements } from '../types/ModelRequirements';
|
|
@@ -559,6 +560,7 @@ export type { BookTranspiler };
|
|
|
559
560
|
export type { BookTranspilerOptions };
|
|
560
561
|
export type { IntermediateFilesStrategy };
|
|
561
562
|
export type { LlmCall };
|
|
563
|
+
export type { LlmToolDefinition };
|
|
562
564
|
export type { Message };
|
|
563
565
|
export type { ModelRequirements };
|
|
564
566
|
export type { CompletionModelRequirements };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LlmToolDefinition } from '../../types/LlmToolDefinition';
|
|
1
2
|
import type { string_knowledge_source_link } from '../../types/typeAliases';
|
|
2
3
|
import type { TODO_any } from '../../utils/organization/TODO_any';
|
|
3
4
|
/**
|
|
@@ -45,6 +46,10 @@ export type AgentModelRequirements = {
|
|
|
45
46
|
* Top-k sampling value for the agent's responses
|
|
46
47
|
*/
|
|
47
48
|
readonly topK?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Tools available for the agent
|
|
51
|
+
*/
|
|
52
|
+
readonly tools?: ReadonlyArray<LlmToolDefinition>;
|
|
48
53
|
/**
|
|
49
54
|
* Arbitrary metadata storage for commitments
|
|
50
55
|
* Each commitment can store its own data here
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,4 +3,4 @@ import { CHAT_SAVE_FORMATS } from '../index';
|
|
|
3
3
|
* Supported chat export formatNames
|
|
4
4
|
* @public exported from `@promptbook/components`
|
|
5
5
|
*/
|
|
6
|
-
export type string_chat_format_name = typeof CHAT_SAVE_FORMATS[number]['formatName'];
|
|
6
|
+
export type string_chat_format_name = (typeof CHAT_SAVE_FORMATS)[number]['formatName'];
|
|
@@ -3,4 +3,4 @@ import { COMMANDS } from '../../index';
|
|
|
3
3
|
* Command is one piece of the book file section which adds some logic to the task or the whole pipeline.
|
|
4
4
|
* It is parsed from the markdown from ul/ol items - one command per one item.
|
|
5
5
|
*/
|
|
6
|
-
export type Command = ReturnType<typeof COMMANDS[number]['parse']>;
|
|
6
|
+
export type Command = ReturnType<(typeof COMMANDS)[number]['parse']>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
|
|
2
|
+
import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* META DESCRIPTION commitment definition
|
|
5
|
+
*
|
|
6
|
+
* The META DESCRIPTION commitment sets the agent's meta description for the profile page.
|
|
7
|
+
* This commitment is special because it doesn't affect the system message,
|
|
8
|
+
* but is handled separately in the parsing logic.
|
|
9
|
+
*
|
|
10
|
+
* Example usage in agent source:
|
|
11
|
+
*
|
|
12
|
+
* ```book
|
|
13
|
+
* META DESCRIPTION An AI assistant specialized in business tasks
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @private [🪔] Maybe export the commitments through some package
|
|
17
|
+
*/
|
|
18
|
+
export declare class MetaDescriptionCommitmentDefinition extends BaseCommitmentDefinition<'META DESCRIPTION'> {
|
|
19
|
+
constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Short one-line description of META DESCRIPTION.
|
|
22
|
+
*/
|
|
23
|
+
get description(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Icon for this commitment.
|
|
26
|
+
*/
|
|
27
|
+
get icon(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Markdown documentation for META DESCRIPTION commitment.
|
|
30
|
+
*/
|
|
31
|
+
get documentation(): string;
|
|
32
|
+
applyToAgentModelRequirements(requirements: AgentModelRequirements, content: string): AgentModelRequirements;
|
|
33
|
+
/**
|
|
34
|
+
* Extracts the meta description from the content
|
|
35
|
+
* This is used by the parsing logic
|
|
36
|
+
*/
|
|
37
|
+
extractMetaDescription(content: string): string | null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
41
|
+
*/
|
|
@@ -6,13 +6,13 @@ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
|
|
|
6
6
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
7
7
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
8
8
|
*
|
|
9
|
-
* The content following `USE SEARCH ENGINE` is
|
|
9
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
10
10
|
*
|
|
11
11
|
* Example usage in agent source:
|
|
12
12
|
*
|
|
13
13
|
* ```book
|
|
14
14
|
* USE SEARCH ENGINE
|
|
15
|
-
* USE SEARCH ENGINE
|
|
15
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -7,4 +7,4 @@ import { FORMFACTOR_DEFINITIONS } from '../index';
|
|
|
7
7
|
* Note: [🚉] This is fully serializable as JSON
|
|
8
8
|
* @see https://github.com/webgptorg/promptbook/discussions/172
|
|
9
9
|
*/
|
|
10
|
-
export type FormfactorDefinition = typeof FORMFACTOR_DEFINITIONS[number];
|
|
10
|
+
export type FormfactorDefinition = (typeof FORMFACTOR_DEFINITIONS)[number];
|
|
@@ -21,7 +21,7 @@ export declare function $provideLlmToolsForTestingAndScriptsAndPlayground(option
|
|
|
21
21
|
export {};
|
|
22
22
|
/**
|
|
23
23
|
* Note: [⚪] This should never be in any released package
|
|
24
|
-
* TODO: [👷♂️]
|
|
24
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
25
25
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
26
26
|
* TODO: [®] DRY Register logi
|
|
27
27
|
*/
|
|
@@ -51,7 +51,7 @@ export declare function $provideLlmToolsForWizardOrCli(options?: ProvideLlmTools
|
|
|
51
51
|
export {};
|
|
52
52
|
/**
|
|
53
53
|
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
54
|
-
* TODO: [👷♂️]
|
|
54
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
55
55
|
* TODO: [🥃] Allow `ptbk make` without llm tools
|
|
56
56
|
* TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
|
|
57
57
|
* TODO: [®] DRY Register logic
|
|
@@ -17,6 +17,6 @@ export type LlmExecutionToolsWithTotalUsage = LlmExecutionTools & {
|
|
|
17
17
|
spending(): Observable<Usage>;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* TODO: [👷♂️]
|
|
20
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
21
21
|
* Note: [🥫] Not using getter `get totalUsage` but `getTotalUsage` to allow this object to be proxied
|
|
22
22
|
*/
|
|
@@ -32,5 +32,5 @@ export {};
|
|
|
32
32
|
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
33
33
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
34
34
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
35
|
-
* TODO: [👷♂️]
|
|
35
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
36
36
|
*/
|
|
@@ -8,5 +8,5 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
|
|
|
8
8
|
export declare function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools: undefined | LlmExecutionTools | ReadonlyArray<LlmExecutionTools>): LlmExecutionTools | MultipleLlmExecutionTools;
|
|
9
9
|
/**
|
|
10
10
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11
|
-
* TODO: [👷♂️]
|
|
11
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
12
12
|
*/
|
|
@@ -19,5 +19,5 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
|
|
|
19
19
|
export declare function joinLlmExecutionTools(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
|
|
20
20
|
/**
|
|
21
21
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
22
|
-
* TODO: [👷♂️]
|
|
22
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
23
23
|
*/
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type OpenAI from 'openai';
|
|
2
|
+
import type { LlmToolDefinition } from '../../../types/LlmToolDefinition';
|
|
3
|
+
/**
|
|
4
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
5
|
+
*
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
export declare function mapToolsToOpenAi(tools: ReadonlyArray<LlmToolDefinition>): Array<OpenAI.Chat.Completions.ChatCompletionTool>;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type { string_url } from '../types/typeAliases';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Represents a search result from a search engine.
|
|
4
4
|
*/
|
|
5
5
|
export type SearchResult = {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* The title of the search result.
|
|
8
8
|
*/
|
|
9
9
|
title: string;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* The URL of the search result.
|
|
12
12
|
*/
|
|
13
13
|
url: string_url;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* A short snippet or description of the search result.
|
|
16
16
|
*/
|
|
17
17
|
snippet: string;
|
|
18
18
|
};
|
|
@@ -3,7 +3,7 @@ import type { string_markdown, string_markdown_text, string_title } from '../../
|
|
|
3
3
|
import type { SearchEngine } from '../SearchEngine';
|
|
4
4
|
import type { SearchResult } from '../SearchResult';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* A search engine implementation that uses the Bing Web Search API.
|
|
7
7
|
*
|
|
8
8
|
* @private <- TODO: !!!! Export via some package
|
|
9
9
|
*/
|
|
@@ -3,7 +3,7 @@ import type { string_markdown, string_markdown_text, string_title } from '../../
|
|
|
3
3
|
import type { SearchEngine } from '../SearchEngine';
|
|
4
4
|
import type { SearchResult } from '../SearchResult';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* A dummy implementation of SearchEngine for testing purposes.
|
|
7
7
|
*
|
|
8
8
|
* @private <- TODO: !!!! Export via some package, maybe `@promptbook/search-engines` or `@promptbook/fake-llm`
|
|
9
9
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { string_markdown_text, string_name } from './typeAliases';
|
|
2
|
+
/**
|
|
3
|
+
* Definition of a tool that can be used by the model
|
|
4
|
+
*
|
|
5
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
6
|
+
*/
|
|
7
|
+
export type LlmToolDefinition = {
|
|
8
|
+
/**
|
|
9
|
+
* Name of the tool
|
|
10
|
+
*/
|
|
11
|
+
readonly name: string_name;
|
|
12
|
+
/**
|
|
13
|
+
* Description of the tool
|
|
14
|
+
*/
|
|
15
|
+
readonly description: string_markdown_text;
|
|
16
|
+
/**
|
|
17
|
+
* Parameters of the tool in JSON Schema format
|
|
18
|
+
*/
|
|
19
|
+
readonly parameters: Record<string, unknown>;
|
|
20
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LlmToolDefinition } from './LlmToolDefinition';
|
|
1
2
|
import type { ModelVariant } from './ModelVariant';
|
|
2
3
|
import type { number_model_temperature, number_seed, string_model_name, string_system_message } from './typeAliases';
|
|
3
4
|
/**
|
|
@@ -28,6 +29,12 @@ export type CompletionModelRequirements = CommonModelRequirements & {
|
|
|
28
29
|
* Maximum number of tokens that can be generated by the model
|
|
29
30
|
*/
|
|
30
31
|
readonly maxTokens?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Tools available for the model
|
|
34
|
+
*
|
|
35
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
36
|
+
*/
|
|
37
|
+
readonly tools?: LlmToolDefinition[];
|
|
31
38
|
};
|
|
32
39
|
/**
|
|
33
40
|
* Model requirements for the chat variant
|
|
@@ -53,6 +60,12 @@ export type ChatModelRequirements = CommonModelRequirements & {
|
|
|
53
60
|
* Maximum number of tokens that can be generated by the model
|
|
54
61
|
*/
|
|
55
62
|
readonly maxTokens?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Tools available for the model
|
|
65
|
+
*
|
|
66
|
+
* Note: [🚉] This is fully serializable as JSON
|
|
67
|
+
*/
|
|
68
|
+
readonly tools?: LlmToolDefinition[];
|
|
56
69
|
};
|
|
57
70
|
/**
|
|
58
71
|
* Model requirements for the image generation variant
|
|
@@ -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.104.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.104.0-12`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-13';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -4004,7 +4004,7 @@
|
|
|
4004
4004
|
}
|
|
4005
4005
|
/**
|
|
4006
4006
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4007
|
-
* TODO: [👷♂️]
|
|
4007
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4008
4008
|
*/
|
|
4009
4009
|
|
|
4010
4010
|
/**
|
|
@@ -4021,7 +4021,7 @@
|
|
|
4021
4021
|
}
|
|
4022
4022
|
/**
|
|
4023
4023
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
4024
|
-
* TODO: [👷♂️]
|
|
4024
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
4025
4025
|
*/
|
|
4026
4026
|
|
|
4027
4027
|
/**
|
|
@@ -8075,9 +8075,7 @@
|
|
|
8075
8075
|
// Get existing dictionary entries from metadata
|
|
8076
8076
|
const existingDictionary = ((_a = requirements.metadata) === null || _a === void 0 ? void 0 : _a.DICTIONARY) || '';
|
|
8077
8077
|
// Merge the new dictionary entry with existing entries
|
|
8078
|
-
const mergedDictionary = existingDictionary
|
|
8079
|
-
? `${existingDictionary}\n${trimmedContent}`
|
|
8080
|
-
: trimmedContent;
|
|
8078
|
+
const mergedDictionary = existingDictionary ? `${existingDictionary}\n${trimmedContent}` : trimmedContent;
|
|
8081
8079
|
// Store the merged dictionary in metadata for debugging and inspection
|
|
8082
8080
|
const updatedMetadata = {
|
|
8083
8081
|
...requirements.metadata,
|
|
@@ -10606,19 +10604,37 @@
|
|
|
10606
10604
|
`);
|
|
10607
10605
|
}
|
|
10608
10606
|
applyToAgentModelRequirements(requirements, content) {
|
|
10609
|
-
// We simply mark that browser capability is enabled in metadata
|
|
10610
|
-
// Get existing metadata
|
|
10611
|
-
const existingMetadata = requirements.metadata || {};
|
|
10612
10607
|
// Get existing tools array or create new one
|
|
10613
|
-
const existingTools =
|
|
10614
|
-
// Add '
|
|
10615
|
-
const updatedTools = existingTools.
|
|
10616
|
-
|
|
10608
|
+
const existingTools = requirements.tools || [];
|
|
10609
|
+
// Add 'web_browser' to tools if not already present
|
|
10610
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
10611
|
+
? existingTools
|
|
10612
|
+
: [
|
|
10613
|
+
...existingTools,
|
|
10614
|
+
{
|
|
10615
|
+
name: 'web_browser',
|
|
10616
|
+
description: spaceTrim$1.spaceTrim(`
|
|
10617
|
+
A tool that can browse the web.
|
|
10618
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
10619
|
+
`),
|
|
10620
|
+
parameters: {
|
|
10621
|
+
type: 'object',
|
|
10622
|
+
properties: {
|
|
10623
|
+
url: {
|
|
10624
|
+
type: 'string',
|
|
10625
|
+
description: 'The URL to browse',
|
|
10626
|
+
},
|
|
10627
|
+
},
|
|
10628
|
+
required: ['url'],
|
|
10629
|
+
},
|
|
10630
|
+
},
|
|
10631
|
+
];
|
|
10632
|
+
// Return requirements with updated tools and metadata
|
|
10617
10633
|
return {
|
|
10618
10634
|
...requirements,
|
|
10635
|
+
tools: updatedTools,
|
|
10619
10636
|
metadata: {
|
|
10620
|
-
...
|
|
10621
|
-
tools: updatedTools,
|
|
10637
|
+
...requirements.metadata,
|
|
10622
10638
|
useBrowser: true,
|
|
10623
10639
|
},
|
|
10624
10640
|
};
|
|
@@ -10711,13 +10727,13 @@
|
|
|
10711
10727
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
10712
10728
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
10713
10729
|
*
|
|
10714
|
-
* The content following `USE SEARCH ENGINE` is
|
|
10730
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
10715
10731
|
*
|
|
10716
10732
|
* Example usage in agent source:
|
|
10717
10733
|
*
|
|
10718
10734
|
* ```book
|
|
10719
10735
|
* USE SEARCH ENGINE
|
|
10720
|
-
* USE SEARCH ENGINE
|
|
10736
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
10721
10737
|
* ```
|
|
10722
10738
|
*
|
|
10723
10739
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -10749,7 +10765,7 @@
|
|
|
10749
10765
|
|
|
10750
10766
|
## Key aspects
|
|
10751
10767
|
|
|
10752
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
10768
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
10753
10769
|
- The actual search engine tool usage is handled by the agent runtime
|
|
10754
10770
|
- Allows the agent to search for current information from the web
|
|
10755
10771
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -10774,20 +10790,39 @@
|
|
|
10774
10790
|
`);
|
|
10775
10791
|
}
|
|
10776
10792
|
applyToAgentModelRequirements(requirements, content) {
|
|
10777
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
10778
|
-
// Get existing metadata
|
|
10779
|
-
const existingMetadata = requirements.metadata || {};
|
|
10780
10793
|
// Get existing tools array or create new one
|
|
10781
|
-
const existingTools =
|
|
10782
|
-
// Add '
|
|
10783
|
-
const updatedTools = existingTools.
|
|
10784
|
-
|
|
10794
|
+
const existingTools = requirements.tools || [];
|
|
10795
|
+
// Add 'web_search' to tools if not already present
|
|
10796
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
10797
|
+
? existingTools
|
|
10798
|
+
: [
|
|
10799
|
+
...existingTools,
|
|
10800
|
+
{
|
|
10801
|
+
name: 'web_search',
|
|
10802
|
+
description: spaceTrim$1.spaceTrim(`
|
|
10803
|
+
Search the internet for information.
|
|
10804
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
10805
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
10806
|
+
`),
|
|
10807
|
+
parameters: {
|
|
10808
|
+
type: 'object',
|
|
10809
|
+
properties: {
|
|
10810
|
+
query: {
|
|
10811
|
+
type: 'string',
|
|
10812
|
+
description: 'The search query',
|
|
10813
|
+
},
|
|
10814
|
+
},
|
|
10815
|
+
required: ['query'],
|
|
10816
|
+
},
|
|
10817
|
+
},
|
|
10818
|
+
];
|
|
10819
|
+
// Return requirements with updated tools and metadata
|
|
10785
10820
|
return {
|
|
10786
10821
|
...requirements,
|
|
10822
|
+
tools: updatedTools,
|
|
10787
10823
|
metadata: {
|
|
10788
|
-
...
|
|
10789
|
-
|
|
10790
|
-
useSearchEngine: true,
|
|
10824
|
+
...requirements.metadata,
|
|
10825
|
+
useSearchEngine: content || true,
|
|
10791
10826
|
},
|
|
10792
10827
|
};
|
|
10793
10828
|
}
|
|
@@ -11957,6 +11992,10 @@
|
|
|
11957
11992
|
meta.image = spaceTrim__default["default"](commitment.content);
|
|
11958
11993
|
continue;
|
|
11959
11994
|
}
|
|
11995
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
11996
|
+
meta.description = spaceTrim__default["default"](commitment.content);
|
|
11997
|
+
continue;
|
|
11998
|
+
}
|
|
11960
11999
|
if (commitment.type === 'META COLOR') {
|
|
11961
12000
|
meta.color = normalizeSeparator(commitment.content);
|
|
11962
12001
|
continue;
|
|
@@ -14135,7 +14174,12 @@
|
|
|
14135
14174
|
* @see {@link ModelVariant}
|
|
14136
14175
|
* @public exported from `@promptbook/core`
|
|
14137
14176
|
*/
|
|
14138
|
-
const MODEL_VARIANTS = [
|
|
14177
|
+
const MODEL_VARIANTS = [
|
|
14178
|
+
'COMPLETION',
|
|
14179
|
+
'CHAT',
|
|
14180
|
+
'IMAGE_GENERATION',
|
|
14181
|
+
'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */,
|
|
14182
|
+
];
|
|
14139
14183
|
|
|
14140
14184
|
/**
|
|
14141
14185
|
* Parses the model command
|
|
@@ -17142,7 +17186,7 @@
|
|
|
17142
17186
|
* TODO: [🧠][💸] Maybe make some common abstraction `interceptLlmTools` and use here (or use javascript Proxy?)
|
|
17143
17187
|
* TODO: [🧠] Is there some meaningfull way how to test this util
|
|
17144
17188
|
* TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
|
|
17145
|
-
* TODO: [👷♂️]
|
|
17189
|
+
* TODO: [👷♂️] Write a comprehensive manual about the construction of LLM tools
|
|
17146
17190
|
*/
|
|
17147
17191
|
|
|
17148
17192
|
/**
|
|
@@ -18030,6 +18074,22 @@
|
|
|
18030
18074
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
18031
18075
|
*/
|
|
18032
18076
|
|
|
18077
|
+
/**
|
|
18078
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
18079
|
+
*
|
|
18080
|
+
* @private
|
|
18081
|
+
*/
|
|
18082
|
+
function mapToolsToOpenAi(tools) {
|
|
18083
|
+
return tools.map((tool) => ({
|
|
18084
|
+
type: 'function',
|
|
18085
|
+
function: {
|
|
18086
|
+
name: tool.name,
|
|
18087
|
+
description: tool.description,
|
|
18088
|
+
parameters: tool.parameters,
|
|
18089
|
+
},
|
|
18090
|
+
}));
|
|
18091
|
+
}
|
|
18092
|
+
|
|
18033
18093
|
/**
|
|
18034
18094
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
18035
18095
|
*
|
|
@@ -18227,6 +18287,9 @@
|
|
|
18227
18287
|
},
|
|
18228
18288
|
],
|
|
18229
18289
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
18290
|
+
tools: currentModelRequirements.tools === undefined
|
|
18291
|
+
? undefined
|
|
18292
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
18230
18293
|
};
|
|
18231
18294
|
const start = $getCurrentDate();
|
|
18232
18295
|
if (this.options.isVerbose) {
|
|
@@ -18371,6 +18434,7 @@
|
|
|
18371
18434
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
18372
18435
|
const rawRequest = {
|
|
18373
18436
|
...modelSettings,
|
|
18437
|
+
model: modelName,
|
|
18374
18438
|
prompt: rawPromptContent,
|
|
18375
18439
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
18376
18440
|
};
|
|
@@ -18625,8 +18689,8 @@
|
|
|
18625
18689
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
18626
18690
|
const rawRequest = {
|
|
18627
18691
|
...modelSettings,
|
|
18628
|
-
size: modelSettings.size || '1024x1024',
|
|
18629
18692
|
prompt: rawPromptContent,
|
|
18693
|
+
size: modelSettings.size || '1024x1024',
|
|
18630
18694
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
18631
18695
|
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
18632
18696
|
};
|
|
@@ -19028,6 +19092,7 @@
|
|
|
19028
19092
|
thread: {
|
|
19029
19093
|
messages: threadMessages,
|
|
19030
19094
|
},
|
|
19095
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
19031
19096
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
19032
19097
|
};
|
|
19033
19098
|
const start = $getCurrentDate();
|
|
@@ -19551,6 +19616,8 @@
|
|
|
19551
19616
|
modelRequirements: {
|
|
19552
19617
|
...chatPrompt.modelRequirements,
|
|
19553
19618
|
...modelRequirements,
|
|
19619
|
+
// Spread tools to convert readonly array to mutable
|
|
19620
|
+
tools: modelRequirements.tools ? [...modelRequirements.tools] : chatPrompt.modelRequirements.tools,
|
|
19554
19621
|
// Prepend agent system message to existing system message
|
|
19555
19622
|
systemMessage: modelRequirements.systemMessage +
|
|
19556
19623
|
(chatPrompt.modelRequirements.systemMessage
|