@promptbook/components 0.103.0-45 → 0.103.0-47
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 +174 -109
- package/esm/index.es.js.map +1 -1
- package/esm/typings/servers.d.ts +1 -7
- package/esm/typings/src/_packages/components.index.d.ts +4 -0
- package/esm/typings/src/_packages/core.index.d.ts +16 -14
- package/esm/typings/src/_packages/types.index.d.ts +12 -6
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +6 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +2 -0
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +2 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.test.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +5 -60
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +1 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +1 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +3 -7
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +32 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +5 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/types/typeAliases.d.ts +6 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +2 -2
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +1 -1
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +2 -1
- package/umd/index.umd.js +177 -112
- package/umd/index.umd.js.map +1 -1
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/index.d.ts +0 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
2
|
+
import type { Prompt } from '../../types/Prompt';
|
|
3
|
+
import { Agent } from './Agent';
|
|
4
|
+
import type { RemoteAgentOptions } from './RemoteAgentOptions';
|
|
5
|
+
/**
|
|
6
|
+
* Represents one AI Agent
|
|
7
|
+
*
|
|
8
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
9
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
10
|
+
* !!!! `RemoteAgent`
|
|
11
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
12
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
13
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
14
|
+
*
|
|
15
|
+
* @public exported from `@promptbook/core`
|
|
16
|
+
*/
|
|
17
|
+
export declare class RemoteAgent extends Agent {
|
|
18
|
+
static connect(options: RemoteAgentOptions): Promise<RemoteAgent>;
|
|
19
|
+
/**
|
|
20
|
+
* The source of the agent
|
|
21
|
+
*/
|
|
22
|
+
private agentUrl;
|
|
23
|
+
private constructor();
|
|
24
|
+
/**
|
|
25
|
+
* Calls the agent on agents remote server
|
|
26
|
+
*/
|
|
27
|
+
callChatModel(prompt: Prompt): Promise<ChatPromptResult>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
31
|
+
* TODO: !!! Agent on remote server
|
|
32
|
+
*/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
|
|
2
|
+
import type { string_agent_url } from '../../types/typeAliases';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating a Remote Agent
|
|
5
|
+
*/
|
|
6
|
+
export type RemoteAgentOptions = CommonToolsOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* Url of the remote agent
|
|
9
|
+
*/
|
|
10
|
+
agentUrl: string_agent_url;
|
|
11
|
+
};
|
|
@@ -9,7 +9,7 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
|
9
9
|
*
|
|
10
10
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
11
11
|
*
|
|
12
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
12
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
13
13
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
14
14
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
15
15
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -42,6 +42,10 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
|
|
|
42
42
|
* Instructions for the new assistant
|
|
43
43
|
*/
|
|
44
44
|
readonly instructions: string_markdown;
|
|
45
|
+
/**
|
|
46
|
+
* Optional list of knowledge source links (URLs or file paths) to attach to the assistant via vector store
|
|
47
|
+
*/
|
|
48
|
+
readonly knowledgeSources?: ReadonlyArray<string>;
|
|
45
49
|
}): Promise<OpenAiAssistantExecutionTools>;
|
|
46
50
|
/**
|
|
47
51
|
* Discriminant for type guards
|
|
@@ -3,6 +3,8 @@ import type { PipelineString } from './PipelineString';
|
|
|
3
3
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
4
4
|
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
5
5
|
*
|
|
6
|
+
* Note: [🔂] This function is idempotent.
|
|
7
|
+
*
|
|
6
8
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
7
9
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
8
10
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -360,6 +360,12 @@ export type string_base_url = string;
|
|
|
360
360
|
* For example `"https://promptbook.studio/webgpt/"`
|
|
361
361
|
*/
|
|
362
362
|
export type string_pipeline_root_url = string;
|
|
363
|
+
/**
|
|
364
|
+
* Semantic helper
|
|
365
|
+
*
|
|
366
|
+
* For example `"https://s6.ptbk.io/agents/agent-007"`
|
|
367
|
+
*/
|
|
368
|
+
export type string_agent_url = string;
|
|
363
369
|
/**
|
|
364
370
|
* Semantic helper
|
|
365
371
|
*
|
|
@@ -9,6 +9,3 @@
|
|
|
9
9
|
* @private util of `@promptbook/color`
|
|
10
10
|
*/
|
|
11
11
|
export declare function checkChannelValue(channelName: string, value: number): asserts value is number;
|
|
12
|
-
/**
|
|
13
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
14
|
-
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PartialDeep } from 'type-fest';
|
|
2
2
|
import type { AgentBasicInformation } from '../../book-2.0/agent-source/AgentBasicInformation';
|
|
3
|
-
import { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
|
-
import { string_agent_name_in_book } from '../../types/typeAliases';
|
|
3
|
+
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
|
+
import type { string_agent_name_in_book } from '../../types/typeAliases';
|
|
5
5
|
type GenerateBookBoilerplateOptions = PartialDeep<Omit<AgentBasicInformation, 'parameters'>> & {
|
|
6
6
|
/**
|
|
7
7
|
* Name of the parent agent to inherit from
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { string_color, string_person_fullname } from '../../types/typeAliases';
|
|
1
|
+
import type { string_color, string_person_fullname } from '../../types/typeAliases';
|
|
2
2
|
export type RandomFullnameWithColorResult = {
|
|
3
3
|
fullname: string_person_fullname;
|
|
4
4
|
color: string_color;
|
|
@@ -3,6 +3,8 @@ import type { string_parameter_name } from '../../../types/typeAliases';
|
|
|
3
3
|
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
4
4
|
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
5
5
|
*
|
|
6
|
+
* Note: [🔂] This function is idempotent.
|
|
7
|
+
*
|
|
6
8
|
* @param parameterName The parameter name to validate and normalize.
|
|
7
9
|
* @returns The validated and normalized parameter name.
|
|
8
10
|
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
@@ -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.103.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.103.0-46`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/components",
|
|
3
|
-
"version": "0.103.0-
|
|
3
|
+
"version": "0.103.0-47",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"highlight.js": "11.11.1",
|
|
101
101
|
"katex": "0.16.25",
|
|
102
102
|
"qrcode": "^1.5.4",
|
|
103
|
+
"rxjs": "7.8.2",
|
|
103
104
|
"showdown": "2.1.0",
|
|
104
105
|
"spacetrim": "0.11.60",
|
|
105
106
|
"waitasecond": "1.11.160"
|
package/umd/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim'), require('react-dom'), require('@monaco-editor/react'), require('path'), require('destroyable'), require('highlight.js'), require('katex'), require('showdown'), require('waitasecond'), require('qrcode')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim', 'react-dom', '@monaco-editor/react', 'path', 'destroyable', 'highlight.js', 'katex', 'showdown', 'waitasecond', 'qrcode'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim, global.reactDom, global.Editor, global.path, global.destroyable, global.hljs, global.katex, global.showdown, global.waitasecond, global.QRCode));
|
|
5
|
-
})(this, (function (exports, jsxRuntime, react, spaceTrim, reactDom, Editor, path, destroyable, hljs, katex, showdown, waitasecond, QRCode) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react/jsx-runtime'), require('react'), require('spacetrim'), require('react-dom'), require('@monaco-editor/react'), require('path'), require('destroyable'), require('highlight.js'), require('katex'), require('showdown'), require('rxjs'), require('waitasecond'), require('qrcode')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react/jsx-runtime', 'react', 'spacetrim', 'react-dom', '@monaco-editor/react', 'path', 'destroyable', 'highlight.js', 'katex', 'showdown', 'rxjs', 'waitasecond', 'qrcode'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-components"] = {}, global.jsxRuntime, global.react, global.spaceTrim, global.reactDom, global.Editor, global.path, global.destroyable, global.hljs, global.katex, global.showdown, global.rxjs, global.waitasecond, global.QRCode));
|
|
5
|
+
})(this, (function (exports, jsxRuntime, react, spaceTrim, reactDom, Editor, path, destroyable, hljs, katex, showdown, rxjs, waitasecond, QRCode) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @generated
|
|
27
27
|
* @see https://github.com/webgptorg/promptbook
|
|
28
28
|
*/
|
|
29
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
29
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-47';
|
|
30
30
|
/**
|
|
31
31
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
32
32
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -667,6 +667,36 @@
|
|
|
667
667
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
668
668
|
*/
|
|
669
669
|
|
|
670
|
+
/**
|
|
671
|
+
* Tests if given string is valid URL.
|
|
672
|
+
*
|
|
673
|
+
* Note: [🔂] This function is idempotent.
|
|
674
|
+
* Note: Dataurl are considered perfectly valid.
|
|
675
|
+
* Note: There are two similar functions:
|
|
676
|
+
* - `isValidUrl` which tests any URL
|
|
677
|
+
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
678
|
+
*
|
|
679
|
+
* @public exported from `@promptbook/utils`
|
|
680
|
+
*/
|
|
681
|
+
function isValidUrl(url) {
|
|
682
|
+
if (typeof url !== 'string') {
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
try {
|
|
686
|
+
if (url.startsWith('blob:')) {
|
|
687
|
+
url = url.replace(/^blob:/, '');
|
|
688
|
+
}
|
|
689
|
+
const urlObject = new URL(url /* because fail is handled */);
|
|
690
|
+
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
return true;
|
|
694
|
+
}
|
|
695
|
+
catch (error) {
|
|
696
|
+
return false;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
670
700
|
/**
|
|
671
701
|
* KNOWLEDGE commitment definition
|
|
672
702
|
*
|
|
@@ -740,23 +770,19 @@
|
|
|
740
770
|
`);
|
|
741
771
|
}
|
|
742
772
|
applyToAgentModelRequirements(requirements, content) {
|
|
743
|
-
var _a;
|
|
744
773
|
const trimmedContent = content.trim();
|
|
745
774
|
if (!trimmedContent) {
|
|
746
775
|
return requirements;
|
|
747
776
|
}
|
|
748
777
|
// Check if content is a URL (external knowledge source)
|
|
749
|
-
if (
|
|
778
|
+
if (isValidUrl(trimmedContent)) {
|
|
750
779
|
// Store the URL for later async processing
|
|
751
780
|
const updatedRequirements = {
|
|
752
781
|
...requirements,
|
|
753
|
-
|
|
754
|
-
...requirements.
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
trimmedContent,
|
|
758
|
-
],
|
|
759
|
-
},
|
|
782
|
+
knowledgeSources: [
|
|
783
|
+
...(requirements.knowledgeSources || []),
|
|
784
|
+
trimmedContent,
|
|
785
|
+
],
|
|
760
786
|
};
|
|
761
787
|
// Add placeholder information about knowledge sources to system message
|
|
762
788
|
const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
|
|
@@ -768,18 +794,6 @@
|
|
|
768
794
|
return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
|
|
769
795
|
}
|
|
770
796
|
}
|
|
771
|
-
/**
|
|
772
|
-
* Check if content is a URL
|
|
773
|
-
*/
|
|
774
|
-
isUrl(content) {
|
|
775
|
-
try {
|
|
776
|
-
new URL(content);
|
|
777
|
-
return true;
|
|
778
|
-
}
|
|
779
|
-
catch (_a) {
|
|
780
|
-
return false;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
797
|
}
|
|
784
798
|
/**
|
|
785
799
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -2324,6 +2338,8 @@
|
|
|
2324
2338
|
/**
|
|
2325
2339
|
* A function that adds padding to the book content
|
|
2326
2340
|
*
|
|
2341
|
+
* Note: [🔂] This function is idempotent.
|
|
2342
|
+
*
|
|
2327
2343
|
* @public exported from `@promptbook/core`
|
|
2328
2344
|
*/
|
|
2329
2345
|
function padBook(content) {
|
|
@@ -2369,6 +2385,8 @@
|
|
|
2369
2385
|
* This function should be used when you have a string that you know represents agent source
|
|
2370
2386
|
* but need to convert it to the branded type for type safety
|
|
2371
2387
|
*
|
|
2388
|
+
* Note: [🔂] This function is idempotent.
|
|
2389
|
+
*
|
|
2372
2390
|
* @public exported from `@promptbook/core`
|
|
2373
2391
|
*/
|
|
2374
2392
|
function validateBook(source) {
|
|
@@ -2400,15 +2418,20 @@
|
|
|
2400
2418
|
*/
|
|
2401
2419
|
const REMOTE_SERVER_URLS = [
|
|
2402
2420
|
{
|
|
2403
|
-
title: 'Promptbook',
|
|
2404
|
-
description: `
|
|
2421
|
+
title: 'Promptbook.Studio',
|
|
2422
|
+
description: `Server of Promptbook.studio`,
|
|
2405
2423
|
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
2406
|
-
isAnonymousModeAllowed: true,
|
|
2407
2424
|
urls: [
|
|
2408
2425
|
'https://promptbook.s5.ptbk.io/',
|
|
2409
2426
|
// Note: Servers 1-4 are not running
|
|
2410
2427
|
],
|
|
2411
2428
|
},
|
|
2429
|
+
{
|
|
2430
|
+
title: 'Testing Agents',
|
|
2431
|
+
description: `Testing Agents server on Vercel`,
|
|
2432
|
+
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
2433
|
+
urls: ['https://s6.ptbk.io/'],
|
|
2434
|
+
},
|
|
2412
2435
|
/*
|
|
2413
2436
|
Note: Working on older version of Promptbook and not supported anymore
|
|
2414
2437
|
{
|
|
@@ -2653,9 +2676,6 @@
|
|
|
2653
2676
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
2654
2677
|
}
|
|
2655
2678
|
}
|
|
2656
|
-
/**
|
|
2657
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
2658
|
-
*/
|
|
2659
2679
|
|
|
2660
2680
|
/**
|
|
2661
2681
|
* Color object represents an RGB color with alpha channel
|
|
@@ -3503,36 +3523,6 @@
|
|
|
3503
3523
|
* TODO: [🍏] Implement for MacOs
|
|
3504
3524
|
*/
|
|
3505
3525
|
|
|
3506
|
-
/**
|
|
3507
|
-
* Tests if given string is valid URL.
|
|
3508
|
-
*
|
|
3509
|
-
* Note: [🔂] This function is idempotent.
|
|
3510
|
-
* Note: Dataurl are considered perfectly valid.
|
|
3511
|
-
* Note: There are two similar functions:
|
|
3512
|
-
* - `isValidUrl` which tests any URL
|
|
3513
|
-
* - `isValidPipelineUrl` *(this one)* which tests just promptbook URL
|
|
3514
|
-
*
|
|
3515
|
-
* @public exported from `@promptbook/utils`
|
|
3516
|
-
*/
|
|
3517
|
-
function isValidUrl(url) {
|
|
3518
|
-
if (typeof url !== 'string') {
|
|
3519
|
-
return false;
|
|
3520
|
-
}
|
|
3521
|
-
try {
|
|
3522
|
-
if (url.startsWith('blob:')) {
|
|
3523
|
-
url = url.replace(/^blob:/, '');
|
|
3524
|
-
}
|
|
3525
|
-
const urlObject = new URL(url /* because fail is handled */);
|
|
3526
|
-
if (!['http:', 'https:', 'data:'].includes(urlObject.protocol)) {
|
|
3527
|
-
return false;
|
|
3528
|
-
}
|
|
3529
|
-
return true;
|
|
3530
|
-
}
|
|
3531
|
-
catch (error) {
|
|
3532
|
-
return false;
|
|
3533
|
-
}
|
|
3534
|
-
}
|
|
3535
|
-
|
|
3536
3526
|
const defaultDiacriticsRemovalMap = [
|
|
3537
3527
|
{
|
|
3538
3528
|
base: 'A',
|
|
@@ -4505,8 +4495,7 @@
|
|
|
4505
4495
|
|
|
4506
4496
|
## Servers
|
|
4507
4497
|
|
|
4508
|
-
${block(REMOTE_SERVER_URLS.map(({ title, urls,
|
|
4509
|
-
${isAnonymousModeAllowed ? '🐱💻 ' : ''} ${urls.join(', ')}
|
|
4498
|
+
${block(REMOTE_SERVER_URLS.map(({ title, urls, description }, index) => `${index + 1}. ${title} ${description} ${urls.join(', ')}
|
|
4510
4499
|
`).join('\n'))}
|
|
4511
4500
|
`);
|
|
4512
4501
|
fullInfoPieces.push(serversInfo);
|
|
@@ -4926,7 +4915,7 @@
|
|
|
4926
4915
|
const uploadResults = await Promise.all(uploadPromises);
|
|
4927
4916
|
// Note: This is a simplified implementation. A more robust solution would
|
|
4928
4917
|
// determine the drop position in the editor and insert the text there.
|
|
4929
|
-
const newText = uploadResults.map((fileSrc) => `KNOWLEDGE
|
|
4918
|
+
const newText = uploadResults.map((fileSrc) => `KNOWLEDGE ${fileSrc}`).join('\n');
|
|
4930
4919
|
const currentValue = value || '';
|
|
4931
4920
|
const newValue = currentValue + '\n' + newText;
|
|
4932
4921
|
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
@@ -5086,6 +5075,38 @@
|
|
|
5086
5075
|
return jsxRuntime.jsx(AvatarProfile, { ...rest, agent: agent, agentSource: agentSource });
|
|
5087
5076
|
}
|
|
5088
5077
|
|
|
5078
|
+
/**
|
|
5079
|
+
* Restricts an Updatable to a (2) BehaviorSubject variant
|
|
5080
|
+
*
|
|
5081
|
+
* @see Updatable
|
|
5082
|
+
* @private internal utility <- TODO: [🧠] Maybe export from `@promptbook/types`
|
|
5083
|
+
*/
|
|
5084
|
+
function asUpdatableSubject(value) {
|
|
5085
|
+
if (value instanceof rxjs.BehaviorSubject) {
|
|
5086
|
+
return value;
|
|
5087
|
+
}
|
|
5088
|
+
else if (Array.isArray(value)) {
|
|
5089
|
+
if (value.length !== 2) {
|
|
5090
|
+
throw new TypeError('`asUpdatableSubject`: Invalid tuple length, expected 2 elements');
|
|
5091
|
+
}
|
|
5092
|
+
if (typeof value[1] !== 'function') {
|
|
5093
|
+
throw new TypeError('`asUpdatableSubject`: Invalid tuple, expected second element to be a function');
|
|
5094
|
+
}
|
|
5095
|
+
const [theValue, setValue] = value;
|
|
5096
|
+
const subject = new rxjs.BehaviorSubject(theValue);
|
|
5097
|
+
subject.subscribe((newValue) => {
|
|
5098
|
+
setValue(newValue);
|
|
5099
|
+
});
|
|
5100
|
+
return subject;
|
|
5101
|
+
}
|
|
5102
|
+
else {
|
|
5103
|
+
return new rxjs.BehaviorSubject(value);
|
|
5104
|
+
}
|
|
5105
|
+
}
|
|
5106
|
+
/**
|
|
5107
|
+
* TODO: [🧠] Maybe `BehaviorSubject` is too heavy for this use case, maybe just tuple `[value,setValue]` is enough
|
|
5108
|
+
*/
|
|
5109
|
+
|
|
5089
5110
|
/**
|
|
5090
5111
|
* Calculates distance between two colors
|
|
5091
5112
|
*
|
|
@@ -6545,53 +6566,6 @@
|
|
|
6545
6566
|
placeholder: "Add a note (optional)", defaultValue: textRating, onChange: (e) => setTextRating(e.target.value), className: chatStyles.ratingInput }), jsxRuntime.jsxs("div", { className: chatStyles.ratingActions, children: [jsxRuntime.jsx("button", { onClick: () => setRatingModalOpen(false), children: "Cancel" }), jsxRuntime.jsx("button", { onClick: submitRating, children: "Submit" })] })] }) }))] }));
|
|
6546
6567
|
}
|
|
6547
6568
|
|
|
6548
|
-
/**
|
|
6549
|
-
* Hook to create a sendMessage function for an <LlmChat/> component WITHOUT needing any React Context.
|
|
6550
|
-
*
|
|
6551
|
-
* Usage pattern:
|
|
6552
|
-
* ```tsx
|
|
6553
|
-
* const sendMessage = useSendMessageToLlmChat();
|
|
6554
|
-
* return (
|
|
6555
|
-
* <>
|
|
6556
|
-
* <button onClick={() => sendMessage('Hello!')}>Hello</button>
|
|
6557
|
-
* <LlmChat llmTools={llmTools} sendMessage={sendMessage} />
|
|
6558
|
-
* </>
|
|
6559
|
-
* );
|
|
6560
|
-
* ```
|
|
6561
|
-
*
|
|
6562
|
-
* - No provider wrapping needed.
|
|
6563
|
-
* - Safe to call before the <LlmChat/> mounts (messages will be queued).
|
|
6564
|
-
* - Keeps DRY by letting <LlmChat/> reuse its internal `handleMessage` logic.
|
|
6565
|
-
*
|
|
6566
|
-
* @public exported from `@promptbook/components`
|
|
6567
|
-
*/
|
|
6568
|
-
function useSendMessageToLlmChat() {
|
|
6569
|
-
const ref = react.useRef(null);
|
|
6570
|
-
if (!ref.current) {
|
|
6571
|
-
let handler = null;
|
|
6572
|
-
const queue = [];
|
|
6573
|
-
const sendMessage = (message) => {
|
|
6574
|
-
if (handler) {
|
|
6575
|
-
// Fire and forget
|
|
6576
|
-
void handler(message);
|
|
6577
|
-
}
|
|
6578
|
-
else {
|
|
6579
|
-
queue.push(message);
|
|
6580
|
-
}
|
|
6581
|
-
};
|
|
6582
|
-
sendMessage._attach = (attachedHandler) => {
|
|
6583
|
-
handler = attachedHandler;
|
|
6584
|
-
// Flush queued messages
|
|
6585
|
-
while (queue.length > 0) {
|
|
6586
|
-
const next = queue.shift();
|
|
6587
|
-
void handler(next);
|
|
6588
|
-
}
|
|
6589
|
-
};
|
|
6590
|
-
ref.current = sendMessage;
|
|
6591
|
-
}
|
|
6592
|
-
return ref.current;
|
|
6593
|
-
}
|
|
6594
|
-
|
|
6595
6569
|
/**
|
|
6596
6570
|
* Utility functions for persisting chat conversations in localStorage
|
|
6597
6571
|
*
|
|
@@ -6845,6 +6819,96 @@
|
|
|
6845
6819
|
return (jsxRuntime.jsx(Chat, { ...restProps, messages, onReset, tasksProgress, participants, onMessage: handleMessage, onReset: handleReset }));
|
|
6846
6820
|
}
|
|
6847
6821
|
|
|
6822
|
+
/**
|
|
6823
|
+
* AgentChat component that provides chat functionality with LLM integration
|
|
6824
|
+
*
|
|
6825
|
+
* This component internally manages messages, participants, and task progress,
|
|
6826
|
+
* and uses the provided LLM tools to generate responses via `LlmExecutionTools.callChatModel`.
|
|
6827
|
+
*
|
|
6828
|
+
* Note: There are multiple chat components:
|
|
6829
|
+
* - `<Chat/>` renders chat as it is without any logic
|
|
6830
|
+
* - `<AgentChat/>` connected to LLM Execution Tools of Promptbook
|
|
6831
|
+
*
|
|
6832
|
+
* @public exported from `@promptbook/components`
|
|
6833
|
+
*/
|
|
6834
|
+
function AgentChat(props) {
|
|
6835
|
+
const { agent, title, persistenceKey, onChange, sendMessage, ...restProps } = props;
|
|
6836
|
+
return (jsxRuntime.jsx(LlmChat, { title: title || `Chat with ${agent.agentName || 'Agent'}`, persistenceKey: persistenceKey || `agent-chat-${agent.agentName || '!!!!!remove'}`, userParticipantName: "USER", llmParticipantName: "AGENT" // <- TODO: [🧠] Maybe dynamic agent id
|
|
6837
|
+
, initialMessages: [
|
|
6838
|
+
{
|
|
6839
|
+
from: 'AGENT',
|
|
6840
|
+
content: spaceTrim__default["default"](`
|
|
6841
|
+
|
|
6842
|
+
Hello! I am ${agent.agentName || 'an AI Agent'}.
|
|
6843
|
+
|
|
6844
|
+
[Hello](?message=Hello, can you tell me about yourself?)
|
|
6845
|
+
`),
|
|
6846
|
+
},
|
|
6847
|
+
], participants: [
|
|
6848
|
+
{
|
|
6849
|
+
name: 'AGENT',
|
|
6850
|
+
fullname: agent.agentName || 'Agent',
|
|
6851
|
+
avatarSrc: agent.meta.image,
|
|
6852
|
+
color: agent.meta.color,
|
|
6853
|
+
isMe: false,
|
|
6854
|
+
agentSource: asUpdatableSubject(agent.agentSource).getValue() /* <- TODO: !!!!! asValue */,
|
|
6855
|
+
},
|
|
6856
|
+
{
|
|
6857
|
+
name: 'USER',
|
|
6858
|
+
fullname: 'User',
|
|
6859
|
+
color: '#115EB6',
|
|
6860
|
+
isMe: true,
|
|
6861
|
+
},
|
|
6862
|
+
], llmTools: agent, onChange, sendMessage, ...restProps }));
|
|
6863
|
+
}
|
|
6864
|
+
|
|
6865
|
+
/**
|
|
6866
|
+
* Hook to create a sendMessage function for an <LlmChat/> component WITHOUT needing any React Context.
|
|
6867
|
+
*
|
|
6868
|
+
* Usage pattern:
|
|
6869
|
+
* ```tsx
|
|
6870
|
+
* const sendMessage = useSendMessageToLlmChat();
|
|
6871
|
+
* return (
|
|
6872
|
+
* <>
|
|
6873
|
+
* <button onClick={() => sendMessage('Hello!')}>Hello</button>
|
|
6874
|
+
* <LlmChat llmTools={llmTools} sendMessage={sendMessage} />
|
|
6875
|
+
* </>
|
|
6876
|
+
* );
|
|
6877
|
+
* ```
|
|
6878
|
+
*
|
|
6879
|
+
* - No provider wrapping needed.
|
|
6880
|
+
* - Safe to call before the <LlmChat/> mounts (messages will be queued).
|
|
6881
|
+
* - Keeps DRY by letting <LlmChat/> reuse its internal `handleMessage` logic.
|
|
6882
|
+
*
|
|
6883
|
+
* @public exported from `@promptbook/components`
|
|
6884
|
+
*/
|
|
6885
|
+
function useSendMessageToLlmChat() {
|
|
6886
|
+
const ref = react.useRef(null);
|
|
6887
|
+
if (!ref.current) {
|
|
6888
|
+
let handler = null;
|
|
6889
|
+
const queue = [];
|
|
6890
|
+
const sendMessage = (message) => {
|
|
6891
|
+
if (handler) {
|
|
6892
|
+
// Fire and forget
|
|
6893
|
+
void handler(message);
|
|
6894
|
+
}
|
|
6895
|
+
else {
|
|
6896
|
+
queue.push(message);
|
|
6897
|
+
}
|
|
6898
|
+
};
|
|
6899
|
+
sendMessage._attach = (attachedHandler) => {
|
|
6900
|
+
handler = attachedHandler;
|
|
6901
|
+
// Flush queued messages
|
|
6902
|
+
while (queue.length > 0) {
|
|
6903
|
+
const next = queue.shift();
|
|
6904
|
+
void handler(next);
|
|
6905
|
+
}
|
|
6906
|
+
};
|
|
6907
|
+
ref.current = sendMessage;
|
|
6908
|
+
}
|
|
6909
|
+
return ref.current;
|
|
6910
|
+
}
|
|
6911
|
+
|
|
6848
6912
|
/**
|
|
6849
6913
|
* Normal flow of messages in the `MockedChat` component
|
|
6850
6914
|
*
|
|
@@ -7455,6 +7519,7 @@
|
|
|
7455
7519
|
}
|
|
7456
7520
|
|
|
7457
7521
|
exports.AboutPromptbookInformation = AboutPromptbookInformation;
|
|
7522
|
+
exports.AgentChat = AgentChat;
|
|
7458
7523
|
exports.ArrowIcon = ArrowIcon;
|
|
7459
7524
|
exports.AttachmentIcon = AttachmentIcon;
|
|
7460
7525
|
exports.AvatarChip = AvatarChip;
|