@promptbook/components 0.104.0-10 β†’ 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 (40) hide show
  1. package/esm/index.es.js +159 -38
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  4. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +24 -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/book-components/Chat/types/ChatMessage.d.ts +2 -2
  8. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
  9. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +1 -1
  10. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +1 -1
  11. package/esm/typings/src/book-components/icons/AttachmentIcon.d.ts +1 -1
  12. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +1 -1
  13. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +1 -1
  14. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +1 -1
  15. package/esm/typings/src/book-components/icons/SaveIcon.d.ts +1 -1
  16. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -2
  17. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +0 -54
  18. package/esm/typings/src/commitments/META/META_DESCRIPTION.d.ts +41 -0
  19. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +2 -2
  20. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  21. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -1
  22. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/countUsage.d.ts +1 -1
  24. package/esm/typings/src/llm-providers/_common/utils/count-total-usage/limitTotalUsage.d.ts +1 -1
  25. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -1
  26. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
  28. package/esm/typings/src/llm-providers/openai/utils/mapToolsToOpenAi.d.ts +8 -0
  29. package/esm/typings/src/remote-server/ui/ServerApp.d.ts +1 -1
  30. package/esm/typings/src/search-engines/SearchEngine.d.ts +9 -0
  31. package/esm/typings/src/search-engines/SearchResult.d.ts +18 -0
  32. package/esm/typings/src/search-engines/bing/BingSearchEngine.d.ts +15 -0
  33. package/esm/typings/src/search-engines/dummy/DummySearchEngine.d.ts +15 -0
  34. package/esm/typings/src/types/LlmToolDefinition.d.ts +20 -0
  35. package/esm/typings/src/types/ModelRequirements.d.ts +13 -0
  36. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +3 -2
  37. package/esm/typings/src/version.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/umd/index.umd.js +159 -38
  40. package/umd/index.umd.js.map +1 -1
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-10';
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 = existingMetadata.tools || [];
6716
- // Add 'browser' to tools if not already present
6717
- const updatedTools = existingTools.includes('browser') ? existingTools : [...existingTools, 'browser'];
6718
- // Return requirements with updated metadata
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
- ...existingMetadata,
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 ignored (similar to NOTE).
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 This will be ignored
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 ignored (similar to NOTE)
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 = existingMetadata.tools || [];
6884
- // Add 'search-engine' to tools if not already present
6885
- const updatedTools = existingTools.includes('search-engine') ? existingTools : [...existingTools, 'search-engine'];
6886
- // Return requirements with updated metadata
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
- ...existingMetadata,
6891
- tools: updatedTools,
6892
- useSearchEngine: true,
6928
+ ...requirements.metadata,
6929
+ useSearchEngine: content || true,
6893
6930
  },
6894
6931
  };
6895
6932
  }
@@ -7312,7 +7349,57 @@
7312
7349
  }
7313
7350
  const meta = {};
7314
7351
  const links = [];
7352
+ const capabilities = [];
7315
7353
  for (const commitment of parseResult.commitments) {
7354
+ if (commitment.type === 'USE BROWSER') {
7355
+ capabilities.push({
7356
+ type: 'browser',
7357
+ label: 'Browser',
7358
+ iconName: 'Globe',
7359
+ });
7360
+ continue;
7361
+ }
7362
+ if (commitment.type === 'USE SEARCH ENGINE') {
7363
+ capabilities.push({
7364
+ type: 'search-engine',
7365
+ label: 'Search Internet',
7366
+ iconName: 'Search',
7367
+ });
7368
+ continue;
7369
+ }
7370
+ if (commitment.type === 'KNOWLEDGE') {
7371
+ const content = spaceTrim__default["default"](commitment.content).split('\n')[0] || '';
7372
+ let label = content;
7373
+ let iconName = 'Book';
7374
+ if (content.startsWith('http://') || content.startsWith('https://')) {
7375
+ try {
7376
+ const url = new URL(content);
7377
+ if (url.pathname.endsWith('.pdf')) {
7378
+ label = url.pathname.split('/').pop() || 'Document.pdf';
7379
+ iconName = 'FileText';
7380
+ }
7381
+ else {
7382
+ label = url.hostname.replace(/^www\./, '');
7383
+ }
7384
+ }
7385
+ catch (e) {
7386
+ // Invalid URL, treat as text
7387
+ }
7388
+ }
7389
+ else {
7390
+ // Text content - take first few words
7391
+ const words = content.split(/\s+/);
7392
+ if (words.length > 4) {
7393
+ label = words.slice(0, 4).join(' ') + '...';
7394
+ }
7395
+ }
7396
+ capabilities.push({
7397
+ type: 'knowledge',
7398
+ label,
7399
+ iconName,
7400
+ });
7401
+ continue;
7402
+ }
7316
7403
  if (commitment.type === 'META LINK') {
7317
7404
  const linkValue = spaceTrim__default["default"](commitment.content);
7318
7405
  links.push(linkValue);
@@ -7323,6 +7410,10 @@
7323
7410
  meta.image = spaceTrim__default["default"](commitment.content);
7324
7411
  continue;
7325
7412
  }
7413
+ if (commitment.type === 'META DESCRIPTION') {
7414
+ meta.description = spaceTrim__default["default"](commitment.content);
7415
+ continue;
7416
+ }
7326
7417
  if (commitment.type === 'META COLOR') {
7327
7418
  meta.color = normalizeSeparator(commitment.content);
7328
7419
  continue;
@@ -7359,6 +7450,7 @@
7359
7450
  meta,
7360
7451
  links,
7361
7452
  parameters,
7453
+ capabilities,
7362
7454
  };
7363
7455
  }
7364
7456
  /**
@@ -7720,7 +7812,7 @@
7720
7812
  styleInject(css_248z$6);
7721
7813
 
7722
7814
  /**
7723
- * @@@
7815
+ * Creates a showdown converter configured for chat markdown rendering
7724
7816
  *
7725
7817
  * @private utility of `MarkdownContent` component
7726
7818
  */
@@ -7768,13 +7860,13 @@
7768
7860
  });
7769
7861
  }
7770
7862
  /**
7771
- * @@@
7863
+ * Pre-configured showdown converter for chat markdown
7772
7864
  *
7773
7865
  * @private utility of `MarkdownContent` component
7774
7866
  */
7775
7867
  const chatMarkdownConverter = createChatMarkdownConverter();
7776
7868
  /**
7777
- * @@@
7869
+ * Renders math expressions in markdown using KaTeX
7778
7870
  *
7779
7871
  * @private utility of `MarkdownContent` component
7780
7872
  */
@@ -7971,7 +8063,7 @@
7971
8063
  }
7972
8064
 
7973
8065
  /**
7974
- * @@@
8066
+ * Renders an about icon
7975
8067
  *
7976
8068
  * @private internal subcomponent used by various components
7977
8069
  */
@@ -7981,7 +8073,7 @@
7981
8073
  }
7982
8074
 
7983
8075
  /**
7984
- * @@@
8076
+ * Renders an attachment icon
7985
8077
  *
7986
8078
  * @public exported from `@promptbook/components`
7987
8079
  */
@@ -7990,7 +8082,7 @@
7990
8082
  }
7991
8083
 
7992
8084
  /**
7993
- * @@@
8085
+ * Renders a camera icon
7994
8086
  *
7995
8087
  * @public exported from `@promptbook/components`
7996
8088
  */
@@ -7999,7 +8091,7 @@
7999
8091
  }
8000
8092
 
8001
8093
  /**
8002
- * @@@
8094
+ * Renders a download icon
8003
8095
  *
8004
8096
  * @private internal subcomponent used by various components
8005
8097
  */
@@ -8093,7 +8185,7 @@
8093
8185
  styleInject(css_248z$5);
8094
8186
 
8095
8187
  /**
8096
- * @@@
8188
+ * An animated hamburger menu button component.
8097
8189
  *
8098
8190
  * @private Internal component
8099
8191
  */
@@ -8106,7 +8198,7 @@
8106
8198
  styleInject(css_248z$4);
8107
8199
 
8108
8200
  /**
8109
- * @@@
8201
+ * A dropdown menu component that displays a list of actions triggered by a hamburger menu button.
8110
8202
  *
8111
8203
  * @private internal subcomponent used by various components
8112
8204
  */
@@ -9029,7 +9121,7 @@
9029
9121
  const ResetIcon = () => (jsxRuntime.jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntime.jsx("path", { d: "M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4L17.65,6.35z" }) }));
9030
9122
 
9031
9123
  /**
9032
- * @@@
9124
+ * Renders a save icon
9033
9125
  *
9034
9126
  * @public exported from `@promptbook/components`
9035
9127
  */
@@ -11382,7 +11474,7 @@
11382
11474
  }
11383
11475
  /**
11384
11476
  * TODO: [πŸ™†] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
11385
- * TODO: [πŸ‘·β€β™‚οΈ] @@@ Manual about construction of llmTools
11477
+ * TODO: [πŸ‘·β€β™‚οΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
11386
11478
  */
11387
11479
 
11388
11480
  /**
@@ -11399,7 +11491,7 @@
11399
11491
  }
11400
11492
  /**
11401
11493
  * TODO: [πŸ™†] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
11402
- * TODO: [πŸ‘·β€β™‚οΈ] @@@ Manual about construction of llmTools
11494
+ * TODO: [πŸ‘·β€β™‚οΈ] Write a comprehensive manual about how to construct and use LLM execution tools in Promptbook
11403
11495
  */
11404
11496
 
11405
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"}];
@@ -12471,7 +12563,7 @@
12471
12563
  * TODO: [🧠] Is there some meaningfull way how to test this util
12472
12564
  * TODO: [🧠][🌯] Maybe a way how to hide ability to `get totalUsage`
12473
12565
  * > const [llmToolsWithUsage,getUsage] = countTotalUsage(llmTools);
12474
- * TODO: [πŸ‘·β€β™‚οΈ] @@@ Manual about construction of llmTools
12566
+ * TODO: [πŸ‘·β€β™‚οΈ] Write a comprehensive manual explaining the construction and usage of LLM tools in the Promptbook ecosystem
12475
12567
  */
12476
12568
 
12477
12569
  /**
@@ -16169,6 +16261,22 @@
16169
16261
  * TODO: [🀝] DRY Maybe some common abstraction between `computeOpenAiUsage` and `computeAnthropicClaudeUsage`
16170
16262
  */
16171
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
+
16172
16280
  /**
16173
16281
  * Parses an OpenAI error message to identify which parameter is unsupported
16174
16282
  *
@@ -16366,6 +16474,9 @@
16366
16474
  },
16367
16475
  ],
16368
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),
16369
16480
  };
16370
16481
  const start = $getCurrentDate();
16371
16482
  if (this.options.isVerbose) {
@@ -16510,6 +16621,7 @@
16510
16621
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
16511
16622
  const rawRequest = {
16512
16623
  ...modelSettings,
16624
+ model: modelName,
16513
16625
  prompt: rawPromptContent,
16514
16626
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
16515
16627
  };
@@ -16764,8 +16876,8 @@
16764
16876
  const rawPromptContent = templateParameters(content, { ...parameters, modelName });
16765
16877
  const rawRequest = {
16766
16878
  ...modelSettings,
16767
- size: modelSettings.size || '1024x1024',
16768
16879
  prompt: rawPromptContent,
16880
+ size: modelSettings.size || '1024x1024',
16769
16881
  user: (_a = this.options.userId) === null || _a === void 0 ? void 0 : _a.toString(),
16770
16882
  response_format: 'url', // TODO: [🧠] Maybe allow b64_json
16771
16883
  };
@@ -17167,6 +17279,7 @@
17167
17279
  thread: {
17168
17280
  messages: threadMessages,
17169
17281
  },
17282
+ tools: modelRequirements.tools === undefined ? undefined : mapToolsToOpenAi(modelRequirements.tools),
17170
17283
  // <- TODO: Add user identification here> user: this.options.user,
17171
17284
  };
17172
17285
  const start = $getCurrentDate();
@@ -17690,6 +17803,8 @@
17690
17803
  modelRequirements: {
17691
17804
  ...chatPrompt.modelRequirements,
17692
17805
  ...modelRequirements,
17806
+ // Spread tools to convert readonly array to mutable
17807
+ tools: modelRequirements.tools ? [...modelRequirements.tools] : chatPrompt.modelRequirements.tools,
17693
17808
  // Prepend agent system message to existing system message
17694
17809
  systemMessage: modelRequirements.systemMessage +
17695
17810
  (chatPrompt.modelRequirements.systemMessage
@@ -17783,6 +17898,11 @@
17783
17898
  * Links found in the agent source
17784
17899
  */
17785
17900
  this.links = [];
17901
+ /**
17902
+ * Capabilities of the agent
17903
+ * This is parsed from commitments like USE BROWSER, USE SEARCH ENGINE, KNOWLEDGE, etc.
17904
+ */
17905
+ this.capabilities = [];
17786
17906
  /**
17787
17907
  * Metadata like image or color
17788
17908
  */
@@ -17792,11 +17912,12 @@
17792
17912
  this.agentSource = agentSource;
17793
17913
  this.agentSource.subscribe((source) => {
17794
17914
  this.updateAgentSource(source);
17795
- const { agentName, personaDescription, initialMessage, links, meta } = parseAgentSource(source);
17915
+ const { agentName, personaDescription, initialMessage, links, meta, capabilities } = parseAgentSource(source);
17796
17916
  this._agentName = agentName;
17797
17917
  this.personaDescription = personaDescription;
17798
17918
  this.initialMessage = initialMessage;
17799
17919
  this.links = links;
17920
+ this.capabilities = capabilities;
17800
17921
  this.meta = { ...this.meta, ...meta };
17801
17922
  });
17802
17923
  }