@promptbook/utils 0.103.0-36 → 0.103.0-37
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 +15 -1
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +5 -1
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/errors/0-index.d.ts +3 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +44 -0
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +16 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -15
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +12 -0
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +2 -0
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +15 -1
- package/umd/index.umd.js.map +1 -1
|
@@ -56,7 +56,7 @@ export type LlmExecutionTools = {
|
|
|
56
56
|
callEmbeddingModel?(prompt: Prompt): Promise<EmbeddingPromptResult>;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
|
-
* TODO: [🕛] Extend this from sth class
|
|
59
|
+
* TODO: [🕛] Extend this from sth class - like `AgentBasicInformation` / `ModelBasicInformation``
|
|
60
60
|
* TODO: [🍚] Implement destroyable pattern to free resources
|
|
61
61
|
* TODO: [🏳] Add `callTranslationModel`
|
|
62
62
|
* TODO: [🧠] Emulation of one type of model with another one - emuate chat with completion; emulate translation with chat
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
import { AgentBasicInformation, BookParameter, LlmExecutionTools, string_agent_name, string_book, string_url_image } from '../../_packages/types.index';
|
|
3
|
+
import { AgentOptions } from './AgentOptions';
|
|
4
|
+
/**
|
|
5
|
+
* Note: !!!! `Agent` vs `LlmExecutionTools`
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @public exported from `@promptbook/core`
|
|
9
|
+
*/
|
|
10
|
+
export declare class Agent implements AgentBasicInformation {
|
|
11
|
+
private readonly options;
|
|
12
|
+
/**
|
|
13
|
+
* Name of the agent
|
|
14
|
+
*/
|
|
15
|
+
agentName: string_agent_name | null;
|
|
16
|
+
/**
|
|
17
|
+
* Description of the agent
|
|
18
|
+
*/
|
|
19
|
+
personaDescription: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Metadata like image or color
|
|
22
|
+
*/
|
|
23
|
+
meta: {
|
|
24
|
+
image?: string_url_image;
|
|
25
|
+
link?: string;
|
|
26
|
+
title?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
[key: string]: string | undefined;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Not used in Agent, always returns empty array
|
|
32
|
+
*/
|
|
33
|
+
get parameters(): BookParameter[];
|
|
34
|
+
readonly agentSource: BehaviorSubject<string_book>;
|
|
35
|
+
constructor(options: AgentOptions);
|
|
36
|
+
/**
|
|
37
|
+
* Creates LlmExecutionTools which exposes the agent as a model
|
|
38
|
+
*/
|
|
39
|
+
getLlmExecutionTools(): LlmExecutionTools;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
43
|
+
* TODO: !!! Agent on remote server
|
|
44
|
+
*/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CommonToolsOptions, ExecutionTools, string_book } from '../../_packages/types.index';
|
|
2
|
+
import { Updatable } from '../../types/Updatable';
|
|
3
|
+
/**
|
|
4
|
+
* Options for creating an Agent
|
|
5
|
+
*/
|
|
6
|
+
export type AgentOptions = CommonToolsOptions & {
|
|
7
|
+
/**
|
|
8
|
+
* The execution tools available to the agent
|
|
9
|
+
*
|
|
10
|
+
* Here the agent has access to various LLM models, browser, scrapers, LibreOffice, tools, etc.
|
|
11
|
+
*/
|
|
12
|
+
executionTools: ExecutionTools;
|
|
13
|
+
/**
|
|
14
|
+
* The source of the agent
|
|
15
|
+
*/
|
|
16
|
+
agentSource: Updatable<string_book>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { string_book } from '../../_packages/types.index';
|
|
2
|
+
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
|
+
import type { OpenAiAssistantExecutionTools } from '../openai/OpenAiAssistantExecutionTools';
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating AgentLlmExecutionTools
|
|
6
|
+
*/
|
|
7
|
+
export type CreateAgentLlmExecutionToolsOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* The underlying LLM execution tools to wrap
|
|
10
|
+
*/
|
|
11
|
+
llmTools: LlmExecutionTools | OpenAiAssistantExecutionTools;
|
|
12
|
+
/**
|
|
13
|
+
* The agent source string that defines the agent's behavior
|
|
14
|
+
*/
|
|
15
|
+
agentSource: string_book;
|
|
16
|
+
};
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
2
|
-
import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
|
|
3
1
|
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
|
-
};
|
|
2
|
+
import { CreateAgentLlmExecutionToolsOptions } from './CreateAgentLlmExecutionToolsOptions';
|
|
17
3
|
/**
|
|
18
4
|
* Creates new AgentLlmExecutionTools that wrap underlying LLM tools with agent-specific behavior
|
|
19
5
|
*
|
|
@@ -13,6 +13,7 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools implements LlmExecutionTools {
|
|
15
15
|
private readonly assistantId;
|
|
16
|
+
private readonly isCreatingNewAssistantsAllowed;
|
|
16
17
|
/**
|
|
17
18
|
* Creates OpenAI Execution Tools.
|
|
18
19
|
*
|
|
@@ -25,6 +26,17 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
|
|
|
25
26
|
* Calls OpenAI API to use a chat model.
|
|
26
27
|
*/
|
|
27
28
|
callChatModel(prompt: Pick<Prompt, 'content' | 'parameters' | 'modelRequirements' | 'format'>): Promise<ChatPromptResult>;
|
|
29
|
+
createNewAssistant(): Promise<OpenAiAssistantExecutionTools>;
|
|
30
|
+
/**
|
|
31
|
+
* Discriminant for type guards
|
|
32
|
+
*/
|
|
33
|
+
protected get discriminant(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAssistantExecutionTools`
|
|
36
|
+
*
|
|
37
|
+
* Note: This is useful when you can possibly have multiple versions of `@promptbook/openai` installed
|
|
38
|
+
*/
|
|
39
|
+
static isOpenAiAssistantExecutionTools(llmExecutionTools: LlmExecutionTools): llmExecutionTools is OpenAiAssistantExecutionTools;
|
|
28
40
|
}
|
|
29
41
|
/**
|
|
30
42
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizard for those who want to use just OpenAI
|
|
@@ -7,8 +7,14 @@ import type { OpenAiCompatibleExecutionToolsOptions } from './OpenAiCompatibleEx
|
|
|
7
7
|
* @public exported from `@promptbook/openai`
|
|
8
8
|
*/
|
|
9
9
|
export type OpenAiAssistantExecutionToolsOptions = OpenAiCompatibleExecutionToolsOptions & ClientOptions & {
|
|
10
|
+
/**
|
|
11
|
+
* Whether creating new assistants is allowed
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
readonly isCreatingNewAssistantsAllowed?: boolean;
|
|
10
16
|
/**
|
|
11
17
|
* Which assistant to use
|
|
12
18
|
*/
|
|
13
|
-
assistantId: string_token;
|
|
19
|
+
readonly assistantId: string_token;
|
|
14
20
|
};
|
|
@@ -11,6 +11,8 @@ import type { RemoteServerOptions } from './types/RemoteServerOptions';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function startRemoteServer<TCustomOptions = undefined>(options: RemoteServerOptions<TCustomOptions>): RemoteServer;
|
|
13
13
|
/**
|
|
14
|
+
* TODO !!!! Add agent
|
|
15
|
+
* TODO: !!!! Allow to chat with agents directly via remote server
|
|
14
16
|
* TODO: [🕋] Use here `aboutPromptbookInformation`
|
|
15
17
|
* TODO: [🌡] Add CORS and security - probably via `helmet`
|
|
16
18
|
* TODO: Split this file into multiple functions - handler for each request
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* A type that represents a value that can be updated over time:
|
|
4
|
+
*
|
|
5
|
+
* 1) It can be a static value of type `TValue`
|
|
6
|
+
* 2) Or a `BehaviorSubject` that emits values of type `TValue`
|
|
7
|
+
* 3) Or pair of `[getValue, setValue]` functions for getting and setting the value
|
|
8
|
+
*/
|
|
9
|
+
export type Updatable<TValue> = TValue | BehaviorSubject<TValue> | [TValue, (value: TValue) => void];
|
|
10
|
+
/**
|
|
11
|
+
* Restricts an Updatable to a (2) BehaviorSubject variant
|
|
12
|
+
*
|
|
13
|
+
* @see Updatable
|
|
14
|
+
* @private internal utility <- TODO: [🧠] Maybe export from `@promptbook/types`
|
|
15
|
+
*/
|
|
16
|
+
export declare function asUpdatableSubject<TValue>(value: Updatable<TValue>): BehaviorSubject<TValue>;
|
|
17
|
+
/**
|
|
18
|
+
* TODO: [🧠] Maybe `BehaviorSubject` is too heavy for this use case, maybe just tuple `[value,setValue]` is enough
|
|
19
|
+
*/
|
|
@@ -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-36`).
|
|
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.103.0-
|
|
25
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-37';
|
|
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
|
|
@@ -2161,6 +2161,19 @@
|
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
2163
|
|
|
2164
|
+
/**
|
|
2165
|
+
* This error indicates that promptbook operation is not allowed
|
|
2166
|
+
*
|
|
2167
|
+
* @public exported from `@promptbook/core`
|
|
2168
|
+
*/
|
|
2169
|
+
class NotAllowed extends Error {
|
|
2170
|
+
constructor(message) {
|
|
2171
|
+
super(message);
|
|
2172
|
+
this.name = 'NotAllowed';
|
|
2173
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
2174
|
+
}
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2164
2177
|
/**
|
|
2165
2178
|
* This error indicates that promptbook not found in the collection
|
|
2166
2179
|
*
|
|
@@ -2310,6 +2323,7 @@
|
|
|
2310
2323
|
PromptbookFetchError,
|
|
2311
2324
|
UnexpectedError,
|
|
2312
2325
|
WrappedError,
|
|
2326
|
+
NotAllowed,
|
|
2313
2327
|
// TODO: [🪑]> VersionMismatchError,
|
|
2314
2328
|
};
|
|
2315
2329
|
/**
|