@promptbook/browser 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.
Files changed (24) hide show
  1. package/esm/index.es.js +64 -23
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  4. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
  5. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +5 -0
  6. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.tools.test.d.ts +1 -0
  7. package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
  8. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
  9. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  10. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  11. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  12. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  13. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  14. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
  15. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  16. package/esm/typings/src/search-engines/SearchResult.d.ts +4 -4
  17. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +1 -1
  18. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +1 -1
  19. package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
  20. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  21. package/esm/typings/src/version.d.ts +1 -1
  22. package/package.json +2 -2
  23. package/umd/index.umd.js +64 -23
  24. package/umd/index.umd.js.map +1 -1
@@ -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 ignored (similar to NOTE).
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 This will be ignored
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: [👷‍♂️] @@@ Manual about construction of llmTools
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: [👷‍♂️] @@@ Manual about construction of llmTools
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: [👷‍♂️] @@@ Manual about construction of llmTools
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: [👷‍♂️] @@@ Manual about construction of llmTools
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: [👷‍♂️] @@@ Manual about construction of llmTools
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: [👷‍♂️] @@@ Manual about construction of llmTools
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-10`).
18
+ * It follows semantic versioning (e.g., `0.104.0-11`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/browser",
3
- "version": "0.104.0-11",
3
+ "version": "0.104.0-12",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -94,7 +94,7 @@
94
94
  "module": "./esm/index.es.js",
95
95
  "typings": "./esm/typings/src/_packages/browser.index.d.ts",
96
96
  "peerDependencies": {
97
- "@promptbook/core": "0.104.0-11"
97
+ "@promptbook/core": "0.104.0-12"
98
98
  },
99
99
  "dependencies": {
100
100
  "crypto": "1.0.1",
package/umd/index.umd.js CHANGED
@@ -23,7 +23,7 @@
23
23
  * @generated
24
24
  * @see https://github.com/webgptorg/promptbook
25
25
  */
26
- const PROMPTBOOK_ENGINE_VERSION = '0.104.0-11';
26
+ const PROMPTBOOK_ENGINE_VERSION = '0.104.0-12';
27
27
  /**
28
28
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
29
29
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5720,19 +5720,37 @@
5720
5720
  `);
5721
5721
  }
5722
5722
  applyToAgentModelRequirements(requirements, content) {
5723
- // We simply mark that browser capability is enabled in metadata
5724
- // Get existing metadata
5725
- const existingMetadata = requirements.metadata || {};
5726
5723
  // Get existing tools array or create new one
5727
- const existingTools = existingMetadata.tools || [];
5728
- // Add 'browser' to tools if not already present
5729
- const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
5730
- // Return requirements with updated metadata
5724
+ const existingTools = requirements.tools || [];
5725
+ // Add 'web_browser' to tools if not already present
5726
+ const updatedTools = existingTools.some((tool) => tool.name === 'web_browser')
5727
+ ? existingTools
5728
+ : [
5729
+ ...existingTools,
5730
+ {
5731
+ name: 'web_browser',
5732
+ description: spaceTrim$1.spaceTrim(`
5733
+ A tool that can browse the web.
5734
+ Use this tool when you need to access specific websites or browse the internet.
5735
+ `),
5736
+ parameters: {
5737
+ type: 'object',
5738
+ properties: {
5739
+ url: {
5740
+ type: 'string',
5741
+ description: 'The URL to browse',
5742
+ },
5743
+ },
5744
+ required: ['url'],
5745
+ },
5746
+ },
5747
+ ];
5748
+ // Return requirements with updated tools and metadata
5731
5749
  return {
5732
5750
  ...requirements,
5751
+ tools: updatedTools,
5733
5752
  metadata: {
5734
- ...existingMetadata,
5735
- tools: updatedTools,
5753
+ ...requirements.metadata,
5736
5754
  useBrowser: true,
5737
5755
  },
5738
5756
  };
@@ -5825,13 +5843,13 @@
5825
5843
  * The `USE SEARCH ENGINE` commitment indicates that the agent should utilize a search engine tool
5826
5844
  * to access and retrieve up-to-date information from the internet when necessary.
5827
5845
  *
5828
- * The content following `USE SEARCH ENGINE` is ignored (similar to NOTE).
5846
+ * The content following `USE SEARCH ENGINE` is an arbitrary text that the agent should know (e.g. search scope or instructions).
5829
5847
  *
5830
5848
  * Example usage in agent source:
5831
5849
  *
5832
5850
  * ```book
5833
5851
  * USE SEARCH ENGINE
5834
- * USE SEARCH ENGINE This will be ignored
5852
+ * USE SEARCH ENGINE Hledej informace o Přemyslovcích
5835
5853
  * ```
5836
5854
  *
5837
5855
  * @private [🪔] Maybe export the commitments through some package
@@ -5863,7 +5881,7 @@
5863
5881
 
5864
5882
  ## Key aspects
5865
5883
 
5866
- - The content following \`USE SEARCH ENGINE\` is ignored (similar to NOTE)
5884
+ - The content following \`USE SEARCH ENGINE\` is an arbitrary text that the agent should know (e.g. search scope or instructions).
5867
5885
  - The actual search engine tool usage is handled by the agent runtime
5868
5886
  - Allows the agent to search for current information from the web
5869
5887
  - Useful for research tasks, finding facts, and accessing dynamic content
@@ -5888,20 +5906,39 @@
5888
5906
  `);
5889
5907
  }
5890
5908
  applyToAgentModelRequirements(requirements, content) {
5891
- // We simply mark that search engine capability is enabled in metadata
5892
- // Get existing metadata
5893
- const existingMetadata = requirements.metadata || {};
5894
5909
  // Get existing tools array or create new one
5895
- const existingTools = existingMetadata.tools || [];
5896
- // Add 'search-engine' to tools if not already present
5897
- const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
5898
- // Return requirements with updated metadata
5910
+ const existingTools = requirements.tools || [];
5911
+ // Add 'web_search' to tools if not already present
5912
+ const updatedTools = existingTools.some((tool) => tool.name === 'web_search')
5913
+ ? existingTools
5914
+ : [
5915
+ ...existingTools,
5916
+ {
5917
+ name: 'web_search',
5918
+ description: spaceTrim$1.spaceTrim(`
5919
+ Search the internet for information.
5920
+ Use this tool when you need to find up-to-date information or facts that you don't know.
5921
+ ${!content ? '' : `Search scope / instructions: ${content}`}
5922
+ `),
5923
+ parameters: {
5924
+ type: 'object',
5925
+ properties: {
5926
+ query: {
5927
+ type: 'string',
5928
+ description: 'The search query',
5929
+ },
5930
+ },
5931
+ required: ['query'],
5932
+ },
5933
+ },
5934
+ ];
5935
+ // Return requirements with updated tools and metadata
5899
5936
  return {
5900
5937
  ...requirements,
5938
+ tools: updatedTools,
5901
5939
  metadata: {
5902
- ...existingMetadata,
5903
- tools: updatedTools,
5904
- useSearchEngine: true,
5940
+ ...requirements.metadata,
5941
+ useSearchEngine: content || true,
5905
5942
  },
5906
5943
  };
5907
5944
  }
@@ -6366,6 +6403,10 @@
6366
6403
  meta.image = spaceTrim__default["default"](commitment.content);
6367
6404
  continue;
6368
6405
  }
6406
+ if (commitment.type === 'META DESCRIPTION') {
6407
+ meta.description = spaceTrim__default["default"](commitment.content);
6408
+ continue;
6409
+ }
6369
6410
  if (commitment.type === 'META COLOR') {
6370
6411
  meta.color = normalizeSeparator(commitment.content);
6371
6412
  continue;