@promptbook/openai 0.103.0-37 → 0.103.0-40
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/README.md +7 -9
- package/esm/index.es.js +39 -11
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/src/_packages/core.index.d.ts +12 -10
- package/esm/typings/src/_packages/node.index.d.ts +4 -2
- package/esm/typings/src/_packages/types.index.d.ts +3 -1
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +1 -1
- package/esm/typings/src/cli/cli-commands/start-agents-server.d.ts +14 -0
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-pipelines-server.d.ts} +2 -2
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +36 -0
- package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts +88 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -10
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/config.d.ts +8 -1
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +6 -1
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +9 -4
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +0 -4
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +17 -1
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +1 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +22 -8
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +1 -1
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +4 -3
- package/umd/index.umd.js +42 -15
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.test.d.ts → agent-collection/constructors/AgentCollectionInDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromJson.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
|
@@ -16,11 +16,11 @@ import { getAllCommitmentDefinitions } from '../book-2.0/commitments/index';
|
|
|
16
16
|
import { getAllCommitmentTypes } from '../book-2.0/commitments/index';
|
|
17
17
|
import { isCommitmentSupported } from '../book-2.0/commitments/index';
|
|
18
18
|
import { generatePlaceholderAgentProfileImageUrl } from '../book-2.0/utils/generatePlaceholderAgentProfileImageUrl';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
19
|
+
import { createPipelineCollectionFromJson } from '../collection/pipeline-collection/constructors/createPipelineCollectionFromJson';
|
|
20
|
+
import { createPipelineCollectionFromPromise } from '../collection/pipeline-collection/constructors/createPipelineCollectionFromPromise';
|
|
21
|
+
import { createPipelineCollectionFromUrl } from '../collection/pipeline-collection/constructors/createPipelineCollectionFromUrl';
|
|
22
|
+
import { createPipelineSubcollection } from '../collection/pipeline-collection/constructors/createPipelineSubcollection';
|
|
23
|
+
import { pipelineCollectionToJson } from '../collection/pipeline-collection/pipelineCollectionToJson';
|
|
24
24
|
import { NAME } from '../config';
|
|
25
25
|
import { ADMIN_EMAIL } from '../config';
|
|
26
26
|
import { ADMIN_GITHUB_NAME } from '../config';
|
|
@@ -44,6 +44,7 @@ import { DEFAULT_MAX_EXECUTION_ATTEMPTS } from '../config';
|
|
|
44
44
|
import { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH } from '../config';
|
|
45
45
|
import { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL } from '../config';
|
|
46
46
|
import { DEFAULT_BOOKS_DIRNAME } from '../config';
|
|
47
|
+
import { DEFAULT_AGENTS_DIRNAME } from '../config';
|
|
47
48
|
import { DEFAULT_DOWNLOAD_CACHE_DIRNAME } from '../config';
|
|
48
49
|
import { DEFAULT_EXECUTION_CACHE_DIRNAME } from '../config';
|
|
49
50
|
import { DEFAULT_SCRAPE_CACHE_DIRNAME } from '../config';
|
|
@@ -200,11 +201,11 @@ export { getAllCommitmentDefinitions };
|
|
|
200
201
|
export { getAllCommitmentTypes };
|
|
201
202
|
export { isCommitmentSupported };
|
|
202
203
|
export { generatePlaceholderAgentProfileImageUrl };
|
|
203
|
-
export {
|
|
204
|
-
export {
|
|
205
|
-
export {
|
|
206
|
-
export {
|
|
207
|
-
export {
|
|
204
|
+
export { createPipelineCollectionFromJson };
|
|
205
|
+
export { createPipelineCollectionFromPromise };
|
|
206
|
+
export { createPipelineCollectionFromUrl };
|
|
207
|
+
export { createPipelineSubcollection };
|
|
208
|
+
export { pipelineCollectionToJson };
|
|
208
209
|
export { NAME };
|
|
209
210
|
export { ADMIN_EMAIL };
|
|
210
211
|
export { ADMIN_GITHUB_NAME };
|
|
@@ -228,6 +229,7 @@ export { DEFAULT_MAX_EXECUTION_ATTEMPTS };
|
|
|
228
229
|
export { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH };
|
|
229
230
|
export { DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL };
|
|
230
231
|
export { DEFAULT_BOOKS_DIRNAME };
|
|
232
|
+
export { DEFAULT_AGENTS_DIRNAME };
|
|
231
233
|
export { DEFAULT_DOWNLOAD_CACHE_DIRNAME };
|
|
232
234
|
export { DEFAULT_EXECUTION_CACHE_DIRNAME };
|
|
233
235
|
export { DEFAULT_SCRAPE_CACHE_DIRNAME };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION } from '../version';
|
|
2
|
-
import {
|
|
2
|
+
import { AgentCollectionInDirectory } from '../collection/agent-collection/constructors/AgentCollectionInDirectory';
|
|
3
|
+
import { createPipelineCollectionFromDirectory } from '../collection/pipeline-collection/constructors/createPipelineCollectionFromDirectory';
|
|
3
4
|
import { $provideExecutablesForNode } from '../executables/$provideExecutablesForNode';
|
|
4
5
|
import { $provideExecutionToolsForNode } from '../execution/utils/$provideExecutionToolsForNode';
|
|
5
6
|
import { $provideLlmToolsConfigurationFromEnv } from '../llm-providers/_common/register/$provideLlmToolsConfigurationFromEnv';
|
|
@@ -11,7 +12,8 @@ import { FileCacheStorage } from '../storage/file-cache-storage/FileCacheStorage
|
|
|
11
12
|
import { $execCommand } from '../utils/execCommand/$execCommand';
|
|
12
13
|
import { $execCommands } from '../utils/execCommand/$execCommands';
|
|
13
14
|
export { BOOK_LANGUAGE_VERSION, PROMPTBOOK_ENGINE_VERSION };
|
|
14
|
-
export {
|
|
15
|
+
export { AgentCollectionInDirectory };
|
|
16
|
+
export { createPipelineCollectionFromDirectory };
|
|
15
17
|
export { $provideExecutablesForNode };
|
|
16
18
|
export { $provideExecutionToolsForNode };
|
|
17
19
|
export { $provideLlmToolsConfigurationFromEnv };
|
|
@@ -22,7 +22,8 @@ import type { ChatMessage } from '../book-components/Chat/types/ChatMessage';
|
|
|
22
22
|
import type { ChatParticipant } from '../book-components/Chat/types/ChatParticipant';
|
|
23
23
|
import type { MessageButton } from '../book-components/Chat/utils/parseMessageButtons';
|
|
24
24
|
import type { QrCodeOptions } from '../book-components/Qr/useQrCode';
|
|
25
|
-
import type {
|
|
25
|
+
import type { AgentCollection } from '../collection/agent-collection/AgentCollection';
|
|
26
|
+
import type { PipelineCollection } from '../collection/pipeline-collection/PipelineCollection';
|
|
26
27
|
import type { Command } from '../commands/_common/types/Command';
|
|
27
28
|
import type { CommandParser } from '../commands/_common/types/CommandParser';
|
|
28
29
|
import type { PipelineBothCommandParser } from '../commands/_common/types/CommandParser';
|
|
@@ -362,6 +363,7 @@ export type { ChatMessage };
|
|
|
362
363
|
export type { ChatParticipant };
|
|
363
364
|
export type { MessageButton };
|
|
364
365
|
export type { QrCodeOptions };
|
|
366
|
+
export type { AgentCollection };
|
|
365
367
|
export type { PipelineCollection };
|
|
366
368
|
export type { Command };
|
|
367
369
|
export type { CommandParser };
|
|
@@ -9,5 +9,5 @@ export declare function Modal({ children, onClose, className, }: {
|
|
|
9
9
|
className?: string;
|
|
10
10
|
}): import("react").ReactPortal;
|
|
11
11
|
/**
|
|
12
|
-
* TODO:
|
|
12
|
+
* TODO: Use this also for feedback modal in Chat component - Make modals DRY
|
|
13
13
|
*/
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command as Program } from 'commander';
|
|
2
|
+
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
|
+
/**
|
|
4
|
+
* Initializes `start-agents-server` command for Promptbook CLI utilities
|
|
5
|
+
*
|
|
6
|
+
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
|
|
7
|
+
*
|
|
8
|
+
* @private internal function of `promptbookCli`
|
|
9
|
+
*/
|
|
10
|
+
export declare function $initializeStartAgentsServerCommand(program: Program): $side_effect;
|
|
11
|
+
/**
|
|
12
|
+
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
13
|
+
* Note: [🟡] Code in this file should never be published outside of `@promptbook/cli`
|
|
14
|
+
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Command as Program } from 'commander';
|
|
2
2
|
import { $side_effect } from '../../utils/organization/$side_effect';
|
|
3
3
|
/**
|
|
4
|
-
* Initializes `start-server` command for Promptbook CLI utilities
|
|
4
|
+
* Initializes `start-pipelines-server` command for Promptbook CLI utilities
|
|
5
5
|
*
|
|
6
6
|
* Note: `$` is used to indicate that this function is not a pure function - it registers a command in the CLI
|
|
7
7
|
*
|
|
8
8
|
* @private internal function of `promptbookCli`
|
|
9
9
|
*/
|
|
10
|
-
export declare function $
|
|
10
|
+
export declare function $initializeStartPipelinesServerCommand(program: Program): $side_effect;
|
|
11
11
|
/**
|
|
12
12
|
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
13
13
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Promisable } from 'type-fest';
|
|
2
|
+
import { Agent } from '../../_packages/core.index';
|
|
3
|
+
import { string_book } from '../../_packages/types.index';
|
|
4
|
+
import type { string_agent_name } from '../../types/typeAliases';
|
|
5
|
+
/**
|
|
6
|
+
* Collection that groups together multiple AI Agents
|
|
7
|
+
*
|
|
8
|
+
* Note: [🧸] There are two types of collections:
|
|
9
|
+
* - `AgentCollection` - which groups together AI Agents
|
|
10
|
+
* - `PipelineCollection` - which groups together *(deprecated)* pipelines
|
|
11
|
+
*/
|
|
12
|
+
export type AgentCollection = {
|
|
13
|
+
/**
|
|
14
|
+
* Gets all agents in the collection
|
|
15
|
+
*/
|
|
16
|
+
listAgents(): Promisable<ReadonlyArray<string_agent_name>>;
|
|
17
|
+
/**
|
|
18
|
+
* Get one agent by its name
|
|
19
|
+
*
|
|
20
|
+
* Note: Agents are existing independently of you getting them or not, you can get the same agent multiple times.
|
|
21
|
+
* Note: Agents are changed by interacting with `Agent` objects directly. Only creation and deletion is done via the collection.
|
|
22
|
+
*/
|
|
23
|
+
getAgentByName(agentName: string_agent_name): Promisable<Agent>;
|
|
24
|
+
/**
|
|
25
|
+
* Deletes an agent from the collection
|
|
26
|
+
*
|
|
27
|
+
* Note: When you want delete an agent by name, first get the agent using `getAgentByName` and then pass it to `deleteAgent`.
|
|
28
|
+
*/
|
|
29
|
+
deleteAgent(agent: Agent): Promisable<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a new agent in the collection
|
|
32
|
+
*
|
|
33
|
+
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
34
|
+
*/
|
|
35
|
+
createAgent(agentSource: string_book): Promisable<Agent>;
|
|
36
|
+
};
|
package/esm/typings/src/collection/agent-collection/constructors/AgentCollectionInDirectory.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Agent } from '../../../_packages/core.index';
|
|
2
|
+
import { CommonToolsOptions, string_book } from '../../../_packages/types.index';
|
|
3
|
+
import type { ExecutionTools } from '../../../execution/ExecutionTools';
|
|
4
|
+
import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeOptions';
|
|
5
|
+
import type { string_agent_name, string_dirname } from '../../../types/typeAliases';
|
|
6
|
+
import type { AgentCollection } from '../AgentCollection';
|
|
7
|
+
/**
|
|
8
|
+
* Options for `createAgentCollectionFromDirectory` function
|
|
9
|
+
*
|
|
10
|
+
* Note: `rootDirname` is not needed because it is the folder in which `.book` or `.book` file is located
|
|
11
|
+
* This is not same as `path` which is the first argument of `createAgentCollectionFromDirectory` - it can be a subfolder
|
|
12
|
+
*/
|
|
13
|
+
type CreateAgentCollectionInDirectoryOptions = Omit<PrepareAndScrapeOptions, 'rootDirname'> & CommonToolsOptions & {
|
|
14
|
+
/**
|
|
15
|
+
* If true, the directory is searched recursively for pipelines
|
|
16
|
+
*
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
19
|
+
isRecursive?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If true, directory will be scanned only when needed not during the construction
|
|
22
|
+
*
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
isLazyLoaded?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* If true, whole collection creation crashes on error in any pipeline
|
|
28
|
+
* If true and isLazyLoaded is true, the error is thrown on first access to the pipeline
|
|
29
|
+
*
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
isCrashedOnError?: boolean;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Agent collection stored in directory
|
|
36
|
+
*
|
|
37
|
+
* Note: Works only in Node.js environment because it reads the file system
|
|
38
|
+
*
|
|
39
|
+
* @public exported from `@promptbook/node`
|
|
40
|
+
*/
|
|
41
|
+
export declare class AgentCollectionInDirectory implements AgentCollection {
|
|
42
|
+
readonly rootPath: string_dirname;
|
|
43
|
+
private readonly tools?;
|
|
44
|
+
readonly options?: CreateAgentCollectionInDirectoryOptions | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* @param rootPath - path to the directory with agents
|
|
47
|
+
* @param tools - Execution tools to be used in `Agent` itself and listing the agents
|
|
48
|
+
* @param options - Options for the collection creation
|
|
49
|
+
*/
|
|
50
|
+
constructor(rootPath: string_dirname, tools?: Pick<ExecutionTools, "llm" | "fs" | "scrapers"> | undefined, options?: CreateAgentCollectionInDirectoryOptions | undefined);
|
|
51
|
+
/**
|
|
52
|
+
* Cached defined execution tools
|
|
53
|
+
*/
|
|
54
|
+
private _definedTools;
|
|
55
|
+
/**
|
|
56
|
+
* Gets or creates execution tools for the collection
|
|
57
|
+
*/
|
|
58
|
+
private getTools;
|
|
59
|
+
/**
|
|
60
|
+
* Gets all agents in the collection
|
|
61
|
+
*/
|
|
62
|
+
listAgents(): Promise<ReadonlyArray<string_agent_name>>;
|
|
63
|
+
/**
|
|
64
|
+
* Get one agent by its name
|
|
65
|
+
*
|
|
66
|
+
* Note: Agents are existing independently of you getting them or not, you can get the same agent multiple times.
|
|
67
|
+
* Note: Agents are changed by interacting with `Agent` objects directly. Only creation and deletion is done via the collection.
|
|
68
|
+
*/
|
|
69
|
+
getAgentByName(agentName: string_agent_name): Promise<Agent>;
|
|
70
|
+
/**
|
|
71
|
+
* Deletes an agent from the collection
|
|
72
|
+
*
|
|
73
|
+
* Note: When you want delete an agent by name, first get the agent using `getAgentByName` and then pass it to `deleteAgent`.
|
|
74
|
+
*/
|
|
75
|
+
deleteAgent(agent: Agent): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new agent in the collection
|
|
78
|
+
*
|
|
79
|
+
* Note: You can set 'PARENT' in the agent source to inherit from another agent in the collection.
|
|
80
|
+
*/
|
|
81
|
+
createAgent(agentSource: string_book): Promise<Agent>;
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
84
|
+
/**
|
|
85
|
+
* TODO: [🖇] What about symlinks? Maybe option `isSymlinksFollowed`
|
|
86
|
+
* TODO: [🧠] Maybe add option `isImmutable`
|
|
87
|
+
* Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
|
|
88
|
+
*/
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { PipelineJson } from '
|
|
3
|
-
import type { Prompt } from '
|
|
4
|
-
import type { string_pipeline_url } from '
|
|
2
|
+
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
3
|
+
import type { Prompt } from '../../types/Prompt';
|
|
4
|
+
import type { string_pipeline_url } from '../../types/typeAliases';
|
|
5
5
|
/**
|
|
6
6
|
* Collection that groups together pipelines, knowledge, personas, tools and actions
|
|
7
|
+
*
|
|
8
|
+
* Note: [🧸] There are two types of collections:
|
|
9
|
+
* - `AgentCollection` - which groups together AI Agents
|
|
10
|
+
* - `PipelineCollection` - which groups together *(deprecated)* pipelines
|
|
7
11
|
*/
|
|
8
12
|
export type PipelineCollection = {
|
|
9
13
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { PipelineJson } from '
|
|
2
|
-
import type { Prompt } from '
|
|
3
|
-
import type { string_pipeline_url } from '
|
|
1
|
+
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { Prompt } from '../../types/Prompt';
|
|
3
|
+
import type { string_pipeline_url } from '../../types/typeAliases';
|
|
4
4
|
import type { PipelineCollection } from './PipelineCollection';
|
|
5
5
|
/**
|
|
6
6
|
* Library of pipelines that groups together pipelines for an application.
|
|
7
7
|
* This implementation is a very thin wrapper around the Array / Map of pipelines.
|
|
8
8
|
*
|
|
9
|
-
* @private internal function of `
|
|
9
|
+
* @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
|
|
10
10
|
* @see https://github.com/webgptorg/pipeline#pipeline-collection
|
|
11
11
|
*/
|
|
12
12
|
export declare class SimplePipelineCollection implements PipelineCollection {
|
|
@@ -17,7 +17,7 @@ export declare class SimplePipelineCollection implements PipelineCollection {
|
|
|
17
17
|
* @param pipelines Array of pipeline JSON objects to include in the collection
|
|
18
18
|
*
|
|
19
19
|
* Note: During the construction logic of all pipelines are validated
|
|
20
|
-
* Note: It is not recommended to use this constructor directly, use `
|
|
20
|
+
* Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
|
|
21
21
|
*/
|
|
22
22
|
constructor(...pipelines: ReadonlyArray<PipelineJson>);
|
|
23
23
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ExecutionTools } from '
|
|
2
|
-
import type { PrepareAndScrapeOptions } from '
|
|
3
|
-
import type { string_dirname, string_pipeline_root_url } from '
|
|
1
|
+
import type { ExecutionTools } from '../../../execution/ExecutionTools';
|
|
2
|
+
import type { PrepareAndScrapeOptions } from '../../../prepare/PrepareAndScrapeOptions';
|
|
3
|
+
import type { string_dirname, string_pipeline_root_url } from '../../../types/typeAliases';
|
|
4
4
|
import type { PipelineCollection } from '../PipelineCollection';
|
|
5
5
|
/**
|
|
6
|
-
* Options for `
|
|
6
|
+
* Options for `createPipelineCollectionFromDirectory` function
|
|
7
7
|
*
|
|
8
8
|
* Note: `rootDirname` is not needed because it is the folder in which `.book` or `.book` file is located
|
|
9
|
-
* This is not same as `path` which is the first argument of `
|
|
9
|
+
* This is not same as `path` which is the first argument of `createPipelineCollectionFromDirectory` - it can be a subfolder
|
|
10
10
|
*/
|
|
11
11
|
type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions, 'rootDirname'> & {
|
|
12
12
|
/**
|
|
@@ -27,8 +27,6 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
27
27
|
* It has 2 purposes:
|
|
28
28
|
* 1) Every pipeline in the collection is checked if it is a child of `rootUrl`
|
|
29
29
|
* 2) If the pipeline does not have a URL, it is created from the `rootUrl` and path to the pipeline
|
|
30
|
-
*
|
|
31
|
-
* @default false
|
|
32
30
|
*/
|
|
33
31
|
rootUrl?: string_pipeline_root_url;
|
|
34
32
|
/**
|
|
@@ -46,7 +44,7 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
46
44
|
isCrashedOnError?: boolean;
|
|
47
45
|
};
|
|
48
46
|
/**
|
|
49
|
-
* Constructs
|
|
47
|
+
* Constructs `PipelineCollection` from given directory
|
|
50
48
|
*
|
|
51
49
|
* Note: Works only in Node.js environment because it reads the file system
|
|
52
50
|
*
|
|
@@ -56,9 +54,9 @@ type CreatePipelineCollectionFromDirectoryOptions = Omit<PrepareAndScrapeOptions
|
|
|
56
54
|
* @returns PipelineCollection
|
|
57
55
|
* @public exported from `@promptbook/node`
|
|
58
56
|
*/
|
|
59
|
-
export declare function
|
|
57
|
+
export declare function createPipelineCollectionFromDirectory(rootPath: string_dirname, tools?: Pick<ExecutionTools, 'llm' | 'fs' | 'scrapers'>, options?: CreatePipelineCollectionFromDirectoryOptions): Promise<PipelineCollection>;
|
|
60
58
|
export {};
|
|
61
59
|
/**
|
|
62
|
-
* TODO: [🖇] What about symlinks? Maybe option isSymlinksFollowed
|
|
60
|
+
* TODO: [🖇] What about symlinks? Maybe option `isSymlinksFollowed`
|
|
63
61
|
* TODO: Maybe move from `@promptbook/node` to `@promptbook/core` as we removes direct dependency on `fs`
|
|
64
62
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { PipelineCollection } from '../PipelineCollection';
|
|
3
|
+
/**
|
|
4
|
+
* Creates `PipelineCollection` from array of PipelineJson or PipelineString
|
|
5
|
+
*
|
|
6
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
7
|
+
* Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
|
|
8
|
+
*
|
|
9
|
+
* @param promptbookSources
|
|
10
|
+
* @returns PipelineCollection
|
|
11
|
+
* @public exported from `@promptbook/core`
|
|
12
|
+
*/
|
|
13
|
+
export declare function createPipelineCollectionFromJson(...promptbooks: ReadonlyArray<PipelineJson>): PipelineCollection;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import type { PipelineJson } from '
|
|
1
|
+
import type { PipelineJson } from '../../../pipeline/PipelineJson/PipelineJson';
|
|
2
2
|
import type { PipelineCollection } from '../PipelineCollection';
|
|
3
3
|
/**
|
|
4
|
-
* Constructs
|
|
4
|
+
* Constructs `PipelineCollection` from async sources
|
|
5
|
+
*
|
|
5
6
|
* It can be one of the following:
|
|
6
7
|
* - Promise of array of PipelineJson or PipelineString
|
|
7
8
|
* - Factory function that returns Promise of array of PipelineJson or PipelineString
|
|
8
9
|
*
|
|
9
10
|
* Note: This is useful as internal tool for other constructor functions like
|
|
10
|
-
* `
|
|
11
|
+
* `createPipelineCollectionFromUrl` or `createPipelineCollectionFromDirectory`
|
|
11
12
|
* Consider using those functions instead of this one
|
|
12
13
|
*
|
|
13
14
|
* Note: The function does NOT return promise it returns the collection directly which waits for the sources to be resolved
|
|
14
15
|
* when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
|
|
15
16
|
*
|
|
16
|
-
* Note: Consider using `
|
|
17
|
+
* Note: Consider using `createPipelineCollectionFromDirectory` or `createPipelineCollectionFromUrl`
|
|
17
18
|
*
|
|
18
19
|
* @param promptbookSourcesPromiseOrFactory
|
|
19
20
|
* @returns PipelineCollection
|
|
20
21
|
* @deprecated Do not use, it will became internal tool for other constructor functions
|
|
21
22
|
* @public exported from `@promptbook/core`
|
|
22
23
|
*/
|
|
23
|
-
export declare function
|
|
24
|
+
export declare function createPipelineCollectionFromPromise(promptbookSourcesPromiseOrFactory: Promise<ReadonlyArray<PipelineJson>> | (() => Promise<ReadonlyArray<PipelineJson>>)): PipelineCollection;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { string_url } from '
|
|
1
|
+
import type { string_url } from '../../../types/typeAliases';
|
|
2
2
|
import type { PipelineCollection } from '../PipelineCollection';
|
|
3
3
|
/**
|
|
4
|
-
* Options for `
|
|
4
|
+
* Options for `createPipelineCollectionFromDirectory` function
|
|
5
5
|
*/
|
|
6
6
|
type CreatePipelineCollectionFromUrlyOptions = {
|
|
7
7
|
/**
|
|
@@ -22,7 +22,7 @@ type CreatePipelineCollectionFromUrlyOptions = {
|
|
|
22
22
|
* @returns PipelineCollection
|
|
23
23
|
* @public exported from `@promptbook/core`
|
|
24
24
|
*/
|
|
25
|
-
export declare function
|
|
25
|
+
export declare function createPipelineCollectionFromUrl(url: string_url | URL, options: CreatePipelineCollectionFromUrlyOptions): Promise<PipelineCollection>;
|
|
26
26
|
export {};
|
|
27
27
|
/**
|
|
28
28
|
* TODO: [main] !!4 [🧠] Library precompilation and do not mix markdown and json promptbooks
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { string_pipeline_url } from '
|
|
1
|
+
import type { string_pipeline_url } from '../../../types/typeAliases';
|
|
2
2
|
import type { PipelineCollection } from '../PipelineCollection';
|
|
3
3
|
/**
|
|
4
|
-
* Creates PipelineCollection as a subset of another PipelineCollection
|
|
4
|
+
* Creates `PipelineCollection` as a subset of another `PipelineCollection`
|
|
5
5
|
*
|
|
6
6
|
* Note: You can use any type of collection as a parent collection - local, remote, etc.
|
|
7
7
|
* Note: This is just a thin wrapper / proxy around the parent collection
|
|
@@ -10,4 +10,4 @@ import type { PipelineCollection } from '../PipelineCollection';
|
|
|
10
10
|
* @returns PipelineCollection
|
|
11
11
|
* @public exported from `@promptbook/core`
|
|
12
12
|
*/
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function createPipelineSubcollection(collection: PipelineCollection, predicate: (url: string_pipeline_url) => boolean): PipelineCollection;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
2
|
+
import type { PipelineCollection } from './PipelineCollection';
|
|
3
|
+
/**
|
|
4
|
+
* Converts PipelineCollection to serialized JSON
|
|
5
|
+
*
|
|
6
|
+
* Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/core`
|
|
9
|
+
*/
|
|
10
|
+
export declare function pipelineCollectionToJson(collection: PipelineCollection): Promise<ReadonlyArray<PipelineJson>>;
|
|
11
|
+
/**
|
|
12
|
+
* TODO: [🧠] Maybe clear `sourceFile` or clear when exposing through API or remote server
|
|
13
|
+
*/
|
|
@@ -233,6 +233,13 @@ export declare const DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
|
|
|
233
233
|
* @public exported from `@promptbook/core`
|
|
234
234
|
*/
|
|
235
235
|
export declare const DEFAULT_BOOKS_DIRNAME = "./books";
|
|
236
|
+
/**
|
|
237
|
+
* Where to store your agents (also book files)
|
|
238
|
+
* This is kind of a "src" for your books
|
|
239
|
+
*
|
|
240
|
+
* @public exported from `@promptbook/core`
|
|
241
|
+
*/
|
|
242
|
+
export declare const DEFAULT_AGENTS_DIRNAME = "./agents";
|
|
236
243
|
/**
|
|
237
244
|
* Where to store the temporary downloads
|
|
238
245
|
*
|
|
@@ -270,7 +277,7 @@ export declare const CLI_APP_ID: string_app_id;
|
|
|
270
277
|
*/
|
|
271
278
|
export declare const PLAYGROUND_APP_ID: string_app_id;
|
|
272
279
|
/**
|
|
273
|
-
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `
|
|
280
|
+
* The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createPipelineCollectionFromDirectory`
|
|
274
281
|
*
|
|
275
282
|
* @public exported from `@promptbook/core`
|
|
276
283
|
*/
|
|
@@ -3,7 +3,7 @@ import type fs from 'fs/promises';
|
|
|
3
3
|
/**
|
|
4
4
|
* Container for all the tools needed to manipulate with filesystem
|
|
5
5
|
*/
|
|
6
|
-
export type FilesystemTools = Pick<typeof fs, 'access' | 'constants' | 'readFile' | 'writeFile' | 'stat' | 'readdir' | 'mkdir'>;
|
|
6
|
+
export type FilesystemTools = Pick<typeof fs, 'access' | 'constants' | 'readFile' | 'writeFile' | 'stat' | 'readdir' | 'mkdir' | 'watch'>;
|
|
7
7
|
/**
|
|
8
8
|
* TODO: Implement destroyable pattern to free resources
|
|
9
9
|
*/
|
|
@@ -9,6 +9,12 @@ import type { ChatPromptResult, CompletionPromptResult, EmbeddingPromptResult }
|
|
|
9
9
|
* On its interface it exposes common methods for prompt execution.
|
|
10
10
|
* Inside (in constructor) it calls OpenAI, Azure, GPU, proxy, cache, logging,...
|
|
11
11
|
*
|
|
12
|
+
* Note: [🦖] There are several different things in Promptbook:
|
|
13
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
14
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
15
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
16
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
17
|
+
*
|
|
12
18
|
* @see https://github.com/webgptorg/promptbook#llm-execution-tools
|
|
13
19
|
*/
|
|
14
20
|
export type LlmExecutionTools = {
|
|
@@ -2,8 +2,13 @@ import { BehaviorSubject } from 'rxjs';
|
|
|
2
2
|
import { AgentBasicInformation, BookParameter, LlmExecutionTools, string_agent_name, string_book, string_url_image } from '../../_packages/types.index';
|
|
3
3
|
import { AgentOptions } from './AgentOptions';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Represents one AI Agent
|
|
6
6
|
*
|
|
7
|
+
* Note: [🦖] There are several different things in Promptbook:
|
|
8
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
9
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
10
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
11
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
7
12
|
*
|
|
8
13
|
* @public exported from `@promptbook/core`
|
|
9
14
|
*/
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import type { Promisable } from 'type-fest';
|
|
2
|
-
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
3
2
|
import type { ChatParticipant } from '../../book-components/Chat/types/ChatParticipant';
|
|
4
3
|
import type { AvailableModel } from '../../execution/AvailableModel';
|
|
5
4
|
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
6
5
|
import type { ChatPromptResult } from '../../execution/PromptResult';
|
|
7
6
|
import type { Prompt } from '../../types/Prompt';
|
|
8
7
|
import type { string_markdown, string_markdown_text, string_model_name, string_title } from '../../types/typeAliases';
|
|
8
|
+
import { CreateAgentLlmExecutionToolsOptions } from './CreateAgentLlmExecutionToolsOptions';
|
|
9
9
|
/**
|
|
10
10
|
* Execution Tools for calling LLM models with a predefined agent "soul"
|
|
11
11
|
* This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
|
|
12
12
|
*
|
|
13
|
+
* Note: [🦖] There are several different things in Promptbook:
|
|
14
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
15
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
16
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
17
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
18
|
+
*
|
|
13
19
|
* @public exported from `@promptbook/core`
|
|
14
20
|
*/
|
|
15
21
|
export declare class AgentLlmExecutionTools implements LlmExecutionTools {
|
|
16
|
-
private readonly
|
|
17
|
-
private readonly agentSource;
|
|
22
|
+
private readonly options;
|
|
18
23
|
/**
|
|
19
24
|
* Cached model requirements to avoid re-parsing the agent source
|
|
20
25
|
*/
|
|
@@ -29,7 +34,7 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
|
|
|
29
34
|
* @param llmTools The underlying LLM execution tools to wrap
|
|
30
35
|
* @param agentSource The agent source string that defines the agent's behavior
|
|
31
36
|
*/
|
|
32
|
-
constructor(
|
|
37
|
+
constructor(options: CreateAgentLlmExecutionToolsOptions);
|
|
33
38
|
/**
|
|
34
39
|
* Get cached or parse agent information
|
|
35
40
|
*/
|
|
@@ -9,7 +9,3 @@ export declare const createAgentLlmExecutionTools: ((options: CreateAgentLlmExec
|
|
|
9
9
|
packageName: string;
|
|
10
10
|
className: string;
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* TODO: [🧠] Consider adding validation for agent source format
|
|
14
|
-
* TODO: [🧠] Consider adding options for caching behavior
|
|
15
|
-
*/
|
|
@@ -9,6 +9,12 @@ 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:
|
|
13
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
14
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
15
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
16
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
17
|
+
*
|
|
12
18
|
* @public exported from `@promptbook/openai`
|
|
13
19
|
*/
|
|
14
20
|
export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
|
|
@@ -26,7 +32,17 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
|
|
|
26
32
|
* Calls OpenAI API to use a chat model.
|
|
27
33
|
*/
|
|
28
34
|
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
|
|
29
|
-
|
|
35
|
+
playground(): Promise<void>;
|
|
36
|
+
createNewAssistant(options: {
|
|
37
|
+
/**
|
|
38
|
+
* Name of the new assistant
|
|
39
|
+
*/
|
|
40
|
+
readonly name: string_title;
|
|
41
|
+
/**
|
|
42
|
+
* Instructions for the new assistant
|
|
43
|
+
*/
|
|
44
|
+
readonly instructions: string_markdown;
|
|
45
|
+
}): Promise<OpenAiAssistantExecutionTools>;
|
|
30
46
|
/**
|
|
31
47
|
* Discriminant for type guards
|
|
32
48
|
*/
|
|
@@ -18,7 +18,7 @@ export declare function startRemoteServer<TCustomOptions = undefined>(options: R
|
|
|
18
18
|
* TODO: Split this file into multiple functions - handler for each request
|
|
19
19
|
* TODO: Maybe use `$exportJson`
|
|
20
20
|
* TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
|
|
21
|
-
* TODO: [⚖] Expose the collection to be able to connect to same collection via
|
|
21
|
+
* TODO: [⚖] Expose the collection to be able to connect to same collection via createPipelineCollectionFromUrl
|
|
22
22
|
* TODO: Handle progress - support streaming
|
|
23
23
|
* TODO: [🗯] Do not hang up immediately but wait until client closes OR timeout
|
|
24
24
|
* TODO: [🗯] Timeout on chat to free up resources
|