@promptbook/javascript 0.105.0-12 → 0.105.0-15

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
@@ -3,6 +3,7 @@ import 'path';
3
3
  import { randomBytes } from 'crypto';
4
4
  import 'crypto-js';
5
5
  import 'crypto-js/enc-hex';
6
+ import moment from 'moment';
6
7
 
7
8
  // ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
8
9
  /**
@@ -18,7 +19,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
18
19
  * @generated
19
20
  * @see https://github.com/webgptorg/promptbook
20
21
  */
21
- const PROMPTBOOK_ENGINE_VERSION = '0.105.0-12';
22
+ const PROMPTBOOK_ENGINE_VERSION = '0.105.0-15';
22
23
  /**
23
24
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
24
25
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -5838,6 +5839,25 @@ class SerpSearchEngine {
5838
5839
  }
5839
5840
  }
5840
5841
 
5842
+ /**
5843
+ * @@@
5844
+ *
5845
+ * @private utility for commitments
5846
+ */
5847
+ function formatOptionalInstructionBlock(label, content) {
5848
+ const trimmedContent = spaceTrim$1(content);
5849
+ if (!trimmedContent) {
5850
+ return '';
5851
+ }
5852
+ return spaceTrim$1((block) => `
5853
+ - ${label}:
5854
+ ${block(trimmedContent
5855
+ .split('\n')
5856
+ .map((line) => `- ${line}`)
5857
+ .join('\n'))}
5858
+ `);
5859
+ }
5860
+
5841
5861
  /**
5842
5862
  * USE SEARCH ENGINE commitment definition
5843
5863
  *
@@ -5859,6 +5879,9 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
5859
5879
  constructor() {
5860
5880
  super('USE SEARCH ENGINE', ['USE SEARCH']);
5861
5881
  }
5882
+ get requiresContent() {
5883
+ return false;
5884
+ }
5862
5885
  /**
5863
5886
  * Short one-line description of USE SEARCH ENGINE.
5864
5887
  */
@@ -5907,6 +5930,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
5907
5930
  `);
5908
5931
  }
5909
5932
  applyToAgentModelRequirements(requirements, content) {
5933
+ const extraInstructions = formatOptionalInstructionBlock('Search instructions', content);
5910
5934
  // Get existing tools array or create new one
5911
5935
  const existingTools = requirements.tools || [];
5912
5936
  // Add 'web_search' to tools if not already present
@@ -5965,13 +5989,14 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
5965
5989
  ...requirements.metadata,
5966
5990
  useSearchEngine: content || true,
5967
5991
  },
5968
- }, spaceTrim$1(`
5969
- Tools:
5970
- You have access to the web search engine via the tool "web_search".
5971
- Use it to find up-to-date information or facts that you don't know.
5972
- When you need to know some information from the internet, use the tool provided to you.
5973
- Do not make up information when you can search for it.
5974
- Do not tell the user you cannot search for information, YOU CAN.
5992
+ }, spaceTrim$1((block) => `
5993
+ Tool:
5994
+ - You have access to the web search engine via the tool "web_search".
5995
+ - Use it to find up-to-date information or facts that you don't know.
5996
+ - When you need to know some information from the internet, use the tool provided to you.
5997
+ - Do not make up information when you can search for it.
5998
+ - Do not tell the user you cannot search for information, YOU CAN.
5999
+ ${block(extraInstructions)}
5975
6000
  `));
5976
6001
  }
5977
6002
  /**
@@ -6023,6 +6048,7 @@ class UseSearchEngineCommitmentDefinition extends BaseCommitmentDefinition {
6023
6048
  *
6024
6049
  * ```book
6025
6050
  * USE TIME
6051
+ * USE TIME Prefer the user's local timezone.
6026
6052
  * ```
6027
6053
  *
6028
6054
  * @private [🪔] Maybe export the commitments through some package
@@ -6031,6 +6057,9 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
6031
6057
  constructor() {
6032
6058
  super('USE TIME', ['CURRENT TIME', 'TIME', 'DATE']);
6033
6059
  }
6060
+ get requiresContent() {
6061
+ return false;
6062
+ }
6034
6063
  /**
6035
6064
  * Short one-line description of USE TIME.
6036
6065
  */
@@ -6057,6 +6086,7 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
6057
6086
  - This tool won't receive any input.
6058
6087
  - It outputs the current date and time as an ISO 8601 string.
6059
6088
  - Allows the agent to answer questions about the current time or date.
6089
+ - The content following \`USE TIME\` is an arbitrary text that the agent should know (e.g. timezone preference).
6060
6090
 
6061
6091
  ## Examples
6062
6092
 
@@ -6066,9 +6096,17 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
6066
6096
  PERSONA You are a helpful assistant who knows the current time.
6067
6097
  USE TIME
6068
6098
  \`\`\`
6099
+
6100
+ \`\`\`book
6101
+ Travel Assistant
6102
+
6103
+ PERSONA You help travelers with planning.
6104
+ USE TIME Prefer the user's local timezone.
6105
+ \`\`\`
6069
6106
  `);
6070
6107
  }
6071
6108
  applyToAgentModelRequirements(requirements, content) {
6109
+ const extraInstructions = formatOptionalInstructionBlock('Time instructions', content);
6072
6110
  // Get existing tools array or create new one
6073
6111
  const existingTools = requirements.tools || [];
6074
6112
  // Add 'get_current_time' to tools if not already present
@@ -6099,13 +6137,12 @@ class UseTimeCommitmentDefinition extends BaseCommitmentDefinition {
6099
6137
  metadata: {
6100
6138
  ...requirements.metadata,
6101
6139
  },
6102
- }, spaceTrim$1(`
6103
- Tool:
6104
- You have access to the current date and time via the tool "get_current_time".
6105
- Use it to answer questions about the current date and time.
6106
- When you need to know the current date or time, use the tool provided to you.
6107
- Do not make up the current date or time; always use the tool to get accurate information.
6108
- `));
6140
+ }, spaceTrim$1((block) => `
6141
+ Time and date context:
6142
+ - It is ${moment().format('MMMM YYYY')} now.
6143
+ - If you need more precise current time information, use the tool "get_current_time".
6144
+ ${block(extraInstructions)}
6145
+ `));
6109
6146
  }
6110
6147
  /**
6111
6148
  * Gets human-readable titles for tool functions provided by this commitment.