@promptbook/components 0.104.0-11 → 0.104.0-12
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 +90 -26
- 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/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/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/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +90 -26
- 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 {};
|
|
@@ -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
|
|
@@ -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-11`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* @generated
|
|
31
31
|
* @see https://github.com/webgptorg/promptbook
|
|
32
32
|
*/
|
|
33
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-
|
|
33
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
|
|
34
34
|
/**
|
|
35
35
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
36
36
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -6708,19 +6708,37 @@
|
|
|
6708
6708
|
`);
|
|
6709
6709
|
}
|
|
6710
6710
|
applyToAgentModelRequirements(requirements, content) {
|
|
6711
|
-
// We simply mark that browser capability is enabled in metadata
|
|
6712
|
-
// Get existing metadata
|
|
6713
|
-
const existingMetadata = requirements.metadata || {};
|
|
6714
6711
|
// Get existing tools array or create new one
|
|
6715
|
-
const existingTools =
|
|
6716
|
-
// Add '
|
|
6717
|
-
const updatedTools = existingTools.
|
|
6718
|
-
|
|
6712
|
+
const existingTools = requirements.tools || [];
|
|
6713
|
+
// Add 'web_browser' to tools if not already present
|
|
6714
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
|
|
6715
|
+
? existingTools
|
|
6716
|
+
: [
|
|
6717
|
+
...existingTools,
|
|
6718
|
+
{
|
|
6719
|
+
name: 'web_browser',
|
|
6720
|
+
description: spaceTrim$1.spaceTrim(`
|
|
6721
|
+
A tool that can browse the web.
|
|
6722
|
+
Use this tool when you need to access specific websites or browse the internet.
|
|
6723
|
+
`),
|
|
6724
|
+
parameters: {
|
|
6725
|
+
type: 'object',
|
|
6726
|
+
properties: {
|
|
6727
|
+
url: {
|
|
6728
|
+
type: 'string',
|
|
6729
|
+
description: 'The URL to browse',
|
|
6730
|
+
},
|
|
6731
|
+
},
|
|
6732
|
+
required: ['url'],
|
|
6733
|
+
},
|
|
6734
|
+
},
|
|
6735
|
+
];
|
|
6736
|
+
// Return requirements with updated tools and metadata
|
|
6719
6737
|
return {
|
|
6720
6738
|
...requirements,
|
|
6739
|
+
tools: updatedTools,
|
|
6721
6740
|
metadata: {
|
|
6722
|
-
...
|
|
6723
|
-
tools: updatedTools,
|
|
6741
|
+
...requirements.metadata,
|
|
6724
6742
|
useBrowser: true,
|
|
6725
6743
|
},
|
|
6726
6744
|
};
|
|
@@ -6813,13 +6831,13 @@
|
|
|
6813
6831
|
* The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
|
|
6814
6832
|
* to access and retrieve up-to-date information from the internet when necessary.
|
|
6815
6833
|
*
|
|
6816
|
-
* The content following `USE SEARCH ENGINE` is
|
|
6834
|
+
* The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6817
6835
|
*
|
|
6818
6836
|
* Example usage in agent source:
|
|
6819
6837
|
*
|
|
6820
6838
|
* ```book
|
|
6821
6839
|
* USE SEARCH ENGINE
|
|
6822
|
-
* USE SEARCH ENGINE
|
|
6840
|
+
* USE SEARCH ENGINE Hledej informace o Přemyslovcích
|
|
6823
6841
|
* ```
|
|
6824
6842
|
*
|
|
6825
6843
|
* @private [🪔] Maybe export the commitments through some package
|
|
@@ -6851,7 +6869,7 @@
|
|
|
6851
6869
|
|
|
6852
6870
|
## Key aspects
|
|
6853
6871
|
|
|
6854
|
-
- The content following \`USE SEARCH ENGINE\` is
|
|
6872
|
+
- The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
|
|
6855
6873
|
- The actual search engine tool usage is handled by the agent runtime
|
|
6856
6874
|
- Allows the agent to search for current information from the web
|
|
6857
6875
|
- Useful for research tasks, finding facts, and accessing dynamic content
|
|
@@ -6876,20 +6894,39 @@
|
|
|
6876
6894
|
`);
|
|
6877
6895
|
}
|
|
6878
6896
|
applyToAgentModelRequirements(requirements, content) {
|
|
6879
|
-
// We simply mark that search engine capability is enabled in metadata
|
|
6880
|
-
// Get existing metadata
|
|
6881
|
-
const existingMetadata = requirements.metadata || {};
|
|
6882
6897
|
// Get existing tools array or create new one
|
|
6883
|
-
const existingTools =
|
|
6884
|
-
// Add '
|
|
6885
|
-
const updatedTools = existingTools.
|
|
6886
|
-
|
|
6898
|
+
const existingTools = requirements.tools || [];
|
|
6899
|
+
// Add 'web_search' to tools if not already present
|
|
6900
|
+
const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
|
|
6901
|
+
? existingTools
|
|
6902
|
+
: [
|
|
6903
|
+
...existingTools,
|
|
6904
|
+
{
|
|
6905
|
+
name: 'web_search',
|
|
6906
|
+
description: spaceTrim$1.spaceTrim(`
|
|
6907
|
+
Search the internet for information.
|
|
6908
|
+
Use this tool when you need to find up-to-date information or facts that you don't know.
|
|
6909
|
+
${!content ? '' : `Search scope / instructions: ${content}`}
|
|
6910
|
+
`),
|
|
6911
|
+
parameters: {
|
|
6912
|
+
type: 'object',
|
|
6913
|
+
properties: {
|
|
6914
|
+
query: {
|
|
6915
|
+
type: 'string',
|
|
6916
|
+
description: 'The search query',
|
|
6917
|
+
},
|
|
6918
|
+
},
|
|
6919
|
+
required: ['query'],
|
|
6920
|
+
},
|
|
6921
|
+
},
|
|
6922
|
+
];
|
|
6923
|
+
// Return requirements with updated tools and metadata
|
|
6887
6924
|
return {
|
|
6888
6925
|
...requirements,
|
|
6926
|
+
tools: updatedTools,
|
|
6889
6927
|
metadata: {
|
|
6890
|
-
...
|
|
6891
|
-
|
|
6892
|
-
useSearchEngine: true,
|
|
6928
|
+
...requirements.metadata,
|
|
6929
|
+
useSearchEngine: content || true,
|
|
6893
6930
|
},
|
|
6894
6931
|
};
|
|
6895
6932
|
}
|
|
@@ -7373,6 +7410,10 @@
|
|
|
7373
7410
|
meta.image = spaceTrim__default["default"](commitment.content);
|
|
7374
7411
|
continue;
|
|
7375
7412
|
}
|
|
7413
|
+
if (commitment.type === 'META DESCRIPTION') {
|
|
7414
|
+
meta.description = spaceTrim__default["default"](commitment.content);
|
|
7415
|
+
continue;
|
|
7416
|
+
}
|
|
7376
7417
|
if (commitment.type === 'META COLOR') {
|
|
7377
7418
|
meta.color = normalizeSeparator(commitment.content);
|
|
7378
7419
|
continue;
|
|
@@ -11433,7 +11474,7 @@
|
|
|
11433
11474
|
}
|
|
11434
11475
|
/**
|
|
11435
11476
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11436
|
-
* TODO: [👷♂️]
|
|
11477
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11437
11478
|
*/
|
|
11438
11479
|
|
|
11439
11480
|
/**
|
|
@@ -11450,7 +11491,7 @@
|
|
|
11450
11491
|
}
|
|
11451
11492
|
/**
|
|
11452
11493
|
* TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
|
|
11453
|
-
* TODO: [👷♂️]
|
|
11494
|
+
* TODO: [👷♂️] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
|
|
11454
11495
|
*/
|
|
11455
11496
|
|
|
11456
11497
|
var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
|
|
@@ -16220,6 +16261,22 @@
|
|
|
16220
16261
|
* TODO: [🤝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
|
|
16221
16262
|
*/
|
|
16222
16263
|
|
|
16264
|
+
/**
|
|
16265
|
+
* Maps Promptbook tools to OpenAI tools.
|
|
16266
|
+
*
|
|
16267
|
+
* @private
|
|
16268
|
+
*/
|
|
16269
|
+
function mapToolsToOpenAi(tools) {
|
|
16270
|
+
return tools.map((tool) => ({
|
|
16271
|
+
type: 'function',
|
|
16272
|
+
function: {
|
|
16273
|
+
name: tool.name,
|
|
16274
|
+
description: tool.description,
|
|
16275
|
+
parameters: tool.parameters,
|
|
16276
|
+
},
|
|
16277
|
+
}));
|
|
16278
|
+
}
|
|
16279
|
+
|
|
16223
16280
|
/**
|
|
16224
16281
|
* Parses an OpenAI error message to identify which parameter is unsupported
|
|
16225
16282
|
*
|
|
@@ -16417,6 +16474,9 @@
|
|
|
16417
16474
|
},
|
|
16418
16475
|
],
|
|
16419
16476
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16477
|
+
tools: currentModelRequirements.tools === undefined
|
|
16478
|
+
? undefined
|
|
16479
|
+
: mapToolsToOpenAi(currentModelRequirements.tools),
|
|
16420
16480
|
};
|
|
16421
16481
|
const start = $getCurrentDate();
|
|
16422
16482
|
if (this.options.isVerbose) {
|
|
@@ -16561,6 +16621,7 @@
|
|
|
16561
16621
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16562
16622
|
const rawRequest = {
|
|
16563
16623
|
...modelSettings,
|
|
16624
|
+
model: modelName,
|
|
16564
16625
|
prompt: rawPromptContent,
|
|
16565
16626
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16566
16627
|
};
|
|
@@ -16815,8 +16876,8 @@
|
|
|
16815
16876
|
const rawPromptContent = templateParameters(content, { ...parameters, modelName });
|
|
16816
16877
|
const rawRequest = {
|
|
16817
16878
|
...modelSettings,
|
|
16818
|
-
size: modelSettings.size || '1024x1024',
|
|
16819
16879
|
prompt: rawPromptContent,
|
|
16880
|
+
size: modelSettings.size || '1024x1024',
|
|
16820
16881
|
user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
16821
16882
|
response_format: 'url', // TODO: [🧠] Maybe allow b64_json
|
|
16822
16883
|
};
|
|
@@ -17218,6 +17279,7 @@
|
|
|
17218
17279
|
thread: {
|
|
17219
17280
|
messages: threadMessages,
|
|
17220
17281
|
},
|
|
17282
|
+
tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
|
|
17221
17283
|
// <- TODO: Add user identification here> user: this.options.user,
|
|
17222
17284
|
};
|
|
17223
17285
|
const start = $getCurrentDate();
|
|
@@ -17741,6 +17803,8 @@
|
|
|
17741
17803
|
modelRequirements: {
|
|
17742
17804
|
...chatPrompt.modelRequirements,
|
|
17743
17805
|
...modelRequirements,
|
|
17806
|
+
// Spread tools to convert readonly array to mutable
|
|
17807
|
+
tools: modelRequirements.tools ? [...modelRequirements.tools] : chatPrompt.modelRequirements.tools,
|
|
17744
17808
|
// Prepend agent system message to existing system message
|
|
17745
17809
|
systemMessage: modelRequirements.systemMessage +
|
|
17746
17810
|
(chatPrompt.modelRequirements.systemMessage
|