@promptbook/core 0.103.0-46 → 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 +326 -283
- 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-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 +1 -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/execution/LlmExecutionTools.d.ts +1 -1
- 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/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/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +326 -282
- 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
package/umd/index.umd.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-47';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -160,15 +160,20 @@
|
|
|
160
160
|
*/
|
|
161
161
|
const REMOTE_SERVER_URLS = [
|
|
162
162
|
{
|
|
163
|
-
title: 'Promptbook',
|
|
164
|
-
description: `
|
|
163
|
+
title: 'Promptbook.Studio',
|
|
164
|
+
description: `Server of Promptbook.studio`,
|
|
165
165
|
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
166
|
-
isAnonymousModeAllowed: true,
|
|
167
166
|
urls: [
|
|
168
167
|
'https://promptbook.s5.ptbk.io/',
|
|
169
168
|
// Note: Servers 1-4 are not running
|
|
170
169
|
],
|
|
171
170
|
},
|
|
171
|
+
{
|
|
172
|
+
title: 'Testing Agents',
|
|
173
|
+
description: `Testing Agents server on Vercel`,
|
|
174
|
+
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
175
|
+
urls: ['https://s6.ptbk.io/'],
|
|
176
|
+
},
|
|
172
177
|
/*
|
|
173
178
|
Note: Working on older version of Promptbook and not supported anymore
|
|
174
179
|
{
|
|
@@ -413,9 +418,6 @@
|
|
|
413
418
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
414
419
|
}
|
|
415
420
|
}
|
|
416
|
-
/**
|
|
417
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
418
|
-
*/
|
|
419
421
|
|
|
420
422
|
/**
|
|
421
423
|
* Color object represents an RGB color with alpha channel
|
|
@@ -7391,40 +7393,6 @@
|
|
|
7391
7393
|
* TODO: [🏢] Check validity of `temperature` in pipeline
|
|
7392
7394
|
*/
|
|
7393
7395
|
|
|
7394
|
-
/**
|
|
7395
|
-
* Creates an empty/basic agent model requirements object
|
|
7396
|
-
* This serves as the starting point for the reduce-like pattern
|
|
7397
|
-
* where each commitment applies its changes to build the final requirements
|
|
7398
|
-
*
|
|
7399
|
-
* @public exported from `@promptbook/core`
|
|
7400
|
-
*/
|
|
7401
|
-
function createEmptyAgentModelRequirements() {
|
|
7402
|
-
return {
|
|
7403
|
-
systemMessage: '',
|
|
7404
|
-
// modelName: 'gpt-5',
|
|
7405
|
-
modelName: 'gemini-2.5-flash-lite',
|
|
7406
|
-
temperature: 0.7,
|
|
7407
|
-
topP: 0.9,
|
|
7408
|
-
topK: 50,
|
|
7409
|
-
};
|
|
7410
|
-
}
|
|
7411
|
-
/**
|
|
7412
|
-
* Creates a basic agent model requirements with just the agent name
|
|
7413
|
-
* This is used when we have an agent name but no commitments
|
|
7414
|
-
*
|
|
7415
|
-
* @public exported from `@promptbook/core`
|
|
7416
|
-
*/
|
|
7417
|
-
function createBasicAgentModelRequirements(agentName) {
|
|
7418
|
-
const empty = createEmptyAgentModelRequirements();
|
|
7419
|
-
return {
|
|
7420
|
-
...empty,
|
|
7421
|
-
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
7422
|
-
};
|
|
7423
|
-
}
|
|
7424
|
-
/**
|
|
7425
|
-
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
7426
|
-
*/
|
|
7427
|
-
|
|
7428
7396
|
/**
|
|
7429
7397
|
* Generates a regex pattern to match a specific commitment
|
|
7430
7398
|
*
|
|
@@ -7958,23 +7926,19 @@
|
|
|
7958
7926
|
`);
|
|
7959
7927
|
}
|
|
7960
7928
|
applyToAgentModelRequirements(requirements, content) {
|
|
7961
|
-
var _a;
|
|
7962
7929
|
const trimmedContent = content.trim();
|
|
7963
7930
|
if (!trimmedContent) {
|
|
7964
7931
|
return requirements;
|
|
7965
7932
|
}
|
|
7966
7933
|
// Check if content is a URL (external knowledge source)
|
|
7967
|
-
if (
|
|
7934
|
+
if (isValidUrl(trimmedContent)) {
|
|
7968
7935
|
// Store the URL for later async processing
|
|
7969
7936
|
const updatedRequirements = {
|
|
7970
7937
|
...requirements,
|
|
7971
|
-
|
|
7972
|
-
...requirements.
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
trimmedContent,
|
|
7976
|
-
],
|
|
7977
|
-
},
|
|
7938
|
+
knowledgeSources: [
|
|
7939
|
+
...(requirements.knowledgeSources || []),
|
|
7940
|
+
trimmedContent,
|
|
7941
|
+
],
|
|
7978
7942
|
};
|
|
7979
7943
|
// Add placeholder information about knowledge sources to system message
|
|
7980
7944
|
const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
|
|
@@ -7986,18 +7950,6 @@
|
|
|
7986
7950
|
return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
|
|
7987
7951
|
}
|
|
7988
7952
|
}
|
|
7989
|
-
/**
|
|
7990
|
-
* Check if content is a URL
|
|
7991
|
-
*/
|
|
7992
|
-
isUrl(content) {
|
|
7993
|
-
try {
|
|
7994
|
-
new URL(content);
|
|
7995
|
-
return true;
|
|
7996
|
-
}
|
|
7997
|
-
catch (_a) {
|
|
7998
|
-
return false;
|
|
7999
|
-
}
|
|
8000
|
-
}
|
|
8001
7953
|
}
|
|
8002
7954
|
/**
|
|
8003
7955
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9323,6 +9275,40 @@
|
|
|
9323
9275
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
9324
9276
|
*/
|
|
9325
9277
|
|
|
9278
|
+
/**
|
|
9279
|
+
* Creates an empty/basic agent model requirements object
|
|
9280
|
+
* This serves as the starting point for the reduce-like pattern
|
|
9281
|
+
* where each commitment applies its changes to build the final requirements
|
|
9282
|
+
*
|
|
9283
|
+
* @public exported from `@promptbook/core`
|
|
9284
|
+
*/
|
|
9285
|
+
function createEmptyAgentModelRequirements() {
|
|
9286
|
+
return {
|
|
9287
|
+
systemMessage: '',
|
|
9288
|
+
// modelName: 'gpt-5',
|
|
9289
|
+
modelName: 'gemini-2.5-flash-lite',
|
|
9290
|
+
temperature: 0.7,
|
|
9291
|
+
topP: 0.9,
|
|
9292
|
+
topK: 50,
|
|
9293
|
+
};
|
|
9294
|
+
}
|
|
9295
|
+
/**
|
|
9296
|
+
* Creates a basic agent model requirements with just the agent name
|
|
9297
|
+
* This is used when we have an agent name but no commitments
|
|
9298
|
+
*
|
|
9299
|
+
* @public exported from `@promptbook/core`
|
|
9300
|
+
*/
|
|
9301
|
+
function createBasicAgentModelRequirements(agentName) {
|
|
9302
|
+
const empty = createEmptyAgentModelRequirements();
|
|
9303
|
+
return {
|
|
9304
|
+
...empty,
|
|
9305
|
+
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
9306
|
+
};
|
|
9307
|
+
}
|
|
9308
|
+
/**
|
|
9309
|
+
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
9310
|
+
*/
|
|
9311
|
+
|
|
9326
9312
|
/**
|
|
9327
9313
|
* Parses agent source using the new commitment system with multiline support
|
|
9328
9314
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -9413,29 +9399,6 @@
|
|
|
9413
9399
|
};
|
|
9414
9400
|
}
|
|
9415
9401
|
|
|
9416
|
-
/**
|
|
9417
|
-
* Removes comment lines (lines starting with #) from a system message
|
|
9418
|
-
* This is used to clean up the final system message before sending it to the AI model
|
|
9419
|
-
* while preserving the original content with comments in metadata
|
|
9420
|
-
*
|
|
9421
|
-
* @param systemMessage The system message that may contain comment lines
|
|
9422
|
-
* @returns The system message with comment lines removed
|
|
9423
|
-
*
|
|
9424
|
-
* @private - TODO: [🧠] Maybe should be public?
|
|
9425
|
-
*/
|
|
9426
|
-
function removeCommentsFromSystemMessage(systemMessage) {
|
|
9427
|
-
if (!systemMessage) {
|
|
9428
|
-
return systemMessage;
|
|
9429
|
-
}
|
|
9430
|
-
const lines = systemMessage.split('\n');
|
|
9431
|
-
const filteredLines = lines.filter((line) => {
|
|
9432
|
-
const trimmedLine = line.trim();
|
|
9433
|
-
// Remove lines that start with # (comments)
|
|
9434
|
-
return !trimmedLine.startsWith('#');
|
|
9435
|
-
});
|
|
9436
|
-
return filteredLines.join('\n').trim();
|
|
9437
|
-
}
|
|
9438
|
-
|
|
9439
9402
|
/**
|
|
9440
9403
|
* Parses parameters from text using both supported notations:
|
|
9441
9404
|
* 1. @Parameter - single word parameter starting with @
|
|
@@ -9494,6 +9457,29 @@
|
|
|
9494
9457
|
return uniqueParameters;
|
|
9495
9458
|
}
|
|
9496
9459
|
|
|
9460
|
+
/**
|
|
9461
|
+
* Removes comment lines (lines starting with #) from a system message
|
|
9462
|
+
* This is used to clean up the final system message before sending it to the AI model
|
|
9463
|
+
* while preserving the original content with comments in metadata
|
|
9464
|
+
*
|
|
9465
|
+
* @param systemMessage The system message that may contain comment lines
|
|
9466
|
+
* @returns The system message with comment lines removed
|
|
9467
|
+
*
|
|
9468
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
9469
|
+
*/
|
|
9470
|
+
function removeCommentsFromSystemMessage(systemMessage) {
|
|
9471
|
+
if (!systemMessage) {
|
|
9472
|
+
return systemMessage;
|
|
9473
|
+
}
|
|
9474
|
+
const lines = systemMessage.split('\n');
|
|
9475
|
+
const filteredLines = lines.filter((line) => {
|
|
9476
|
+
const trimmedLine = line.trim();
|
|
9477
|
+
// Remove lines that start with # (comments)
|
|
9478
|
+
return !trimmedLine.startsWith('#');
|
|
9479
|
+
});
|
|
9480
|
+
return filteredLines.join('\n').trim();
|
|
9481
|
+
}
|
|
9482
|
+
|
|
9497
9483
|
/**
|
|
9498
9484
|
* Creates agent model requirements using the new commitment system
|
|
9499
9485
|
* This function uses a reduce-like pattern where each commitment applies its changes
|
|
@@ -9937,125 +9923,51 @@
|
|
|
9937
9923
|
console.info(`Creating pipeline collection from supabase...`);
|
|
9938
9924
|
}
|
|
9939
9925
|
}
|
|
9940
|
-
/**
|
|
9941
|
-
* Cached defined execution tools
|
|
9942
|
-
*/
|
|
9943
|
-
// !!! private _definedTools: ExecutionTools | null = null;
|
|
9944
|
-
/*
|
|
9945
|
-
TODO: !!! Use or remove
|
|
9946
|
-
/**
|
|
9947
|
-
* Gets or creates execution tools for the collection
|
|
9948
|
-
* /
|
|
9949
|
-
private async getTools(): Promise<ExecutionTools> {
|
|
9950
|
-
if (this._definedTools !== null) {
|
|
9951
|
-
return this._definedTools;
|
|
9952
|
-
}
|
|
9953
|
-
|
|
9954
|
-
this._definedTools = {
|
|
9955
|
-
...(this.tools === undefined || this.tools.fs === undefined ? await $provideExecutionToolsForNode() : {}),
|
|
9956
|
-
...this.tools,
|
|
9957
|
-
};
|
|
9958
|
-
return this._definedTools;
|
|
9959
|
-
}
|
|
9960
|
-
// <- TODO: [👪] Maybe create some common abstraction *(or parent abstract class)*
|
|
9961
|
-
*/
|
|
9962
9926
|
/**
|
|
9963
9927
|
* Gets all agents in the collection
|
|
9964
9928
|
*/
|
|
9965
9929
|
async listAgents( /* TODO: [🧠] Allow to pass some condition here */) {
|
|
9966
9930
|
const { isVerbose = exports.DEFAULT_IS_VERBOSE } = this.options || {};
|
|
9967
|
-
const
|
|
9931
|
+
const selectResult = await this.supabaseClient
|
|
9968
9932
|
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
9969
9933
|
.select('agentProfile');
|
|
9970
|
-
if (
|
|
9934
|
+
if (selectResult.error) {
|
|
9971
9935
|
throw new DatabaseError(spaceTrim((block) => `
|
|
9972
9936
|
|
|
9973
9937
|
Error fetching agents from Supabase:
|
|
9974
9938
|
|
|
9975
|
-
${block(
|
|
9939
|
+
${block(selectResult.error.message)}
|
|
9976
9940
|
`));
|
|
9977
9941
|
}
|
|
9978
9942
|
if (isVerbose) {
|
|
9979
|
-
console.info(`Found ${
|
|
9980
|
-
}
|
|
9981
|
-
return result.data.map((row) => row.agentProfile);
|
|
9982
|
-
}
|
|
9983
|
-
/**
|
|
9984
|
-
* !!!
|
|
9985
|
-
* /
|
|
9986
|
-
public async spawnAgent(agentName: string_agent_name): Promise<Agent> {
|
|
9987
|
-
|
|
9988
|
-
// <- TODO: !!! ENOENT: no such file or directory, open 'C:\Users\me\work\ai\promptbook\agents\examples\Asistent pro LŠVP.book
|
|
9989
|
-
const { isVerbose = DEFAULT_IS_VERBOSE } = this.options || {};
|
|
9990
|
-
const tools = await this.getTools();
|
|
9991
|
-
|
|
9992
|
-
const agentSourceValue = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
9993
|
-
const agentSource = new BehaviorSubject(agentSourceValue);
|
|
9994
|
-
|
|
9995
|
-
// Note: Write file whenever agent source changes
|
|
9996
|
-
agentSource.subscribe(async (newSource) => {
|
|
9997
|
-
if (isVerbose) {
|
|
9998
|
-
console.info(colors.cyan(`Writing agent source to file ${agentSourcePath}`));
|
|
9999
|
-
}
|
|
10000
|
-
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
10001
|
-
await tools.fs!.writeFile(agentSourcePath, newSource, 'utf-8');
|
|
10002
|
-
});
|
|
10003
|
-
|
|
10004
|
-
// Note: Watch file for external changes
|
|
10005
|
-
for await (const event of tools.fs!.watch(agentSourcePath)) {
|
|
10006
|
-
// <- TODO: !!!! Solve the memory freeing when the watching is no longer needed
|
|
10007
|
-
|
|
10008
|
-
if (event.eventType !== 'change') {
|
|
10009
|
-
continue;
|
|
10010
|
-
}
|
|
10011
|
-
|
|
10012
|
-
if (isVerbose) {
|
|
10013
|
-
console.info(
|
|
10014
|
-
colors.cyan(`Detected external change in agent source file ${agentSourcePath}, reloading`),
|
|
10015
|
-
);
|
|
10016
|
-
}
|
|
10017
|
-
await forTime(500); // <- TODO: [🙌] !!! Remove
|
|
10018
|
-
const newSource = validateBook(await tools.fs!.readFile(agentSourcePath, 'utf-8'));
|
|
10019
|
-
agentSource.next(newSource);
|
|
10020
|
-
}
|
|
10021
|
-
|
|
10022
|
-
// TODO: [🙌] !!!! Debug the infinite loop when file is changed externally and agent source is updated which causes file to be written again
|
|
10023
|
-
|
|
10024
|
-
const agent = new Agent({
|
|
10025
|
-
...this.options,
|
|
10026
|
-
agentSource,
|
|
10027
|
-
executionTools: this.tools || {},
|
|
10028
|
-
});
|
|
10029
|
-
|
|
10030
|
-
if (isVerbose) {
|
|
10031
|
-
console.info(colors.cyan(`Created agent "${agent.agentName}" from source file ${agentSourcePath}`));
|
|
9943
|
+
console.info(`Found ${selectResult.data.length} agents in directory`);
|
|
10032
9944
|
}
|
|
10033
|
-
|
|
10034
|
-
return agent;
|
|
10035
|
-
* /
|
|
9945
|
+
return selectResult.data.map((row) => row.agentProfile);
|
|
10036
9946
|
}
|
|
10037
|
-
*/
|
|
10038
9947
|
/**
|
|
10039
9948
|
* !!!@@@
|
|
10040
9949
|
*/
|
|
10041
9950
|
async getAgentSource(agentName) {
|
|
10042
|
-
const
|
|
9951
|
+
const selectResult = await this.supabaseClient
|
|
10043
9952
|
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
10044
9953
|
.select('agentSource')
|
|
10045
9954
|
.eq('agentName', agentName)
|
|
10046
9955
|
.single();
|
|
10047
|
-
|
|
9956
|
+
/*
|
|
9957
|
+
if (selectResult.data===null) {
|
|
9958
|
+
throw new NotFoundError(`Agent "${agentName}" not found`);
|
|
9959
|
+
}
|
|
9960
|
+
*/
|
|
9961
|
+
if (selectResult.error) {
|
|
10048
9962
|
throw new DatabaseError(spaceTrim((block) => `
|
|
10049
9963
|
|
|
10050
9964
|
Error fetching agent "${agentName}" from Supabase:
|
|
10051
9965
|
|
|
10052
|
-
${block(
|
|
9966
|
+
${block(selectResult.error.message)}
|
|
10053
9967
|
`));
|
|
10054
9968
|
// <- TODO: !!! First check if the error is "not found" and throw `NotFoundError` instead then throw `DatabaseError`
|
|
10055
9969
|
}
|
|
10056
|
-
|
|
10057
|
-
// <- TODO: !!!! Dynamic updates
|
|
10058
|
-
return agentSource;
|
|
9970
|
+
return selectResult.data.agentSource;
|
|
10059
9971
|
}
|
|
10060
9972
|
/**
|
|
10061
9973
|
* Creates a new agent in the collection
|
|
@@ -10065,7 +9977,9 @@
|
|
|
10065
9977
|
async createAgent(agentSource) {
|
|
10066
9978
|
const agentProfile = parseAgentSource(agentSource);
|
|
10067
9979
|
// <- TODO: [🕛]
|
|
10068
|
-
const
|
|
9980
|
+
const selectResult = await this.supabaseClient
|
|
9981
|
+
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
9982
|
+
.insert({
|
|
10069
9983
|
agentName: agentProfile.agentName || '!!!!!' /* <- TODO: !!!! Remove */,
|
|
10070
9984
|
agentProfile,
|
|
10071
9985
|
createdAt: new Date().toISOString(),
|
|
@@ -10075,11 +9989,11 @@
|
|
|
10075
9989
|
usage: ZERO_USAGE,
|
|
10076
9990
|
agentSource: agentSource,
|
|
10077
9991
|
});
|
|
10078
|
-
if (
|
|
9992
|
+
if (selectResult.error) {
|
|
10079
9993
|
throw new DatabaseError(spaceTrim((block) => `
|
|
10080
9994
|
Error creating agent "${agentProfile.agentName}" in Supabase:
|
|
10081
9995
|
|
|
10082
|
-
${block(
|
|
9996
|
+
${block(selectResult.error.message)}
|
|
10083
9997
|
`));
|
|
10084
9998
|
}
|
|
10085
9999
|
return agentProfile;
|
|
@@ -10088,33 +10002,43 @@
|
|
|
10088
10002
|
* Updates an existing agent in the collection
|
|
10089
10003
|
*/
|
|
10090
10004
|
async updateAgentSource(agentName, agentSource) {
|
|
10005
|
+
const selectResult = await this.supabaseClient
|
|
10006
|
+
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
10007
|
+
.select('agentVersion')
|
|
10008
|
+
.eq('agentName', agentName)
|
|
10009
|
+
.single();
|
|
10010
|
+
if (!selectResult.data) {
|
|
10011
|
+
throw new NotFoundError(`Agent "${agentName}" not found`);
|
|
10012
|
+
}
|
|
10091
10013
|
const agentProfile = parseAgentSource(agentSource);
|
|
10092
10014
|
// TODO: !!!!!! What about agentName change
|
|
10093
10015
|
console.log('!!! agentName', agentName);
|
|
10094
10016
|
const oldAgentSource = await this.getAgentSource(agentName);
|
|
10095
|
-
const
|
|
10017
|
+
const updateResult = await this.supabaseClient
|
|
10096
10018
|
.from('AgentCollection' /* <- TODO: !!!! Change to `Agent` */)
|
|
10097
10019
|
.update({
|
|
10098
10020
|
// TODO: !!!! Compare not update> agentName: agentProfile.agentName || '!!!!!' /* <- TODO: !!!! Remove */,
|
|
10099
10021
|
agentProfile,
|
|
10100
10022
|
updatedAt: new Date().toISOString(),
|
|
10101
|
-
agentVersion:
|
|
10102
|
-
agentSource
|
|
10023
|
+
agentVersion: selectResult.data.agentVersion + 1,
|
|
10024
|
+
agentSource,
|
|
10025
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
10103
10026
|
})
|
|
10104
10027
|
.eq('agentName', agentName);
|
|
10105
10028
|
const newAgentSource = await this.getAgentSource(agentName);
|
|
10106
|
-
console.log('!!! updateAgent',
|
|
10029
|
+
console.log('!!! updateAgent', updateResult);
|
|
10107
10030
|
console.log('!!! old', oldAgentSource);
|
|
10108
10031
|
console.log('!!! new', newAgentSource);
|
|
10109
|
-
if (
|
|
10032
|
+
if (updateResult.error) {
|
|
10110
10033
|
throw new DatabaseError(spaceTrim((block) => `
|
|
10111
10034
|
Error updating agent "${agentName}" in Supabase:
|
|
10112
10035
|
|
|
10113
|
-
${block(
|
|
10036
|
+
${block(updateResult.error.message)}
|
|
10114
10037
|
`));
|
|
10115
10038
|
}
|
|
10116
10039
|
}
|
|
10117
|
-
// TODO: !!!! getAgentSourceSubject
|
|
10040
|
+
// TODO: !!!! public async getAgentSourceSubject(agentName: string_agent_name): Promise<BehaviorSubject<string_book>>
|
|
10041
|
+
// Use Supabase realtime logic
|
|
10118
10042
|
/**
|
|
10119
10043
|
* Deletes an agent from the collection
|
|
10120
10044
|
*/
|
|
@@ -16563,7 +16487,7 @@
|
|
|
16563
16487
|
*
|
|
16564
16488
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
16565
16489
|
*
|
|
16566
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
16490
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
16567
16491
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
16568
16492
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
16569
16493
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -16669,17 +16593,21 @@
|
|
|
16669
16593
|
console.info('connect', stream.currentEvent);
|
|
16670
16594
|
}
|
|
16671
16595
|
});
|
|
16596
|
+
/*
|
|
16672
16597
|
stream.on('messageDelta', (messageDelta) => {
|
|
16673
|
-
|
|
16674
|
-
|
|
16598
|
+
if (
|
|
16599
|
+
this.options.isVerbose &&
|
|
16675
16600
|
messageDelta &&
|
|
16676
16601
|
messageDelta.content &&
|
|
16677
16602
|
messageDelta.content[0] &&
|
|
16678
|
-
messageDelta.content[0].type === 'text'
|
|
16679
|
-
|
|
16603
|
+
messageDelta.content[0].type === 'text'
|
|
16604
|
+
) {
|
|
16605
|
+
console.info('messageDelta', messageDelta.content[0].text?.value);
|
|
16680
16606
|
}
|
|
16607
|
+
|
|
16681
16608
|
// <- TODO: [🐚] Make streaming and running tasks working
|
|
16682
16609
|
});
|
|
16610
|
+
*/
|
|
16683
16611
|
stream.on('messageCreated', (message) => {
|
|
16684
16612
|
if (this.options.isVerbose) {
|
|
16685
16613
|
console.info('messageCreated', message);
|
|
@@ -16759,64 +16687,85 @@
|
|
|
16759
16687
|
throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
|
|
16760
16688
|
}
|
|
16761
16689
|
// await this.playground();
|
|
16762
|
-
const { name, instructions } = options;
|
|
16690
|
+
const { name, instructions, knowledgeSources } = options;
|
|
16763
16691
|
const client = await this.getClient();
|
|
16764
|
-
|
|
16765
|
-
//
|
|
16766
|
-
|
|
16767
|
-
|
|
16768
|
-
|
|
16769
|
-
|
|
16770
|
-
|
|
16771
|
-
|
|
16772
|
-
|
|
16773
|
-
if (!res.ok) throw new Error(`Download error: ${url}`);
|
|
16774
|
-
const buffer = await res.arrayBuffer();
|
|
16775
|
-
fs.writeFileSync(filepath, Buffer.from(buffer));
|
|
16776
|
-
console.log(`📥 File downloaded: ${filename}`);
|
|
16777
|
-
|
|
16778
|
-
return filepath;
|
|
16779
|
-
}
|
|
16780
|
-
|
|
16781
|
-
async function uploadFileToOpenAI(filepath: string) {
|
|
16782
|
-
const file = await client.files.create({
|
|
16783
|
-
file: fs.createReadStream(filepath),
|
|
16784
|
-
purpose: 'assistants',
|
|
16692
|
+
let vectorStoreId;
|
|
16693
|
+
// If knowledge sources are provided, create a vector store with them
|
|
16694
|
+
if (knowledgeSources && knowledgeSources.length > 0) {
|
|
16695
|
+
if (this.options.isVerbose) {
|
|
16696
|
+
console.info(`📚 Creating vector store with ${knowledgeSources.length} knowledge sources...`);
|
|
16697
|
+
}
|
|
16698
|
+
// Create a vector store
|
|
16699
|
+
const vectorStore = await client.beta.vectorStores.create({
|
|
16700
|
+
name: `${name} Knowledge Base`,
|
|
16785
16701
|
});
|
|
16786
|
-
|
|
16787
|
-
|
|
16788
|
-
|
|
16789
|
-
|
|
16790
|
-
|
|
16791
|
-
|
|
16792
|
-
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
|
|
16796
|
-
|
|
16797
|
-
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
|
|
16805
|
-
|
|
16806
|
-
|
|
16807
|
-
|
|
16702
|
+
vectorStoreId = vectorStore.id;
|
|
16703
|
+
if (this.options.isVerbose) {
|
|
16704
|
+
console.info(`✅ Vector store created: ${vectorStoreId}`);
|
|
16705
|
+
}
|
|
16706
|
+
// Upload files from knowledge sources to the vector store
|
|
16707
|
+
const fileStreams = [];
|
|
16708
|
+
for (const source of knowledgeSources) {
|
|
16709
|
+
try {
|
|
16710
|
+
// Check if it's a URL
|
|
16711
|
+
if (source.startsWith('http://') || source.startsWith('https://')) {
|
|
16712
|
+
// Download the file
|
|
16713
|
+
const response = await fetch(source);
|
|
16714
|
+
if (!response.ok) {
|
|
16715
|
+
console.error(`Failed to download ${source}: ${response.statusText}`);
|
|
16716
|
+
continue;
|
|
16717
|
+
}
|
|
16718
|
+
const buffer = await response.arrayBuffer();
|
|
16719
|
+
const filename = source.split('/').pop() || 'downloaded-file';
|
|
16720
|
+
const blob = new Blob([buffer]);
|
|
16721
|
+
const file = new File([blob], filename);
|
|
16722
|
+
fileStreams.push(file);
|
|
16723
|
+
}
|
|
16724
|
+
else {
|
|
16725
|
+
// Assume it's a local file path
|
|
16726
|
+
// Note: This will work in Node.js environment
|
|
16727
|
+
// For browser environments, this would need different handling
|
|
16728
|
+
const fs = await import('fs');
|
|
16729
|
+
const fileStream = fs.createReadStream(source);
|
|
16730
|
+
fileStreams.push(fileStream);
|
|
16731
|
+
}
|
|
16732
|
+
}
|
|
16733
|
+
catch (error) {
|
|
16734
|
+
console.error(`Error processing knowledge source ${source}:`, error);
|
|
16735
|
+
}
|
|
16736
|
+
}
|
|
16737
|
+
// Batch upload files to the vector store
|
|
16738
|
+
if (fileStreams.length > 0) {
|
|
16739
|
+
try {
|
|
16740
|
+
await client.beta.vectorStores.fileBatches.uploadAndPoll(vectorStoreId, {
|
|
16741
|
+
files: fileStreams,
|
|
16742
|
+
});
|
|
16743
|
+
if (this.options.isVerbose) {
|
|
16744
|
+
console.info(`✅ Uploaded ${fileStreams.length} files to vector store`);
|
|
16745
|
+
}
|
|
16746
|
+
}
|
|
16747
|
+
catch (error) {
|
|
16748
|
+
console.error('Error uploading files to vector store:', error);
|
|
16749
|
+
}
|
|
16750
|
+
}
|
|
16808
16751
|
}
|
|
16809
|
-
|
|
16810
|
-
|
|
16811
|
-
// 3️⃣ Create assistant with uploaded files
|
|
16812
|
-
const assistant = await client.beta.assistants.create({
|
|
16752
|
+
// Create assistant with vector store attached
|
|
16753
|
+
const assistantConfig = {
|
|
16813
16754
|
name,
|
|
16814
16755
|
description: 'Assistant created via Promptbook',
|
|
16815
16756
|
model: 'gpt-4o',
|
|
16816
16757
|
instructions,
|
|
16817
16758
|
tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
|
|
16818
|
-
|
|
16819
|
-
|
|
16759
|
+
};
|
|
16760
|
+
// Attach vector store if created
|
|
16761
|
+
if (vectorStoreId) {
|
|
16762
|
+
assistantConfig.tool_resources = {
|
|
16763
|
+
file_search: {
|
|
16764
|
+
vector_store_ids: [vectorStoreId],
|
|
16765
|
+
},
|
|
16766
|
+
};
|
|
16767
|
+
}
|
|
16768
|
+
const assistant = await client.beta.assistants.create(assistantConfig);
|
|
16820
16769
|
console.log(`✅ Assistant created: ${assistant.id}`);
|
|
16821
16770
|
// TODO: !!!! Try listing existing assistants
|
|
16822
16771
|
// TODO: !!!! Try marking existing assistants by DISCRIMINANT
|
|
@@ -16859,7 +16808,7 @@
|
|
|
16859
16808
|
* Execution Tools for calling LLM models with a predefined agent "soul"
|
|
16860
16809
|
* This wraps underlying LLM execution tools and applies agent-specific system prompts and requirements
|
|
16861
16810
|
*
|
|
16862
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
16811
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
16863
16812
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
16864
16813
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
16865
16814
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -16975,6 +16924,7 @@
|
|
|
16975
16924
|
const assistant = await this.options.llmTools.createNewAssistant({
|
|
16976
16925
|
name: this.title,
|
|
16977
16926
|
instructions: modelRequirements.systemMessage,
|
|
16927
|
+
knowledgeSources: modelRequirements.knowledgeSources,
|
|
16978
16928
|
/*
|
|
16979
16929
|
!!!
|
|
16980
16930
|
metadata: {
|
|
@@ -17025,7 +16975,7 @@
|
|
|
17025
16975
|
/**
|
|
17026
16976
|
* Represents one AI Agent
|
|
17027
16977
|
*
|
|
17028
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
16978
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
17029
16979
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
17030
16980
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
17031
16981
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -17033,7 +16983,7 @@
|
|
|
17033
16983
|
*
|
|
17034
16984
|
* @public exported from `@promptbook/core`
|
|
17035
16985
|
*/
|
|
17036
|
-
class Agent {
|
|
16986
|
+
class Agent extends AgentLlmExecutionTools {
|
|
17037
16987
|
/**
|
|
17038
16988
|
* Not used in Agent, always returns empty array
|
|
17039
16989
|
*/
|
|
@@ -17043,7 +16993,12 @@
|
|
|
17043
16993
|
];
|
|
17044
16994
|
}
|
|
17045
16995
|
constructor(options) {
|
|
17046
|
-
|
|
16996
|
+
const agentSource = asUpdatableSubject(options.agentSource);
|
|
16997
|
+
super({
|
|
16998
|
+
isVerbose: options.isVerbose,
|
|
16999
|
+
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
17000
|
+
agentSource: agentSource.value, // <- TODO: !!!! Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
17001
|
+
});
|
|
17047
17002
|
/**
|
|
17048
17003
|
* Name of the agent
|
|
17049
17004
|
*/
|
|
@@ -17056,7 +17011,9 @@
|
|
|
17056
17011
|
* Metadata like image or color
|
|
17057
17012
|
*/
|
|
17058
17013
|
this.meta = {};
|
|
17059
|
-
|
|
17014
|
+
// TODO: !!!! Add `Agent` simple "mocked" learning by appending to agent source
|
|
17015
|
+
// TODO: !!!! Add `Agent` learning by promptbookAgent
|
|
17016
|
+
this.agentSource = agentSource;
|
|
17060
17017
|
this.agentSource.subscribe((source) => {
|
|
17061
17018
|
const { agentName, personaDescription, meta } = parseAgentSource(source);
|
|
17062
17019
|
this.agentName = agentName;
|
|
@@ -17064,19 +17021,6 @@
|
|
|
17064
17021
|
this.meta = { ...this.meta, ...meta };
|
|
17065
17022
|
});
|
|
17066
17023
|
}
|
|
17067
|
-
/**
|
|
17068
|
-
* Creates LlmExecutionTools which exposes the agent as a model
|
|
17069
|
-
*/
|
|
17070
|
-
getLlmExecutionTools() {
|
|
17071
|
-
const llmTools = new AgentLlmExecutionTools({
|
|
17072
|
-
isVerbose: this.options.isVerbose,
|
|
17073
|
-
llmTools: getSingleLlmExecutionTools(this.options.executionTools.llm),
|
|
17074
|
-
agentSource: this.agentSource.value, // <- TODO: !!!! Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
17075
|
-
});
|
|
17076
|
-
// TODO: !!!! Add `Agent` simple "mocked" learning by appending to agent source
|
|
17077
|
-
// TODO: !!!! Add `Agent` learning by promptbookAgent
|
|
17078
|
-
return llmTools;
|
|
17079
|
-
}
|
|
17080
17024
|
}
|
|
17081
17025
|
/**
|
|
17082
17026
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
@@ -17143,6 +17087,106 @@
|
|
|
17143
17087
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
17144
17088
|
*/
|
|
17145
17089
|
|
|
17090
|
+
/**
|
|
17091
|
+
* Represents one AI Agent
|
|
17092
|
+
*
|
|
17093
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
17094
|
+
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
17095
|
+
* !!!! `RemoteAgent`
|
|
17096
|
+
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
17097
|
+
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
17098
|
+
* - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
|
|
17099
|
+
*
|
|
17100
|
+
* @public exported from `@promptbook/core`
|
|
17101
|
+
*/
|
|
17102
|
+
class RemoteAgent extends Agent {
|
|
17103
|
+
static async connect(options) {
|
|
17104
|
+
console.log('!!!!!', `${options.agentUrl}/api/book`);
|
|
17105
|
+
const bookResponse = await fetch(`${options.agentUrl}/api/book`);
|
|
17106
|
+
// <- TODO: !!!! What about closed-source agents?
|
|
17107
|
+
// <- TODO: !!!! Maybe use promptbookFetch
|
|
17108
|
+
const agentSourceValue = (await bookResponse.text());
|
|
17109
|
+
const agentSource = new rxjs.BehaviorSubject(agentSourceValue);
|
|
17110
|
+
// <- TODO: !!!!!! Support updating
|
|
17111
|
+
return new RemoteAgent({
|
|
17112
|
+
...options,
|
|
17113
|
+
executionTools: {
|
|
17114
|
+
/* Note: These tools are not used */
|
|
17115
|
+
// ---------------------------------------
|
|
17116
|
+
/*
|
|
17117
|
+
TODO: !!! Get rid of
|
|
17118
|
+
|
|
17119
|
+
> You have not provided any `LlmExecutionTools`
|
|
17120
|
+
> This means that you won't be able to execute any prompts that require large language models like GPT-4 or Anthropic's Claude.
|
|
17121
|
+
>
|
|
17122
|
+
> Technically, it's not an error, but it's probably not what you want because it does not make sense to use Promptbook without language models.
|
|
17123
|
+
|
|
17124
|
+
*/
|
|
17125
|
+
},
|
|
17126
|
+
agentSource,
|
|
17127
|
+
});
|
|
17128
|
+
}
|
|
17129
|
+
constructor(options) {
|
|
17130
|
+
super(options);
|
|
17131
|
+
this.agentUrl = options.agentUrl;
|
|
17132
|
+
}
|
|
17133
|
+
/**
|
|
17134
|
+
* Calls the agent on agents remote server
|
|
17135
|
+
*/
|
|
17136
|
+
async callChatModel(prompt) {
|
|
17137
|
+
// Ensure we're working with a chat prompt
|
|
17138
|
+
if (prompt.modelRequirements.modelVariant !== 'CHAT') {
|
|
17139
|
+
throw new Error('Agents only supports chat prompts');
|
|
17140
|
+
}
|
|
17141
|
+
const bookResponse = await fetch(`${this.agentUrl}/api/chat?message=${encodeURIComponent(prompt.content)}`);
|
|
17142
|
+
// <- TODO: !!!! What about closed-source agents?
|
|
17143
|
+
// <- TODO: !!!! Maybe use promptbookFetch
|
|
17144
|
+
let content = '';
|
|
17145
|
+
if (!bookResponse.body) {
|
|
17146
|
+
content = await bookResponse.text();
|
|
17147
|
+
}
|
|
17148
|
+
else {
|
|
17149
|
+
// Note: [🐚] Problem with streaming is not here but it is not implemented on server
|
|
17150
|
+
const decoder = new TextDecoder();
|
|
17151
|
+
// Web ReadableStream is not async-iterable in many runtimes; use a reader.
|
|
17152
|
+
const reader = bookResponse.body.getReader();
|
|
17153
|
+
try {
|
|
17154
|
+
let doneReading = false;
|
|
17155
|
+
while (!doneReading) {
|
|
17156
|
+
const { done, value } = await reader.read();
|
|
17157
|
+
doneReading = !!done;
|
|
17158
|
+
if (value) {
|
|
17159
|
+
const textChunk = decoder.decode(value, { stream: true });
|
|
17160
|
+
// console.debug('RemoteAgent chunk:', textChunk);
|
|
17161
|
+
content += textChunk;
|
|
17162
|
+
}
|
|
17163
|
+
}
|
|
17164
|
+
// Flush any remaining decoder internal state
|
|
17165
|
+
content += decoder.decode();
|
|
17166
|
+
}
|
|
17167
|
+
finally {
|
|
17168
|
+
reader.releaseLock();
|
|
17169
|
+
}
|
|
17170
|
+
}
|
|
17171
|
+
// <- TODO: !!!!!!!! Transfer metadata
|
|
17172
|
+
const agentResult = {
|
|
17173
|
+
content,
|
|
17174
|
+
modelName: this.modelName,
|
|
17175
|
+
timing: {},
|
|
17176
|
+
usage: {},
|
|
17177
|
+
rawPromptContent: {},
|
|
17178
|
+
rawRequest: {},
|
|
17179
|
+
rawResponse: {},
|
|
17180
|
+
// <- TODO: !!!!!!!! Transfer and proxy the metadata
|
|
17181
|
+
};
|
|
17182
|
+
return agentResult;
|
|
17183
|
+
}
|
|
17184
|
+
}
|
|
17185
|
+
/**
|
|
17186
|
+
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
17187
|
+
* TODO: !!! Agent on remote server
|
|
17188
|
+
*/
|
|
17189
|
+
|
|
17146
17190
|
/**
|
|
17147
17191
|
* Registration of LLM provider metadata
|
|
17148
17192
|
*
|
|
@@ -18361,8 +18405,7 @@
|
|
|
18361
18405
|
|
|
18362
18406
|
## Servers
|
|
18363
18407
|
|
|
18364
|
-
${block(REMOTE_SERVER_URLS.map(({ title, urls,
|
|
18365
|
-
${isAnonymousModeAllowed ? '🐱💻 ' : ''} ${urls.join(', ')}
|
|
18408
|
+
${block(REMOTE_SERVER_URLS.map(({ title, urls, description }, index) => `${index + 1}. ${title} ${description} ${urls.join(', ')}
|
|
18366
18409
|
`).join('\n'))}
|
|
18367
18410
|
`);
|
|
18368
18411
|
fullInfoPieces.push(serversInfo);
|
|
@@ -18405,6 +18448,30 @@
|
|
|
18405
18448
|
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18406
18449
|
*/
|
|
18407
18450
|
|
|
18451
|
+
const PERSONALITIES = [
|
|
18452
|
+
'Friendly and helpful AI agent.',
|
|
18453
|
+
'Professional and efficient virtual assistant.',
|
|
18454
|
+
'Creative and imaginative digital companion.',
|
|
18455
|
+
'Knowledgeable and informative AI guide.',
|
|
18456
|
+
'Empathetic and understanding support bot.',
|
|
18457
|
+
'Energetic and enthusiastic conversational partner.',
|
|
18458
|
+
'Calm and patient virtual helper.',
|
|
18459
|
+
'Curious and inquisitive AI explorer.',
|
|
18460
|
+
'Witty and humorous digital friend.',
|
|
18461
|
+
'Serious and focused AI consultant.',
|
|
18462
|
+
];
|
|
18463
|
+
/**
|
|
18464
|
+
* @@@@
|
|
18465
|
+
*
|
|
18466
|
+
* @private internal helper function
|
|
18467
|
+
*/
|
|
18468
|
+
function $randomAgentPersona() {
|
|
18469
|
+
return $randomItem(...PERSONALITIES);
|
|
18470
|
+
}
|
|
18471
|
+
/**
|
|
18472
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18473
|
+
*/
|
|
18474
|
+
|
|
18408
18475
|
const FIRSTNAMES = [
|
|
18409
18476
|
'Paul',
|
|
18410
18477
|
'George',
|
|
@@ -18465,30 +18532,6 @@
|
|
|
18465
18532
|
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18466
18533
|
*/
|
|
18467
18534
|
|
|
18468
|
-
const PERSONALITIES = [
|
|
18469
|
-
'Friendly and helpful AI agent.',
|
|
18470
|
-
'Professional and efficient virtual assistant.',
|
|
18471
|
-
'Creative and imaginative digital companion.',
|
|
18472
|
-
'Knowledgeable and informative AI guide.',
|
|
18473
|
-
'Empathetic and understanding support bot.',
|
|
18474
|
-
'Energetic and enthusiastic conversational partner.',
|
|
18475
|
-
'Calm and patient virtual helper.',
|
|
18476
|
-
'Curious and inquisitive AI explorer.',
|
|
18477
|
-
'Witty and humorous digital friend.',
|
|
18478
|
-
'Serious and focused AI consultant.',
|
|
18479
|
-
];
|
|
18480
|
-
/**
|
|
18481
|
-
* @@@@
|
|
18482
|
-
*
|
|
18483
|
-
* @private internal helper function
|
|
18484
|
-
*/
|
|
18485
|
-
function $randomAgentPersona() {
|
|
18486
|
-
return $randomItem(...PERSONALITIES);
|
|
18487
|
-
}
|
|
18488
|
-
/**
|
|
18489
|
-
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
18490
|
-
*/
|
|
18491
|
-
|
|
18492
18535
|
/**
|
|
18493
18536
|
* Generates boilerplate for a new agent book
|
|
18494
18537
|
*
|
|
@@ -18620,6 +18663,7 @@
|
|
|
18620
18663
|
exports.PromptbookFetchError = PromptbookFetchError;
|
|
18621
18664
|
exports.REMOTE_SERVER_URLS = REMOTE_SERVER_URLS;
|
|
18622
18665
|
exports.RESERVED_PARAMETER_NAMES = RESERVED_PARAMETER_NAMES;
|
|
18666
|
+
exports.RemoteAgent = RemoteAgent;
|
|
18623
18667
|
exports.SET_IS_VERBOSE = SET_IS_VERBOSE;
|
|
18624
18668
|
exports.SectionTypes = SectionTypes;
|
|
18625
18669
|
exports.SheetsFormfactorDefinition = SheetsFormfactorDefinition;
|