@promptbook/components 0.101.0-11 → 0.101.0-13
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 +13 -51
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +8 -0
- package/esm/typings/src/_packages/types.index.d.ts +2 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +55 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +29 -0
- package/esm/typings/src/llm-providers/agent/playground/playground.d.ts +8 -0
- package/esm/typings/src/llm-providers/agent/register-configuration.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/register-constructor.d.ts +13 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +13 -51
- package/umd/index.umd.js.map +1 -1
|
@@ -93,6 +93,7 @@ import type { LlmToolsOptions } from '../llm-providers/_common/register/LlmTools
|
|
|
93
93
|
import type { CacheItem } from '../llm-providers/_common/utils/cache/CacheItem';
|
|
94
94
|
import type { CacheLlmToolsOptions } from '../llm-providers/_common/utils/cache/CacheLlmToolsOptions';
|
|
95
95
|
import type { LlmExecutionToolsWithTotalUsage } from '../llm-providers/_common/utils/count-total-usage/LlmExecutionToolsWithTotalUsage';
|
|
96
|
+
import type { CreateAgentLlmExecutionToolsOptions } from '../llm-providers/agent/createAgentLlmExecutionTools';
|
|
96
97
|
import type { AnthropicClaudeExecutionToolsOptions } from '../llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions';
|
|
97
98
|
import type { AnthropicClaudeExecutionToolsNonProxiedOptions } from '../llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions';
|
|
98
99
|
import type { AnthropicClaudeExecutionToolsProxiedOptions } from '../llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions';
|
|
@@ -418,6 +419,7 @@ export type { LlmToolsOptions };
|
|
|
418
419
|
export type { CacheItem };
|
|
419
420
|
export type { CacheLlmToolsOptions };
|
|
420
421
|
export type { LlmExecutionToolsWithTotalUsage };
|
|
422
|
+
export type { CreateAgentLlmExecutionToolsOptions };
|
|
421
423
|
export type { AnthropicClaudeExecutionToolsOptions };
|
|
422
424
|
export type { AnthropicClaudeExecutionToolsNonProxiedOptions };
|
|
423
425
|
export type { AnthropicClaudeExecutionToolsProxiedOptions };
|
|
@@ -0,0 +1,55 @@
|
|
|
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_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
|
+
listModels(): Promisable<ReadonlyArray<AvailableModel>>;
|
|
46
|
+
/**
|
|
47
|
+
* Calls the chat model with agent-specific system prompt and requirements
|
|
48
|
+
*/
|
|
49
|
+
callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* TODO: [🍚] Implement Destroyable pattern to free resources
|
|
53
|
+
* TODO: !!!! Pick the best model from available models
|
|
54
|
+
* TODO: !!!! adding parameter substitution support
|
|
55
|
+
*/
|
|
@@ -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,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
|
+
*/
|
|
@@ -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.101.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.101.0-12`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* @generated
|
|
23
23
|
* @see https://github.com/webgptorg/promptbook
|
|
24
24
|
*/
|
|
25
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-
|
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.101.0-13';
|
|
26
26
|
/**
|
|
27
27
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
28
28
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -4128,49 +4128,8 @@
|
|
|
4128
4128
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
4129
4129
|
*/
|
|
4130
4130
|
|
|
4131
|
-
//
|
|
4132
|
-
const
|
|
4133
|
-
chat: {
|
|
4134
|
-
width: '100%',
|
|
4135
|
-
height: '100%',
|
|
4136
|
-
display: 'flex',
|
|
4137
|
-
flexDirection: 'column',
|
|
4138
|
-
},
|
|
4139
|
-
chatMainFlow: {
|
|
4140
|
-
width: '100%',
|
|
4141
|
-
height: '100%',
|
|
4142
|
-
maxWidth: '100vw',
|
|
4143
|
-
display: 'grid',
|
|
4144
|
-
gridTemplate: `
|
|
4145
|
-
'header' min-content
|
|
4146
|
-
'messages' 1fr
|
|
4147
|
-
'input' min-content
|
|
4148
|
-
/ 1fr`,
|
|
4149
|
-
},
|
|
4150
|
-
chatMessages: {
|
|
4151
|
-
gridArea: 'messages',
|
|
4152
|
-
width: '100%',
|
|
4153
|
-
height: '100%',
|
|
4154
|
-
padding: '24px 20px 16px',
|
|
4155
|
-
overflowY: 'auto',
|
|
4156
|
-
overflowX: 'hidden',
|
|
4157
|
-
},
|
|
4158
|
-
chatInput: {
|
|
4159
|
-
gridArea: 'input',
|
|
4160
|
-
width: '100%',
|
|
4161
|
-
padding: '20px',
|
|
4162
|
-
display: 'flex',
|
|
4163
|
-
alignItems: 'center',
|
|
4164
|
-
gap: '12px',
|
|
4165
|
-
},
|
|
4166
|
-
chatBar: {
|
|
4167
|
-
gridArea: 'header',
|
|
4168
|
-
width: '100%',
|
|
4169
|
-
padding: '16px 20px',
|
|
4170
|
-
textAlign: 'center',
|
|
4171
|
-
},
|
|
4172
|
-
};
|
|
4173
|
-
// <- TODO: [💩] !!!! "[✨🦬] Fix `<Chat/>` loading"
|
|
4131
|
+
// [🚉] Avatar dimensions constant to prevent layout jumps and maintain DRY principle
|
|
4132
|
+
const AVATAR_SIZE = 40;
|
|
4174
4133
|
/**
|
|
4175
4134
|
* Renders a chat with messages and input for new messages
|
|
4176
4135
|
*
|
|
@@ -4351,10 +4310,7 @@
|
|
|
4351
4310
|
return { ...message, content: humanizeAiText(message.content) };
|
|
4352
4311
|
});
|
|
4353
4312
|
}, [messages, isAiTextHumanized]);
|
|
4354
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ratingConfirmation && jsxRuntime.jsx("div", { className: styles$1.ratingConfirmation, children: ratingConfirmation }), jsxRuntime.jsx("div", { className: classNames(className, styles$1.Chat, useChatCssClassName('Chat')), style: {
|
|
4355
|
-
...CRITICAL_STYLES.chat,
|
|
4356
|
-
...style,
|
|
4357
|
-
}, children: jsxRuntime.jsxs("div", { className: classNames(className, styles$1.chatMainFlow, useChatCssClassName('chatMainFlow')), style: CRITICAL_STYLES.chatMainFlow, children: [children && (jsxRuntime.jsx("div", { className: classNames(styles$1.chatBar, chatBarCssClassName), style: CRITICAL_STYLES.chatBar, children: children })), !isAutoScrolling && (jsxRuntime.jsx("div", { className: styles$1.scrollToBottomContainer, children: jsxRuntime.jsx("button", { "data-button-type": "custom", className: classNames(styles$1.scrollToBottom, scrollToBottomCssClassName), onClick: () => {
|
|
4313
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ratingConfirmation && jsxRuntime.jsx("div", { className: styles$1.ratingConfirmation, children: ratingConfirmation }), jsxRuntime.jsx("div", { className: classNames(className, styles$1.Chat, useChatCssClassName('Chat')), style, children: jsxRuntime.jsxs("div", { className: classNames(className, styles$1.chatMainFlow, useChatCssClassName('chatMainFlow')), children: [children && jsxRuntime.jsx("div", { className: classNames(styles$1.chatBar, chatBarCssClassName), children: children }), !isAutoScrolling && (jsxRuntime.jsx("div", { className: styles$1.scrollToBottomContainer, children: jsxRuntime.jsx("button", { "data-button-type": "custom", className: classNames(styles$1.scrollToBottom, scrollToBottomCssClassName), onClick: () => {
|
|
4358
4314
|
const chatMessagesElement = chatMessagesRef.current;
|
|
4359
4315
|
if (chatMessagesElement === null) {
|
|
4360
4316
|
return;
|
|
@@ -4376,7 +4332,7 @@
|
|
|
4376
4332
|
return;
|
|
4377
4333
|
}
|
|
4378
4334
|
onReset();
|
|
4379
|
-
}, children: [jsxRuntime.jsx(ResetIcon, {}), jsxRuntime.jsx("span", { className: styles$1.resetButtonText, children: "New chat" })] })), onUseTemplate && (jsxRuntime.jsxs("button", { className: classNames(styles$1.useTemplateButton), onClick: onUseTemplate, children: [jsxRuntime.jsx("span", { className: styles$1.resetButtonText, children: "Use this template" }), jsxRuntime.jsx(TemplateIcon, { size: 16 })] }))] }), jsxRuntime.jsx("div", { className: classNames(styles$1.chatMessages, useChatCssClassName('chatMessages')),
|
|
4335
|
+
}, children: [jsxRuntime.jsx(ResetIcon, {}), jsxRuntime.jsx("span", { className: styles$1.resetButtonText, children: "New chat" })] })), onUseTemplate && (jsxRuntime.jsxs("button", { className: classNames(styles$1.useTemplateButton), onClick: onUseTemplate, children: [jsxRuntime.jsx("span", { className: styles$1.resetButtonText, children: "Use this template" }), jsxRuntime.jsx(TemplateIcon, { size: 16 })] }))] }), jsxRuntime.jsx("div", { className: classNames(styles$1.chatMessages, useChatCssClassName('chatMessages')), ref: (chatMessagesElement) => {
|
|
4380
4336
|
chatMessagesRef.current = chatMessagesElement;
|
|
4381
4337
|
if (chatMessagesElement === null) {
|
|
4382
4338
|
return;
|
|
@@ -4419,8 +4375,14 @@
|
|
|
4419
4375
|
console.info('participant avatarSrc', avatarSrc);
|
|
4420
4376
|
console.info('participant color', { color, colorOfText });
|
|
4421
4377
|
console.groupEnd();
|
|
4422
|
-
}, children: [avatarSrc && (jsxRuntime.jsx("div", { className: styles$1.avatar, children: jsxRuntime.jsx("img", { width:
|
|
4378
|
+
}, children: [avatarSrc && (jsxRuntime.jsx("div", { className: styles$1.avatar, children: jsxRuntime.jsx("img", { width: AVATAR_SIZE, height: AVATAR_SIZE, src: avatarSrc, alt: `Avatar of ${message.from.toLocaleLowerCase()}`, style: {
|
|
4423
4379
|
backgroundColor: color.toHex(),
|
|
4380
|
+
width: AVATAR_SIZE,
|
|
4381
|
+
height: AVATAR_SIZE,
|
|
4382
|
+
borderRadius: '50%',
|
|
4383
|
+
objectFit: 'cover',
|
|
4384
|
+
border: '2px solid rgba(125, 125, 125, 0.1)',
|
|
4385
|
+
flexShrink: 0,
|
|
4424
4386
|
} }) })), jsxRuntime.jsxs("div", { className: styles$1.messageText, style: {
|
|
4425
4387
|
backgroundColor: color.toHex(),
|
|
4426
4388
|
color: colorOfText.toHex(),
|
|
@@ -4449,7 +4411,7 @@
|
|
|
4449
4411
|
: '#666',
|
|
4450
4412
|
transition: 'color 0.2s',
|
|
4451
4413
|
}, children: "\u2B50" })) }))] })] }, i));
|
|
4452
|
-
}) }), onMessage && (jsxRuntime.jsxs("div", { className: classNames(styles$1.chatInput, useChatCssClassName('chatInput')),
|
|
4414
|
+
}) }), onMessage && (jsxRuntime.jsxs("div", { className: classNames(styles$1.chatInput, useChatCssClassName('chatInput')), children: [jsxRuntime.jsx("textarea", { ref: (element) => {
|
|
4453
4415
|
textareaRef.current = element;
|
|
4454
4416
|
}, style: {
|
|
4455
4417
|
height: Math.max(countLines(((_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.value) || defaultMessage || ''), (((_c = textareaRef.current) === null || _c === void 0 ? void 0 : _c.value) || defaultMessage || '').split('\n').length, 3) *
|