@promptbook/editable 0.101.0-9 → 0.101.0

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 (88) hide show
  1. package/README.md +0 -4
  2. package/esm/index.es.js +1 -1
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/components.index.d.ts +14 -0
  5. package/esm/typings/src/_packages/core.index.d.ts +12 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +8 -0
  7. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +11 -4
  8. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +3 -0
  9. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirements.d.ts +4 -22
  10. package/esm/typings/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.d.ts +1 -26
  11. package/esm/typings/src/book-2.0/commitments/ACTION/ACTION.d.ts +0 -12
  12. package/esm/typings/src/book-2.0/commitments/DELETE/DELETE.d.ts +0 -24
  13. package/esm/typings/src/book-2.0/commitments/FORMAT/FORMAT.d.ts +0 -12
  14. package/esm/typings/src/book-2.0/commitments/GOAL/GOAL.d.ts +0 -12
  15. package/esm/typings/src/book-2.0/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -6
  16. package/esm/typings/src/book-2.0/commitments/MEMORY/MEMORY.d.ts +0 -12
  17. package/esm/typings/src/book-2.0/commitments/MESSAGE/MESSAGE.d.ts +0 -12
  18. package/esm/typings/src/book-2.0/commitments/META/META.d.ts +0 -6
  19. package/esm/typings/src/book-2.0/commitments/META_IMAGE/META_IMAGE.d.ts +0 -6
  20. package/esm/typings/src/book-2.0/commitments/META_LINK/META_LINK.d.ts +0 -6
  21. package/esm/typings/src/book-2.0/commitments/MODEL/MODEL.d.ts +23 -14
  22. package/esm/typings/src/book-2.0/commitments/NOTE/NOTE.d.ts +2 -14
  23. package/esm/typings/src/book-2.0/commitments/PERSONA/PERSONA.d.ts +0 -12
  24. package/esm/typings/src/book-2.0/commitments/RULE/RULE.d.ts +0 -12
  25. package/esm/typings/src/book-2.0/commitments/SAMPLE/SAMPLE.d.ts +0 -12
  26. package/esm/typings/src/book-2.0/commitments/SCENARIO/SCENARIO.d.ts +0 -12
  27. package/esm/typings/src/book-2.0/commitments/STYLE/STYLE.d.ts +0 -12
  28. package/esm/typings/src/book-2.0/commitments/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  29. package/esm/typings/src/book-2.0/commitments/index.d.ts +1 -1
  30. package/esm/typings/src/book-2.0/utils/generatePlaceholderAgentProfileImageUrl.d.ts +3 -0
  31. package/esm/typings/src/book-components/AvatarProfile/AvatarChip/AvatarChip.d.ts +5 -2
  32. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +3 -0
  33. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/MockedChat.d.ts +18 -1
  34. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +8 -0
  35. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +2 -15
  36. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +9 -0
  37. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +13 -0
  38. package/esm/typings/src/book-components/Chat/hooks/index.d.ts +2 -0
  39. package/esm/typings/src/book-components/Chat/hooks/useChatAutoScroll.d.ts +41 -0
  40. package/esm/typings/src/book-components/Chat/hooks/useSendMessageToLlmChat.d.ts +44 -0
  41. package/esm/typings/src/book-components/Chat/utils/parseMessageButtons.d.ts +22 -0
  42. package/esm/typings/src/book-components/icons/PauseIcon.d.ts +8 -0
  43. package/esm/typings/src/book-components/icons/PlayIcon.d.ts +8 -0
  44. package/esm/typings/src/execution/PromptResult.d.ts +2 -4
  45. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +1 -2
  46. package/esm/typings/src/execution/createPipelineExecutor/getKnowledgeForTask.d.ts +1 -3
  47. package/esm/typings/src/formats/csv/CsvFormatError.d.ts +1 -1
  48. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForTestingAndScriptsAndPlayground.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +1 -2
  51. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +8 -2
  52. package/esm/typings/src/llm-providers/_common/utils/removeUnsupportedModelRequirements.d.ts +25 -0
  53. package/esm/typings/src/llm-providers/_multiple/MultipleLlmExecutionTools.d.ts +7 -18
  54. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +11 -0
  55. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +2 -1
  56. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +58 -0
  57. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +29 -0
  58. package/esm/typings/src/llm-providers/agent/playground/playground.d.ts +8 -0
  59. package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +11 -0
  60. package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +13 -0
  61. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -8
  62. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +4 -5
  63. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -0
  64. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +4 -10
  65. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +4 -6
  66. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +3 -3
  67. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +16 -8
  68. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -8
  69. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +5 -14
  70. package/esm/typings/src/personas/preparePersona.d.ts +1 -0
  71. package/esm/typings/src/remote-server/openapi-types.d.ts +31 -31
  72. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -2
  73. package/esm/typings/src/types/ModelRequirements.d.ts +2 -4
  74. package/esm/typings/src/utils/color/utils/colorSaturation.d.ts +1 -1
  75. package/esm/typings/src/utils/editable/edit-pipeline-string/addPipelineCommand.d.ts +1 -1
  76. package/esm/typings/src/utils/markdown/humanizeAiText.d.ts +0 -1
  77. package/esm/typings/src/utils/markdown/promptbookifyAiText.d.ts +2 -2
  78. package/esm/typings/src/version.d.ts +1 -1
  79. package/package.json +2 -2
  80. package/umd/index.umd.js +1 -1
  81. package/umd/index.umd.js.map +1 -1
  82. package/esm/typings/src/book-2.0/utils/extractAgentMetadata.d.ts +0 -17
  83. package/esm/typings/src/book-2.0/utils/extractProfileImageFromSystemMessage.d.ts +0 -12
  84. package/esm/typings/src/book-components/Chat/examples/ChatMarkdownDemo.d.ts +0 -16
  85. package/esm/typings/src/expectations/drafts/isDomainNameFree.d.ts +0 -10
  86. package/esm/typings/src/expectations/drafts/isGithubNameFree.d.ts +0 -10
  87. package/esm/typings/src/llm-providers/_common/profiles/llmProviderProfiles.d.ts +0 -81
  88. /package/esm/typings/src/llm-providers/_common/{profiles/test/llmProviderProfiles.test.d.ts → utils/removeUnsupportedModelRequirements.test.d.ts} +0 -0
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Configuration for the auto-scroll behavior
3
+ */
4
+ export type ChatAutoScrollConfig = {
5
+ /**
6
+ * Threshold in pixels from bottom to consider as "at bottom"
7
+ * @default 100
8
+ */
9
+ bottomThreshold?: number;
10
+ /**
11
+ * Whether to use smooth scrolling
12
+ * @default true
13
+ */
14
+ smoothScroll?: boolean;
15
+ /**
16
+ * Delay before checking scroll position after new messages (in milliseconds)
17
+ * @default 100
18
+ */
19
+ scrollCheckDelay?: number;
20
+ };
21
+ /**
22
+ * Hook for managing auto-scroll behavior in chat components
23
+ *
24
+ * This hook provides:
25
+ * - Automatic scrolling to bottom when new messages arrive (if user is already at bottom)
26
+ * - Detection of when user scrolls away from bottom
27
+ * - Scroll-to-bottom functionality with smooth animation
28
+ * - Mobile-optimized scrolling behavior
29
+ *
30
+ * @public exported from `@promptbook/components`
31
+ */
32
+ export declare function useChatAutoScroll(config?: ChatAutoScrollConfig): {
33
+ isAutoScrolling: boolean;
34
+ chatMessagesRef: (element: HTMLDivElement | null) => void;
35
+ handleScroll: (event: React.UIEvent<HTMLDivElement>) => void;
36
+ handleMessagesChange: () => void;
37
+ scrollToBottom: () => void;
38
+ enableAutoScroll: () => void;
39
+ disableAutoScroll: () => void;
40
+ isMobile: boolean;
41
+ };
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Function type for sending a message to LlmChat.
3
+ *
4
+ * Implementation detail: The returned function is "attachable".
5
+ * LlmChat will call the internal `_attach` method (if present) to bind
6
+ * its real message handler. Messages sent before attachment are queued
7
+ * and flushed after attachment.
8
+ *
9
+ * @public exported from `@promptbook/components`
10
+ */
11
+ export type SendMessageToLlmChatFunction = {
12
+ /**
13
+ * Send a message to the bound LlmChat instance (or queue it until attached).
14
+ */
15
+ (message: string): void;
16
+ /**
17
+ * Internal method used by the <LlmChat/> component to attach its handler.
18
+ * Not intended for consumer usage.
19
+ *
20
+ * @internal
21
+ */
22
+ _attach?: (handler: (message: string) => Promise<void> | void) => void;
23
+ };
24
+ /**
25
+ * Hook to create a sendMessage function for an <LlmChat/> component WITHOUT needing any React Context.
26
+ *
27
+ * Usage pattern:
28
+ * ```tsx
29
+ * const sendMessage = useSendMessageToLlmChat();
30
+ * return (
31
+ * <>
32
+ * <button onClick={() => sendMessage('Hello!')}>Hello</button>
33
+ * <LlmChat llmTools={llmTools} sendMessage={sendMessage} />
34
+ * </>
35
+ * );
36
+ * ```
37
+ *
38
+ * - No provider wrapping needed.
39
+ * - Safe to call before the <LlmChat/> mounts (messages will be queued).
40
+ * - Keeps DRY by letting <LlmChat/> reuse its internal `handleMessage` logic.
41
+ *
42
+ * @public exported from `@promptbook/components`
43
+ */
44
+ export declare function useSendMessageToLlmChat(): SendMessageToLlmChatFunction;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Represents a parsed message button from markdown
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export type MessageButton = {
7
+ text: string;
8
+ message: string;
9
+ };
10
+ /**
11
+ * Parses markdown buttons in the format [Button Text](?message=Message%20to%20send)
12
+ * Returns both the content without buttons and the extracted buttons
13
+ *
14
+ * @param content The markdown content that may contain buttons
15
+ * @returns Object with contentWithoutButtons and buttons array
16
+ *
17
+ * @public exported from `@promptbook/components`
18
+ */
19
+ export declare function parseMessageButtons(content: string): {
20
+ contentWithoutButtons: string;
21
+ buttons: MessageButton[];
22
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pause icon (two vertical bars)
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const PauseIcon: ({ size }: {
7
+ size?: number | undefined;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Play icon (triangle) used for resume action
3
+ *
4
+ * @public exported from `@promptbook/components`
5
+ */
6
+ export declare const PlayIcon: ({ size }: {
7
+ size?: number | undefined;
8
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,4 @@
1
- import type { string_date_iso8601 } from '../types/typeAliases';
2
- import type { string_model_name } from '../types/typeAliases';
3
- import type { string_prompt } from '../types/typeAliases';
1
+ import type { string_date_iso8601, string_model_name, string_prompt } from '../types/typeAliases';
4
2
  import type { TODO_object } from '../utils/organization/TODO_object';
5
3
  import type { EmbeddingVector } from './EmbeddingVector';
6
4
  import type { Usage } from './Usage';
@@ -44,7 +42,7 @@ export type EmbeddingPromptResult = Omit<CommonPromptResult, 'content'> & {
44
42
  */
45
43
  export type CommonPromptResult = {
46
44
  /**
47
- * Exact text response from the model
45
+ * Text response from the model
48
46
  */
49
47
  readonly content: string;
50
48
  /**
@@ -1,8 +1,7 @@
1
1
  import type { PartialDeep, Promisable, ReadonlyDeep, WritableDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { Parameters } from '../../types/typeAliases';
5
- import type { string_parameter_name } from '../../types/typeAliases';
4
+ import type { Parameters, string_parameter_name } from '../../types/typeAliases';
6
5
  import type { TODO_string } from '../../utils/organization/TODO_string';
7
6
  import type { ExecutionReportJson } from '../execution-report/ExecutionReportJson';
8
7
  import type { PipelineExecutorResult } from '../PipelineExecutorResult';
@@ -1,9 +1,7 @@
1
1
  import type { ReadonlyDeep } from 'type-fest';
2
2
  import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
3
3
  import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
4
- import type { Parameters } from '../../types/typeAliases';
5
- import type { string_markdown } from '../../types/typeAliases';
6
- import type { string_parameter_value } from '../../types/typeAliases';
4
+ import type { Parameters, string_markdown, string_parameter_value } from '../../types/typeAliases';
7
5
  import type { ExecutionTools } from '../ExecutionTools';
8
6
  /**
9
7
  * Options for retrieving relevant knowledge for a specific task during pipeline execution.
@@ -1,4 +1,4 @@
1
- import { AbstractFormatError } from "../../errors/AbstractFormatError";
1
+ import { AbstractFormatError } from '../../errors/AbstractFormatError';
2
2
  /**
3
3
  * This error indicates problem with parsing of CSV
4
4
  *
@@ -16,4 +16,4 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
16
16
  export declare function $provideLlmToolsConfigurationFromEnv(): Promise<LlmToolsConfiguration>;
17
17
  /**
18
18
  * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
19
- */
19
+ */
@@ -24,4 +24,4 @@ export {};
24
24
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
25
25
  * TODO: This should be maybe not under `_common` but under `utils-internal` / `utils/internal`
26
26
  * TODO: [®] DRY Register logi
27
- */
27
+ */
@@ -1,7 +1,6 @@
1
1
  import { Promisable } from 'type-fest';
2
2
  import type { Identification } from '../../../remote-server/socket-types/_subtypes/Identification';
3
- import type { string_app_id } from '../../../types/typeAliases';
4
- import type { string_url } from '../../../types/typeAliases';
3
+ import type { string_app_id, string_url } from '../../../types/typeAliases';
5
4
  import type { really_any } from '../../../utils/organization/really_any';
6
5
  import type { CacheLlmToolsOptions } from '../utils/cache/CacheLlmToolsOptions';
7
6
  import type { LlmExecutionToolsWithTotalUsage } from '../utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
@@ -1,4 +1,4 @@
1
- import type { string_user_id } from '../../../types/typeAliases';
1
+ import type { string_markdown_text, string_mime_type_with_wildcard, string_user_id } from '../../../types/typeAliases';
2
2
  import { MultipleLlmExecutionTools } from '../../_multiple/MultipleLlmExecutionTools';
3
3
  import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
4
4
  /**
@@ -7,12 +7,18 @@ import type { LlmToolsConfiguration } from './LlmToolsConfiguration';
7
7
  * @private internal type for `$provideLlmToolsFromEnv` and `$provideLlmToolsForTestingAndScriptsAndPlayground`
8
8
  */
9
9
  export type CreateLlmToolsFromConfigurationOptions = {
10
+ /**
11
+ * Title of the LLM tools
12
+ *
13
+ * @default 'LLM Tools from Configuration'
14
+ */
15
+ readonly title?: string_mime_type_with_wildcard & string_markdown_text;
10
16
  /**
11
17
  * This will will be passed to the created `LlmExecutionTools`
12
18
  *
13
19
  * @default false
14
20
  */
15
- isVerbose?: boolean;
21
+ readonly isVerbose?: boolean;
16
22
  /**
17
23
  * Identifier of the end user
18
24
  *
@@ -0,0 +1,25 @@
1
+ import type { ModelRequirements } from '../../../types/ModelRequirements';
2
+ /**
3
+ * Parses an OpenAI error message to identify which parameter is unsupported
4
+ *
5
+ * @param errorMessage The error message from OpenAI API
6
+ * @returns The parameter name that is unsupported, or null if not an unsupported parameter error
7
+ * @private utility of LLM Tools
8
+ */
9
+ export declare function parseUnsupportedParameterError(errorMessage: string): string | null;
10
+ /**
11
+ * Creates a copy of model requirements with the specified parameter removed
12
+ *
13
+ * @param modelRequirements Original model requirements
14
+ * @param unsupportedParameter The parameter to remove
15
+ * @returns New model requirements without the unsupported parameter
16
+ * @private utility of LLM Tools
17
+ */
18
+ export declare function removeUnsupportedModelRequirement(modelRequirements: ModelRequirements, unsupportedParameter: string): ModelRequirements;
19
+ /**
20
+ * Checks if an error is an "Unsupported value" error from OpenAI
21
+ * @param error The error to check
22
+ * @returns true if this is an unsupported parameter error
23
+ * @private utility of LLM Tools
24
+ */
25
+ export declare function isUnsupportedParameterError(error: Error): boolean;
@@ -1,16 +1,9 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
- import type { ChatPromptResult } from '../../execution/PromptResult';
4
- import type { CompletionPromptResult } from '../../execution/PromptResult';
5
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
6
- import type { PromptResult } from '../../execution/PromptResult';
7
- import type { ChatPrompt } from '../../types/Prompt';
8
- import type { CompletionPrompt } from '../../types/Prompt';
9
- import type { EmbeddingPrompt } from '../../types/Prompt';
10
- import type { Prompt } from '../../types/Prompt';
11
- import type { string_markdown } from '../../types/typeAliases';
12
- import type { string_markdown_text } from '../../types/typeAliases';
13
- import type { string_title } from '../../types/typeAliases';
4
+ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult, PromptResult } from '../../execution/PromptResult';
5
+ import type { ChatPrompt, CompletionPrompt, EmbeddingPrompt, Prompt } from '../../types/Prompt';
6
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
14
7
  /**
15
8
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
16
9
  *
@@ -18,6 +11,7 @@ import type { string_title } from '../../types/typeAliases';
18
11
  * @public exported from `@promptbook/core`
19
12
  */
20
13
  export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
14
+ readonly title: string_title & string_markdown_text;
21
15
  /**
22
16
  * Array of execution tools in order of priority
23
17
  */
@@ -25,14 +19,9 @@ export declare class MultipleLlmExecutionTools implements LlmExecutionTools {
25
19
  /**
26
20
  * Gets array of execution tools in order of priority
27
21
  */
28
- constructor(...llmExecutionTools: ReadonlyArray<LlmExecutionTools>);
29
- get title(): string_title & string_markdown_text;
22
+ constructor(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>);
30
23
  get description(): string_markdown;
31
- get profile(): {
32
- name: string;
33
- fullname: string;
34
- color: string;
35
- };
24
+ get profile(): ChatParticipant;
36
25
  /**
37
26
  * Check the configuration of all execution tools
38
27
  */
@@ -0,0 +1,11 @@
1
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
3
+ /**
4
+ * Just returns the given `LlmExecutionTools` or joins multiple into one
5
+ *
6
+ * @public exported from `@promptbook/core`
7
+ */
8
+ export declare function getSingleLlmExecutionTools(oneOrMoreLlmExecutionTools: undefined | LlmExecutionTools | ReadonlyArray<LlmExecutionTools>): LlmExecutionTools | MultipleLlmExecutionTools;
9
+ /**
10
+ * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
11
+ */
@@ -1,4 +1,5 @@
1
1
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
2
+ import { string_markdown_text, string_title } from '../../types/typeAliases';
2
3
  import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
3
4
  /**
4
5
  * Joins multiple LLM Execution Tools into one
@@ -15,7 +16,7 @@ import { MultipleLlmExecutionTools } from './MultipleLlmExecutionTools';
15
16
  *
16
17
  * @public exported from `@promptbook/core`
17
18
  */
18
- export declare function joinLlmExecutionTools(...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
19
+ export declare function joinLlmExecutionTools(title: string_title & string_markdown_text, ...llmExecutionTools: ReadonlyArray<LlmExecutionTools>): MultipleLlmExecutionTools;
19
20
  /**
20
21
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
21
22
  */
@@ -0,0 +1,58 @@
1
+ import type { Promisable } from 'type-fest';
2
+ import type { string_book } from '../../book-2.0/agent-source/string_book';
3
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
4
+ import type { AvailableModel } from '../../execution/AvailableModel';
5
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
6
+ import type { ChatPromptResult } from '../../execution/PromptResult';
7
+ import type { Prompt } from '../../types/Prompt';
8
+ import type { string_markdown, string_markdown_text, string_model_name, string_title } from '../../types/typeAliases';
9
+ /**
10
+ * Execution Tools for calling LLM models with a predefined agent "soul"
11
+ * This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
12
+ *
13
+ * @public exported from `@promptbook/core`
14
+ */
15
+ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
16
+ private readonly llmTools;
17
+ private readonly agentSource;
18
+ /**
19
+ * Cached model requirements to avoid re-parsing the agent source
20
+ */
21
+ private _cachedModelRequirements;
22
+ /**
23
+ * Cached parsed agent information
24
+ */
25
+ private _cachedAgentInfo;
26
+ /**
27
+ * Creates new AgentLlmExecutionTools
28
+ *
29
+ * @param llmTools The underlying LLM execution tools to wrap
30
+ * @param agentSource The agent source string that defines the agent's behavior
31
+ */
32
+ constructor(llmTools: LlmExecutionTools, agentSource: string_book);
33
+ /**
34
+ * Get cached or parse agent information
35
+ */
36
+ private getAgentInfo;
37
+ /**
38
+ * Get cached or create agent model requirements
39
+ */
40
+ private getAgentModelRequirements;
41
+ get title(): string_title & string_markdown_text;
42
+ get description(): string_markdown;
43
+ get profile(): ChatParticipant | undefined;
44
+ checkConfiguration(): Promisable<void>;
45
+ /**
46
+ * Returns a virtual model name representing the agent behavior
47
+ */
48
+ get modelName(): string_model_name;
49
+ listModels(): Promisable<ReadonlyArray<AvailableModel>>;
50
+ /**
51
+ * Calls the chat model with agent-specific system prompt and requirements
52
+ */
53
+ callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
54
+ }
55
+ /**
56
+ * TODO: [🍚] Implement Destroyable pattern to free resources
57
+ * TODO: [🧠] Adding parameter substitution support (here or should be responsibility of the underlying LLM Tools)
58
+ */
@@ -0,0 +1,29 @@
1
+ import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
+ import { AgentLlmExecutionTools } from './AgentLlmExecutionTools';
4
+ /**
5
+ * Options for creating AgentLlmExecutionTools
6
+ */
7
+ export type CreateAgentLlmExecutionToolsOptions = {
8
+ /**
9
+ * The underlying LLM execution tools to wrap
10
+ */
11
+ llmTools: LlmExecutionTools;
12
+ /**
13
+ * The agent source string that defines the agent's behavior
14
+ */
15
+ agentSource: string_book;
16
+ };
17
+ /**
18
+ * Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
19
+ *
20
+ * @public exported from `@promptbook/core`
21
+ */
22
+ export declare const createAgentLlmExecutionTools: ((options: CreateAgentLlmExecutionToolsOptions) => AgentLlmExecutionTools) & {
23
+ packageName: string;
24
+ className: string;
25
+ };
26
+ /**
27
+ * TODO: [🧠] Consider adding validation for agent source format
28
+ * TODO: [🧠] Consider adding options for caching behavior
29
+ */
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ts-node
2
+ export {};
3
+ /**
4
+ * TODO: [🧠] Add more complex agent scenarios
5
+ * TODO: [🧠] Add parameter substitution demo
6
+ * TODO: [🧠] Add multi-turn conversation demo
7
+ * Note: [⚫] Code in this file should never be published in any package
8
+ */
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Metadata for Agent LLM execution tools
3
+ *
4
+ * @public exported from `@promptbook/core`
5
+ */
6
+ export declare const _AgentMetadata: import("../../utils/$Register").Registration;
7
+ /**
8
+ * TODO: [🧠] Consider adding a special trust level for AgentLlmExecutionTools
9
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
10
+ * Note: [💞] Ignore a discrepancy between file name and entity name
11
+ */
@@ -0,0 +1,13 @@
1
+ import type { Registration } from '../../utils/$Register';
2
+ /**
3
+ * Registration of Agent LLM provider
4
+ *
5
+ * Warning: This is not useful for the end user, it is just a side effect of the mechanism that handles all available LLM tools
6
+ *
7
+ * @public exported from `@promptbook/core`
8
+ */
9
+ export declare const _AgentRegistration: Registration;
10
+ /**
11
+ * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
12
+ * Note: [💞] Ignore a discrepancy between file name and entity name
13
+ */
@@ -1,11 +1,10 @@
1
1
  import Anthropic from '@anthropic-ai/sdk';
2
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
2
3
  import type { AvailableModel } from '../../execution/AvailableModel';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
5
  import type { ChatPromptResult } from '../../execution/PromptResult';
5
6
  import type { Prompt } from '../../types/Prompt';
6
- import type { string_markdown } from '../../types/typeAliases';
7
- import type { string_markdown_text } from '../../types/typeAliases';
8
- import type { string_title } from '../../types/typeAliases';
7
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
9
8
  import type { AnthropicClaudeExecutionToolsNonProxiedOptions } from './AnthropicClaudeExecutionToolsOptions';
10
9
  /**
11
10
  * Execution Tools for calling Anthropic Claude API.
@@ -28,11 +27,7 @@ export declare class AnthropicClaudeExecutionTools implements LlmExecutionTools
28
27
  constructor(options?: AnthropicClaudeExecutionToolsNonProxiedOptions);
29
28
  get title(): string_title & string_markdown_text;
30
29
  get description(): string_markdown;
31
- get profile(): {
32
- name: string;
33
- fullname: string;
34
- color: string;
35
- };
30
+ get profile(): ChatParticipant;
36
31
  getClient(): Promise<Anthropic>;
37
32
  /**
38
33
  * Check the `options` passed to `constructor`
@@ -1,12 +1,10 @@
1
1
  import { OpenAIClient } from '@azure/openai';
2
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
2
3
  import type { AvailableModel } from '../../execution/AvailableModel';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import type { ChatPromptResult } from '../../execution/PromptResult';
5
- import type { CompletionPromptResult } from '../../execution/PromptResult';
5
+ import type { ChatPromptResult, CompletionPromptResult } from '../../execution/PromptResult';
6
6
  import type { Prompt } from '../../types/Prompt';
7
- import type { string_markdown } from '../../types/typeAliases';
8
- import type { string_markdown_text } from '../../types/typeAliases';
9
- import type { string_title } from '../../types/typeAliases';
7
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
10
8
  import type { AzureOpenAiExecutionToolsOptions } from './AzureOpenAiExecutionToolsOptions';
11
9
  /**
12
10
  * Execution Tools for calling Azure OpenAI API.
@@ -31,6 +29,7 @@ export declare class AzureOpenAiExecutionTools implements LlmExecutionTools {
31
29
  constructor(options: AzureOpenAiExecutionToolsOptions);
32
30
  get title(): string_title & string_markdown_text;
33
31
  get description(): string_markdown;
32
+ get profile(): ChatParticipant;
34
33
  getClient(): Promise<OpenAIClient>;
35
34
  /**
36
35
  * Check the `options` passed to `constructor`
@@ -11,5 +11,6 @@ import type { string_postprocessing_function_name } from '../../types/typeAliase
11
11
  */
12
12
  export declare function $fakeTextToExpectations(expectations: Expectations, postprocessingFunctionNames?: ReadonlyArray<string_postprocessing_function_name>): Promise<string>;
13
13
  /**
14
+ * TODO: Do not use LoremIpsum, but use some faked text that looks more human-promptbook-like
14
15
  * TODO: [💝] Unite object for expecting amount and format - use here also a format
15
16
  */
@@ -1,12 +1,10 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import type { ChatPromptResult } from '../../execution/PromptResult';
5
- import type { CompletionPromptResult } from '../../execution/PromptResult';
5
+ import type { ChatPromptResult, CompletionPromptResult } from '../../execution/PromptResult';
6
6
  import type { Prompt } from '../../types/Prompt';
7
- import type { string_markdown } from '../../types/typeAliases';
8
- import type { string_markdown_text } from '../../types/typeAliases';
9
- import type { string_title } from '../../types/typeAliases';
7
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
10
8
  /**
11
9
  * Mocked execution Tools for just echoing the requests for testing purposes.
12
10
  *
@@ -17,11 +15,7 @@ export declare class MockedEchoLlmExecutionTools implements LlmExecutionTools {
17
15
  constructor(options?: CommonToolsOptions);
18
16
  get title(): string_title & string_markdown_text;
19
17
  get description(): string_markdown;
20
- get profile(): {
21
- name: string;
22
- fullname: string;
23
- color: string;
24
- };
18
+ get profile(): ChatParticipant;
25
19
  /**
26
20
  * Does nothing, just to implement the interface
27
21
  */
@@ -1,13 +1,10 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
- import type { ChatPromptResult } from '../../execution/PromptResult';
5
- import type { CompletionPromptResult } from '../../execution/PromptResult';
6
- import type { EmbeddingPromptResult } from '../../execution/PromptResult';
5
+ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult } from '../../execution/PromptResult';
7
6
  import type { Prompt } from '../../types/Prompt';
8
- import type { string_markdown } from '../../types/typeAliases';
9
- import type { string_markdown_text } from '../../types/typeAliases';
10
- import type { string_title } from '../../types/typeAliases';
7
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
11
8
  /**
12
9
  * Mocked execution Tools for just faking expected responses for testing purposes
13
10
  *
@@ -18,6 +15,7 @@ export declare class MockedFackedLlmExecutionTools implements LlmExecutionTools
18
15
  constructor(options?: CommonToolsOptions);
19
16
  get title(): string_title & string_markdown_text;
20
17
  get description(): string_markdown;
18
+ get profile(): ChatParticipant;
21
19
  /**
22
20
  * Does nothing, just to implement the interface
23
21
  */
@@ -1,9 +1,8 @@
1
+ import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
1
2
  import type { AvailableModel } from '../../execution/AvailableModel';
2
3
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
3
4
  import type { Usage } from '../../execution/Usage';
4
- import type { string_markdown } from '../../types/typeAliases';
5
- import type { string_markdown_text } from '../../types/typeAliases';
6
- import type { string_title } from '../../types/typeAliases';
5
+ import type { string_markdown, string_markdown_text, string_title } from '../../types/typeAliases';
7
6
  import { computeOpenAiUsage } from '../openai/computeOpenAiUsage';
8
7
  import { OpenAiCompatibleExecutionTools } from '../openai/OpenAiCompatibleExecutionTools';
9
8
  import type { OllamaExecutionToolsOptions } from './OllamaExecutionToolsOptions';
@@ -16,6 +15,7 @@ export declare class OllamaExecutionTools extends OpenAiCompatibleExecutionTools
16
15
  constructor(ollamaOptions: OllamaExecutionToolsOptions);
17
16
  get title(): string_title & string_markdown_text;
18
17
  get description(): string_markdown;
18
+ get profile(): ChatParticipant;
19
19
  /**
20
20
  * List all available models (non dynamically)
21
21
  *