@promptbook/openai 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 +114 -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 +2 -2
- package/umd/index.umd.js +114 -1
- package/umd/index.umd.js.map +1 -1
|
@@ -7,6 +7,7 @@ import { ExpectError } from './ExpectError';
|
|
|
7
7
|
import { KnowledgeScrapeError } from './KnowledgeScrapeError';
|
|
8
8
|
import { LimitReachedError } from './LimitReachedError';
|
|
9
9
|
import { MissingToolsError } from './MissingToolsError';
|
|
10
|
+
import { NotAllowed } from './NotAllowed';
|
|
10
11
|
import { NotFoundError } from './NotFoundError';
|
|
11
12
|
import { NotYetImplementedError } from './NotYetImplementedError';
|
|
12
13
|
import { ParseError } from './ParseError';
|
|
@@ -40,6 +41,7 @@ export declare const PROMPTBOOK_ERRORS: {
|
|
|
40
41
|
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
41
42
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
42
43
|
readonly WrappedError: typeof WrappedError;
|
|
44
|
+
readonly NotAllowed: typeof NotAllowed;
|
|
43
45
|
};
|
|
44
46
|
/**
|
|
45
47
|
* Index of all javascript errors
|
|
@@ -88,6 +90,7 @@ export declare const ALL_ERRORS: {
|
|
|
88
90
|
readonly PromptbookFetchError: typeof PromptbookFetchError;
|
|
89
91
|
readonly UnexpectedError: typeof UnexpectedError;
|
|
90
92
|
readonly WrappedError: typeof WrappedError;
|
|
93
|
+
readonly NotAllowed: typeof NotAllowed;
|
|
91
94
|
};
|
|
92
95
|
/**
|
|
93
96
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -46,5 +46,6 @@ export type AvailableModel = {
|
|
|
46
46
|
readonly isDeprecated?: boolean;
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
|
+
* TODO: [🕛] Extend this from sth like `AgentBasicInformation` / `ModelBasicInformation`
|
|
49
50
|
* TODO: [🧠] Maybe rename to something else - like `ModelInformation` or `ModelMetadata`
|
|
50
51
|
*/
|
|
@@ -67,3 +67,8 @@ export type ExecutionTools = {
|
|
|
67
67
|
*/
|
|
68
68
|
readonly userInterface?: UserInterfaceTools;
|
|
69
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* <- TODO: Add !!! `promptbookAgent` to `ExecutionTools`
|
|
72
|
+
* <- TODO: Add !!! `mcps` to `ExecutionTools`
|
|
73
|
+
* <- TODO: Add !!! `prepareCache` to `ExecutionTools`
|
|
74
|
+
*/
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptbook/openai",
|
|
3
|
-
"version": "0.103.0-
|
|
3
|
+
"version": "0.103.0-37",
|
|
4
4
|
"description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"module": "./esm/index.es.js",
|
|
103
103
|
"typings": "./esm/typings/src/_packages/openai.index.d.ts",
|
|
104
104
|
"peerDependencies": {
|
|
105
|
-
"@promptbook/core": "0.103.0-
|
|
105
|
+
"@promptbook/core": "0.103.0-37"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"bottleneck": "2.19.5",
|
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* @generated
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-37';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -71,6 +71,19 @@
|
|
|
71
71
|
* TODO: [🎺]
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* This error indicates that promptbook operation is not allowed
|
|
76
|
+
*
|
|
77
|
+
* @public exported from `@promptbook/core`
|
|
78
|
+
*/
|
|
79
|
+
class NotAllowed extends Error {
|
|
80
|
+
constructor(message) {
|
|
81
|
+
super(message);
|
|
82
|
+
this.name = 'NotAllowed';
|
|
83
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
74
87
|
/**
|
|
75
88
|
* This error type indicates that some part of the code is not implemented yet
|
|
76
89
|
*
|
|
@@ -3628,11 +3641,18 @@
|
|
|
3628
3641
|
* @param options which are relevant are directly passed to the OpenAI client
|
|
3629
3642
|
*/
|
|
3630
3643
|
constructor(options) {
|
|
3644
|
+
var _a;
|
|
3631
3645
|
if (options.isProxied) {
|
|
3632
3646
|
throw new NotYetImplementedError(`Proxy mode is not yet implemented for OpenAI assistants`);
|
|
3633
3647
|
}
|
|
3634
3648
|
super(options);
|
|
3649
|
+
this.isCreatingNewAssistantsAllowed = false;
|
|
3635
3650
|
this.assistantId = options.assistantId;
|
|
3651
|
+
this.isCreatingNewAssistantsAllowed = (_a = options.isCreatingNewAssistantsAllowed) !== null && _a !== void 0 ? _a : false;
|
|
3652
|
+
if (this.assistantId === null && !this.isCreatingNewAssistantsAllowed) {
|
|
3653
|
+
throw new NotAllowed(`Assistant ID is null and creating new assistants is not allowed - this configuration does not make sense`);
|
|
3654
|
+
}
|
|
3655
|
+
// <- TODO: !!! `OpenAiAssistantExecutionToolsOptions` - Allow `assistantId: null` together with `isCreatingNewAssistantsAllowed: true`
|
|
3636
3656
|
// TODO: [👱] Make limiter same as in `OpenAiExecutionTools`
|
|
3637
3657
|
}
|
|
3638
3658
|
get title() {
|
|
@@ -3777,7 +3797,99 @@
|
|
|
3777
3797
|
},
|
|
3778
3798
|
});
|
|
3779
3799
|
}
|
|
3800
|
+
async createNewAssistant() {
|
|
3801
|
+
if (!this.isCreatingNewAssistantsAllowed) {
|
|
3802
|
+
throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
|
|
3803
|
+
}
|
|
3804
|
+
const client = await this.getClient();
|
|
3805
|
+
/*
|
|
3806
|
+
TODO: !!!
|
|
3807
|
+
async function downloadFile(url: string, folder = './tmp'): Promise<string> {
|
|
3808
|
+
const filename = path.basename(url.split('?')[0]);
|
|
3809
|
+
const filepath = path.join(folder, filename);
|
|
3810
|
+
|
|
3811
|
+
if (!fs.existsSync(folder)) fs.mkdirSync(folder);
|
|
3812
|
+
|
|
3813
|
+
const res = await fetch(url);
|
|
3814
|
+
if (!res.ok) throw new Error(`Download error: ${url}`);
|
|
3815
|
+
const buffer = await res.arrayBuffer();
|
|
3816
|
+
fs.writeFileSync(filepath, Buffer.from(buffer));
|
|
3817
|
+
console.log(`📥 File downloaded: ${filename}`);
|
|
3818
|
+
|
|
3819
|
+
return filepath;
|
|
3820
|
+
}
|
|
3821
|
+
|
|
3822
|
+
async function uploadFileToOpenAI(filepath: string) {
|
|
3823
|
+
const file = await client.files.create({
|
|
3824
|
+
file: fs.createReadStream(filepath),
|
|
3825
|
+
purpose: 'assistants',
|
|
3826
|
+
});
|
|
3827
|
+
console.log(`⬆️ File uploaded to OpenAI: ${file.filename} (${file.id})`);
|
|
3828
|
+
return file;
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
// 🌐 URL addresses of files to upload
|
|
3832
|
+
const fileUrls = [
|
|
3833
|
+
'https://raw.githubusercontent.com/vercel/next.js/canary/packages/next/README.md',
|
|
3834
|
+
'https://raw.githubusercontent.com/openai/openai-cookbook/main/examples/How_to_call_the_Assistants_API_with_Node.js.ipynb',
|
|
3835
|
+
];
|
|
3836
|
+
|
|
3837
|
+
// 1️⃣ Download files from URL
|
|
3838
|
+
const localFiles = [];
|
|
3839
|
+
for (const url of fileUrls) {
|
|
3840
|
+
const filepath = await downloadFile(url);
|
|
3841
|
+
localFiles.push(filepath);
|
|
3842
|
+
}
|
|
3843
|
+
|
|
3844
|
+
// 2️⃣ Upload files to OpenAI
|
|
3845
|
+
const uploadedFiles = [];
|
|
3846
|
+
for (const filepath of localFiles) {
|
|
3847
|
+
const file = await uploadFileToOpenAI(filepath);
|
|
3848
|
+
uploadedFiles.push(file.id);
|
|
3849
|
+
}
|
|
3850
|
+
*/
|
|
3851
|
+
// 3️⃣ Create assistant with uploaded files
|
|
3852
|
+
const assistant = await client.beta.assistants.create({
|
|
3853
|
+
name: 'Next.js documentation assistant',
|
|
3854
|
+
description: 'Assistant that can answer questions about Next.js and working with APIs.',
|
|
3855
|
+
model: 'gpt-4o',
|
|
3856
|
+
instructions: spaceTrim__default["default"](`
|
|
3857
|
+
Answer clearly and comprehensively.
|
|
3858
|
+
Quote parts from uploaded files if needed.
|
|
3859
|
+
`),
|
|
3860
|
+
// <- TODO: !!!! Generate the `instructions` from passed `agentSource` (generate outside of this class)
|
|
3861
|
+
tools: [{ type: 'code_interpreter' }, { type: 'file_search' }],
|
|
3862
|
+
// !!!! file_ids: uploadedFiles,
|
|
3863
|
+
});
|
|
3864
|
+
// TODO: !!!! Change Czech to English
|
|
3865
|
+
console.log(`✅ Assistant created: ${assistant.id}`);
|
|
3866
|
+
return new OpenAiAssistantExecutionTools({
|
|
3867
|
+
...this.options,
|
|
3868
|
+
isCreatingNewAssistantsAllowed: false,
|
|
3869
|
+
assistantId: assistant.id,
|
|
3870
|
+
});
|
|
3871
|
+
}
|
|
3872
|
+
/**
|
|
3873
|
+
* Discriminant for type guards
|
|
3874
|
+
*/
|
|
3875
|
+
get discriminant() {
|
|
3876
|
+
return DISCRIMINANT;
|
|
3877
|
+
}
|
|
3878
|
+
/**
|
|
3879
|
+
* Type guard to check if given `LlmExecutionTools` are instanceof `OpenAiAssistantExecutionTools`
|
|
3880
|
+
*
|
|
3881
|
+
* Note: This is useful when you can possibly have multiple versions of `@promptbook/openai` installed
|
|
3882
|
+
*/
|
|
3883
|
+
static isOpenAiAssistantExecutionTools(llmExecutionTools) {
|
|
3884
|
+
return llmExecutionTools.discriminant === DISCRIMINANT;
|
|
3885
|
+
}
|
|
3780
3886
|
}
|
|
3887
|
+
/**
|
|
3888
|
+
* Discriminant for type guards
|
|
3889
|
+
*
|
|
3890
|
+
* @private const of `OpenAiAssistantExecutionTools`
|
|
3891
|
+
*/
|
|
3892
|
+
const DISCRIMINANT = 'OPEN_AI_ASSISTANT_V1';
|
|
3781
3893
|
/**
|
|
3782
3894
|
* TODO: [🧠][🧙♂️] Maybe there can be some wizard for those who want to use just OpenAI
|
|
3783
3895
|
* TODO: Maybe make custom OpenAiError
|
|
@@ -4013,6 +4125,7 @@
|
|
|
4013
4125
|
PromptbookFetchError,
|
|
4014
4126
|
UnexpectedError,
|
|
4015
4127
|
WrappedError,
|
|
4128
|
+
NotAllowed,
|
|
4016
4129
|
// TODO: [🪑]> VersionMismatchError,
|
|
4017
4130
|
};
|
|
4018
4131
|
/**
|