@promptbook/cli 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/apps/agents-server/config.ts.todo +4 -4
- package/apps/agents-server/next.config.ts +3 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +1 -1
- package/apps/agents-server/src/app/agents/[agentName]/api/book/test.http +2 -2
- package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +6 -4
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/TODO.txt +1 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +53 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +45 -0
- package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +54 -0
- package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +83 -17
- package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +9 -5
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/{SelfLearningBook.tsx → AgentBookAndChatComponent.tsx} +5 -46
- package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +7 -4
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +38 -0
- package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +23 -0
- package/apps/agents-server/src/app/agents/[agentName]/page.tsx +6 -4
- package/apps/agents-server/src/app/agents/page.tsx +11 -0
- package/apps/agents-server/src/app/api/chat/route.ts +1 -1
- package/apps/agents-server/src/app/api/chat-streaming/route.ts +5 -1
- package/apps/agents-server/src/app/api/upload/route.ts +75 -0
- package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +1 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +28 -0
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +119 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IFilesStorage.ts +32 -0
- package/apps/agents-server/src/utils/cdn/interfaces/IStorage.ts +14 -0
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +27 -0
- package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +9 -0
- package/apps/agents-server/src/utils/cdn/utils/nextRequestToNodeRequest.ts +27 -0
- package/apps/agents-server/src/utils/validators/validateMimeType.ts +24 -0
- package/apps/agents-server/tsconfig.json +1 -1
- package/esm/index.es.js +154 -161
- 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 +154 -161
- 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
|
@@ -9,7 +9,7 @@ import { OpenAiExecutionTools } from './OpenAiExecutionTools';
|
|
|
9
9
|
*
|
|
10
10
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
11
11
|
*
|
|
12
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
12
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
13
13
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
14
14
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
15
15
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -42,6 +42,10 @@ export declare class OpenAiAssistantExecutionTools extends OpenAiExecutionTools
|
|
|
42
42
|
* Instructions for the new assistant
|
|
43
43
|
*/
|
|
44
44
|
readonly instructions: string_markdown;
|
|
45
|
+
/**
|
|
46
|
+
* Optional list of knowledge source links (URLs or file paths) to attach to the assistant via vector store
|
|
47
|
+
*/
|
|
48
|
+
readonly knowledgeSources?: ReadonlyArray<string>;
|
|
45
49
|
}): Promise<OpenAiAssistantExecutionTools>;
|
|
46
50
|
/**
|
|
47
51
|
* Discriminant for type guards
|
|
@@ -360,6 +360,12 @@ export type string_base_url = string;
|
|
|
360
360
|
* For example `"https://promptbook.studio/webgpt/"`
|
|
361
361
|
*/
|
|
362
362
|
export type string_pipeline_root_url = string;
|
|
363
|
+
/**
|
|
364
|
+
* Semantic helper
|
|
365
|
+
*
|
|
366
|
+
* For example `"https://s6.ptbk.io/agents/agent-007"`
|
|
367
|
+
*/
|
|
368
|
+
export type string_agent_url = string;
|
|
363
369
|
/**
|
|
364
370
|
* Semantic helper
|
|
365
371
|
*
|
|
@@ -9,6 +9,3 @@
|
|
|
9
9
|
* @private util of `@promptbook/color`
|
|
10
10
|
*/
|
|
11
11
|
export declare function checkChannelValue(channelName: string, value: number): asserts value is number;
|
|
12
|
-
/**
|
|
13
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
14
|
-
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PartialDeep } from 'type-fest';
|
|
2
2
|
import type { AgentBasicInformation } from '../../book-2.0/agent-source/AgentBasicInformation';
|
|
3
|
-
import { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
|
-
import { string_agent_name_in_book } from '../../types/typeAliases';
|
|
3
|
+
import type { string_book } from '../../book-2.0/agent-source/string_book';
|
|
4
|
+
import type { string_agent_name_in_book } from '../../types/typeAliases';
|
|
5
5
|
type GenerateBookBoilerplateOptions = PartialDeep<Omit<AgentBasicInformation, 'parameters'>> & {
|
|
6
6
|
/**
|
|
7
7
|
* Name of the parent agent to inherit from
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { string_color, string_person_fullname } from '../../types/typeAliases';
|
|
1
|
+
import type { string_color, string_person_fullname } from '../../types/typeAliases';
|
|
2
2
|
export type RandomFullnameWithColorResult = {
|
|
3
3
|
fullname: string_person_fullname;
|
|
4
4
|
color: string_color;
|
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.103.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.103.0-46`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
package/umd/index.umd.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
* @generated
|
|
57
57
|
* @see https://github.com/webgptorg/promptbook
|
|
58
58
|
*/
|
|
59
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
59
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-47';
|
|
60
60
|
/**
|
|
61
61
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
62
62
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -69,15 +69,20 @@
|
|
|
69
69
|
*/
|
|
70
70
|
const REMOTE_SERVER_URLS = [
|
|
71
71
|
{
|
|
72
|
-
title: 'Promptbook',
|
|
73
|
-
description: `
|
|
72
|
+
title: 'Promptbook.Studio',
|
|
73
|
+
description: `Server of Promptbook.studio`,
|
|
74
74
|
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
75
|
-
isAnonymousModeAllowed: true,
|
|
76
75
|
urls: [
|
|
77
76
|
'https://promptbook.s5.ptbk.io/',
|
|
78
77
|
// Note: Servers 1-4 are not running
|
|
79
78
|
],
|
|
80
79
|
},
|
|
80
|
+
{
|
|
81
|
+
title: 'Testing Agents',
|
|
82
|
+
description: `Testing Agents server on Vercel`,
|
|
83
|
+
owner: 'AI Web, LLC <legal@ptbk.io> (https://www.ptbk.io/)',
|
|
84
|
+
urls: ['https://s6.ptbk.io/'],
|
|
85
|
+
},
|
|
81
86
|
/*
|
|
82
87
|
Note: Working on older version of Promptbook and not supported anymore
|
|
83
88
|
{
|
|
@@ -335,9 +340,6 @@
|
|
|
335
340
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
336
341
|
}
|
|
337
342
|
}
|
|
338
|
-
/**
|
|
339
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
340
|
-
*/
|
|
341
343
|
|
|
342
344
|
/**
|
|
343
345
|
* Color object represents an RGB color with alpha channel
|
|
@@ -15094,11 +15096,13 @@
|
|
|
15094
15096
|
async function startAgentServer(options) {
|
|
15095
15097
|
const { port = 4440 } = options;
|
|
15096
15098
|
// TODO: !!!! [🌕]
|
|
15099
|
+
const agentsServerRoot = path.join(__dirname, '../apps/agents-server');
|
|
15097
15100
|
console.trace(`!!! Starting agents server on port ${port}...`);
|
|
15098
15101
|
console.log(`!!! cwd`, process.cwd());
|
|
15099
15102
|
console.log(`!!! __dirname`, __dirname);
|
|
15103
|
+
console.log(`!!! agentsServerRoot`, agentsServerRoot);
|
|
15100
15104
|
await $execCommand({
|
|
15101
|
-
cwd:
|
|
15105
|
+
cwd: agentsServerRoot,
|
|
15102
15106
|
command: `next dev --port ${port} `,
|
|
15103
15107
|
isVerbose: true,
|
|
15104
15108
|
});
|
|
@@ -18851,26 +18855,6 @@
|
|
|
18851
18855
|
output: pricing(`$0.45 / 1M tokens`),
|
|
18852
18856
|
},
|
|
18853
18857
|
},
|
|
18854
|
-
{
|
|
18855
|
-
modelVariant: 'CHAT',
|
|
18856
|
-
modelTitle: 'Gemini 2.0 Flash',
|
|
18857
|
-
modelName: 'gemini-2.0-flash',
|
|
18858
|
-
modelDescription: 'Fast, efficient model with 128K context window optimized for rapid response times. Balances performance and cost with 2x lower latency than Pro models while maintaining strong capabilities in text generation, code completion, and logical reasoning. Excellent for interactive applications, chatbots, and services requiring quick responses with good quality.',
|
|
18859
|
-
pricing: {
|
|
18860
|
-
prompt: pricing(`$0.35 / 1M tokens`),
|
|
18861
|
-
output: pricing(`$1.05 / 1M tokens`),
|
|
18862
|
-
},
|
|
18863
|
-
},
|
|
18864
|
-
{
|
|
18865
|
-
modelVariant: 'CHAT',
|
|
18866
|
-
modelTitle: 'Gemini 2.0 Flash Lite',
|
|
18867
|
-
modelName: 'gemini-2.0-flash-lite',
|
|
18868
|
-
modelDescription: 'Streamlined version of Gemini 2.0 Flash with 64K context window, designed for extremely low-latency applications. Features 40% smaller model size and 3x faster inference while retaining core capabilities for text and simple reasoning tasks. Perfect for mobile applications, edge deployments, and high-volume services with strict latency requirements.',
|
|
18869
|
-
pricing: {
|
|
18870
|
-
prompt: pricing(`$0.20 / 1M tokens`),
|
|
18871
|
-
output: pricing(`$0.60 / 1M tokens`),
|
|
18872
|
-
},
|
|
18873
|
-
},
|
|
18874
18858
|
{
|
|
18875
18859
|
modelVariant: 'CHAT',
|
|
18876
18860
|
modelTitle: 'Gemini 2.0 Flash Thinking',
|
|
@@ -20407,7 +20391,7 @@
|
|
|
20407
20391
|
*
|
|
20408
20392
|
* This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
|
|
20409
20393
|
*
|
|
20410
|
-
* Note: [🦖] There are several different things in Promptbook:
|
|
20394
|
+
* !!! Note: [🦖] There are several different things in Promptbook:
|
|
20411
20395
|
* - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
|
|
20412
20396
|
* - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
|
|
20413
20397
|
* - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
|
|
@@ -20513,17 +20497,21 @@
|
|
|
20513
20497
|
console.info('connect', stream.currentEvent);
|
|
20514
20498
|
}
|
|
20515
20499
|
});
|
|
20500
|
+
/*
|
|
20516
20501
|
stream.on('messageDelta', (messageDelta) => {
|
|
20517
|
-
|
|
20518
|
-
|
|
20502
|
+
if (
|
|
20503
|
+
this.options.isVerbose &&
|
|
20519
20504
|
messageDelta &&
|
|
20520
20505
|
messageDelta.content &&
|
|
20521
20506
|
messageDelta.content[0] &&
|
|
20522
|
-
messageDelta.content[0].type === 'text'
|
|
20523
|
-
|
|
20507
|
+
messageDelta.content[0].type === 'text'
|
|
20508
|
+
) {
|
|
20509
|
+
console.info('messageDelta', messageDelta.content[0].text?.value);
|
|
20524
20510
|
}
|
|
20511
|
+
|
|
20525
20512
|
// <- TODO: [🐚] Make streaming and running tasks working
|
|
20526
20513
|
});
|
|
20514
|
+
*/
|
|
20527
20515
|
stream.on('messageCreated', (message) => {
|
|
20528
20516
|
if (this.options.isVerbose) {
|
|
20529
20517
|
console.info('messageCreated', message);
|
|
@@ -20603,64 +20591,85 @@
|
|
|
20603
20591
|
throw new NotAllowed(`Creating new assistants is not allowed. Set \`isCreatingNewAssistantsAllowed: true\` in options to enable this feature.`);
|
|
20604
20592
|
}
|
|
20605
20593
|
// await this.playground();
|
|
20606
|
-
const { name, instructions } = options;
|
|
20594
|
+
const { name, instructions, knowledgeSources } = options;
|
|
20607
20595
|
const client = await this.getClient();
|
|
20608
|
-
|
|
20609
|
-
//
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
|
|
20617
|
-
if (!res.ok) throw new Error(`Download error: ${url}`);
|
|
20618
|
-
const buffer = await res.arrayBuffer();
|
|
20619
|
-
fs.writeFileSync(filepath, Buffer.from(buffer));
|
|
20620
|
-
console.log(`📥 File downloaded: ${filename}`);
|
|
20621
|
-
|
|
20622
|
-
return filepath;
|
|
20623
|
-
}
|
|
20624
|
-
|
|
20625
|
-
async function uploadFileToOpenAI(filepath: string) {
|
|
20626
|
-
const file = await client.files.create({
|
|
20627
|
-
file: fs.createReadStream(filepath),
|
|
20628
|
-
purpose: 'assistants',
|
|
20596
|
+
let vectorStoreId;
|
|
20597
|
+
// If knowledge sources are provided, create a vector store with them
|
|
20598
|
+
if (knowledgeSources && knowledgeSources.length > 0) {
|
|
20599
|
+
if (this.options.isVerbose) {
|
|
20600
|
+
console.info(`📚 Creating vector store with ${knowledgeSources.length} knowledge sources...`);
|
|
20601
|
+
}
|
|
20602
|
+
// Create a vector store
|
|
20603
|
+
const vectorStore = await client.beta.vectorStores.create({
|
|
20604
|
+
name: `${name} Knowledge Base`,
|
|
20629
20605
|
});
|
|
20630
|
-
|
|
20631
|
-
|
|
20632
|
-
|
|
20633
|
-
|
|
20634
|
-
|
|
20635
|
-
|
|
20636
|
-
|
|
20637
|
-
|
|
20638
|
-
|
|
20639
|
-
|
|
20640
|
-
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20644
|
-
|
|
20645
|
-
|
|
20646
|
-
|
|
20647
|
-
|
|
20648
|
-
|
|
20649
|
-
|
|
20650
|
-
|
|
20651
|
-
|
|
20606
|
+
vectorStoreId = vectorStore.id;
|
|
20607
|
+
if (this.options.isVerbose) {
|
|
20608
|
+
console.info(`✅ Vector store created: ${vectorStoreId}`);
|
|
20609
|
+
}
|
|
20610
|
+
// Upload files from knowledge sources to the vector store
|
|
20611
|
+
const fileStreams = [];
|
|
20612
|
+
for (const source of knowledgeSources) {
|
|
20613
|
+
try {
|
|
20614
|
+
// Check if it's a URL
|
|
20615
|
+
if (source.startsWith('http://') || source.startsWith('https://')) {
|
|
20616
|
+
// Download the file
|
|
20617
|
+
const response = await fetch(source);
|
|
20618
|
+
if (!response.ok) {
|
|
20619
|
+
console.error(`Failed to download ${source}: ${response.statusText}`);
|
|
20620
|
+
continue;
|
|
20621
|
+
}
|
|
20622
|
+
const buffer = await response.arrayBuffer();
|
|
20623
|
+
const filename = source.split('/').pop() || 'downloaded-file';
|
|
20624
|
+
const blob = new Blob([buffer]);
|
|
20625
|
+
const file = new File([blob], filename);
|
|
20626
|
+
fileStreams.push(file);
|
|
20627
|
+
}
|
|
20628
|
+
else {
|
|
20629
|
+
// Assume it's a local file path
|
|
20630
|
+
// Note: This will work in Node.js environment
|
|
20631
|
+
// For browser environments, this would need different handling
|
|
20632
|
+
const fs = await import('fs');
|
|
20633
|
+
const fileStream = fs.createReadStream(source);
|
|
20634
|
+
fileStreams.push(fileStream);
|
|
20635
|
+
}
|
|
20636
|
+
}
|
|
20637
|
+
catch (error) {
|
|
20638
|
+
console.error(`Error processing knowledge source ${source}:`, error);
|
|
20639
|
+
}
|
|
20640
|
+
}
|
|
20641
|
+
// Batch upload files to the vector store
|
|
20642
|
+
if (fileStreams.length > 0) {
|
|
20643
|
+
try {
|
|
20644
|
+
await client.beta.vectorStores.fileBatches.uploadAndPoll(vectorStoreId, {
|
|
20645
|
+
files: fileStreams,
|
|
20646
|
+
});
|
|
20647
|
+
if (this.options.isVerbose) {
|
|
20648
|
+
console.info(`✅ Uploaded ${fileStreams.length} files to vector store`);
|
|
20649
|
+
}
|
|
20650
|
+
}
|
|
20651
|
+
catch (error) {
|
|
20652
|
+
console.error('Error uploading files to vector store:', error);
|
|
20653
|
+
}
|
|
20654
|
+
}
|
|
20652
20655
|
}
|
|
20653
|
-
|
|
20654
|
-
|
|
20655
|
-
// 3️⃣ Create assistant with uploaded files
|
|
20656
|
-
const assistant = await client.beta.assistants.create({
|
|
20656
|
+
// Create assistant with vector store attached
|
|
20657
|
+
const assistantConfig = {
|
|
20657
20658
|
name,
|
|
20658
20659
|
description: 'Assistant created via Promptbook',
|
|
20659
20660
|
model: 'gpt-4o',
|
|
20660
20661
|
instructions,
|
|
20661
20662
|
tools: [/* TODO: [🧠] Maybe add { type: 'code_interpreter' }, */ { type: 'file_search' }],
|
|
20662
|
-
|
|
20663
|
-
|
|
20663
|
+
};
|
|
20664
|
+
// Attach vector store if created
|
|
20665
|
+
if (vectorStoreId) {
|
|
20666
|
+
assistantConfig.tool_resources = {
|
|
20667
|
+
file_search: {
|
|
20668
|
+
vector_store_ids: [vectorStoreId],
|
|
20669
|
+
},
|
|
20670
|
+
};
|
|
20671
|
+
}
|
|
20672
|
+
const assistant = await client.beta.assistants.create(assistantConfig);
|
|
20664
20673
|
console.log(`✅ Assistant created: ${assistant.id}`);
|
|
20665
20674
|
// TODO: !!!! Try listing existing assistants
|
|
20666
20675
|
// TODO: !!!! Try marking existing assistants by DISCRIMINANT
|
|
@@ -22234,40 +22243,6 @@
|
|
|
22234
22243
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
22235
22244
|
*/
|
|
22236
22245
|
|
|
22237
|
-
/**
|
|
22238
|
-
* Creates an empty/basic agent model requirements object
|
|
22239
|
-
* This serves as the starting point for the reduce-like pattern
|
|
22240
|
-
* where each commitment applies its changes to build the final requirements
|
|
22241
|
-
*
|
|
22242
|
-
* @public exported from `@promptbook/core`
|
|
22243
|
-
*/
|
|
22244
|
-
function createEmptyAgentModelRequirements() {
|
|
22245
|
-
return {
|
|
22246
|
-
systemMessage: '',
|
|
22247
|
-
// modelName: 'gpt-5',
|
|
22248
|
-
modelName: 'gemini-2.5-flash-lite',
|
|
22249
|
-
temperature: 0.7,
|
|
22250
|
-
topP: 0.9,
|
|
22251
|
-
topK: 50,
|
|
22252
|
-
};
|
|
22253
|
-
}
|
|
22254
|
-
/**
|
|
22255
|
-
* Creates a basic agent model requirements with just the agent name
|
|
22256
|
-
* This is used when we have an agent name but no commitments
|
|
22257
|
-
*
|
|
22258
|
-
* @public exported from `@promptbook/core`
|
|
22259
|
-
*/
|
|
22260
|
-
function createBasicAgentModelRequirements(agentName) {
|
|
22261
|
-
const empty = createEmptyAgentModelRequirements();
|
|
22262
|
-
return {
|
|
22263
|
-
...empty,
|
|
22264
|
-
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
22265
|
-
};
|
|
22266
|
-
}
|
|
22267
|
-
/**
|
|
22268
|
-
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
22269
|
-
*/
|
|
22270
|
-
|
|
22271
22246
|
/**
|
|
22272
22247
|
* Generates a regex pattern to match a specific commitment
|
|
22273
22248
|
*
|
|
@@ -22801,23 +22776,19 @@
|
|
|
22801
22776
|
`);
|
|
22802
22777
|
}
|
|
22803
22778
|
applyToAgentModelRequirements(requirements, content) {
|
|
22804
|
-
var _a;
|
|
22805
22779
|
const trimmedContent = content.trim();
|
|
22806
22780
|
if (!trimmedContent) {
|
|
22807
22781
|
return requirements;
|
|
22808
22782
|
}
|
|
22809
22783
|
// Check if content is a URL (external knowledge source)
|
|
22810
|
-
if (
|
|
22784
|
+
if (isValidUrl(trimmedContent)) {
|
|
22811
22785
|
// Store the URL for later async processing
|
|
22812
22786
|
const updatedRequirements = {
|
|
22813
22787
|
...requirements,
|
|
22814
|
-
|
|
22815
|
-
...requirements.
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
trimmedContent,
|
|
22819
|
-
],
|
|
22820
|
-
},
|
|
22788
|
+
knowledgeSources: [
|
|
22789
|
+
...(requirements.knowledgeSources || []),
|
|
22790
|
+
trimmedContent,
|
|
22791
|
+
],
|
|
22821
22792
|
};
|
|
22822
22793
|
// Add placeholder information about knowledge sources to system message
|
|
22823
22794
|
const knowledgeInfo = `Knowledge Source URL: ${trimmedContent} (will be processed for retrieval during chat)`;
|
|
@@ -22829,18 +22800,6 @@
|
|
|
22829
22800
|
return this.appendToSystemMessage(requirements, knowledgeSection, '\n\n');
|
|
22830
22801
|
}
|
|
22831
22802
|
}
|
|
22832
|
-
/**
|
|
22833
|
-
* Check if content is a URL
|
|
22834
|
-
*/
|
|
22835
|
-
isUrl(content) {
|
|
22836
|
-
try {
|
|
22837
|
-
new URL(content);
|
|
22838
|
-
return true;
|
|
22839
|
-
}
|
|
22840
|
-
catch (_a) {
|
|
22841
|
-
return false;
|
|
22842
|
-
}
|
|
22843
|
-
}
|
|
22844
22803
|
}
|
|
22845
22804
|
/**
|
|
22846
22805
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -24138,6 +24097,40 @@
|
|
|
24138
24097
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24139
24098
|
*/
|
|
24140
24099
|
|
|
24100
|
+
/**
|
|
24101
|
+
* Creates an empty/basic agent model requirements object
|
|
24102
|
+
* This serves as the starting point for the reduce-like pattern
|
|
24103
|
+
* where each commitment applies its changes to build the final requirements
|
|
24104
|
+
*
|
|
24105
|
+
* @public exported from `@promptbook/core`
|
|
24106
|
+
*/
|
|
24107
|
+
function createEmptyAgentModelRequirements() {
|
|
24108
|
+
return {
|
|
24109
|
+
systemMessage: '',
|
|
24110
|
+
// modelName: 'gpt-5',
|
|
24111
|
+
modelName: 'gemini-2.5-flash-lite',
|
|
24112
|
+
temperature: 0.7,
|
|
24113
|
+
topP: 0.9,
|
|
24114
|
+
topK: 50,
|
|
24115
|
+
};
|
|
24116
|
+
}
|
|
24117
|
+
/**
|
|
24118
|
+
* Creates a basic agent model requirements with just the agent name
|
|
24119
|
+
* This is used when we have an agent name but no commitments
|
|
24120
|
+
*
|
|
24121
|
+
* @public exported from `@promptbook/core`
|
|
24122
|
+
*/
|
|
24123
|
+
function createBasicAgentModelRequirements(agentName) {
|
|
24124
|
+
const empty = createEmptyAgentModelRequirements();
|
|
24125
|
+
return {
|
|
24126
|
+
...empty,
|
|
24127
|
+
systemMessage: `You are ${agentName || 'AI Agent'}`,
|
|
24128
|
+
};
|
|
24129
|
+
}
|
|
24130
|
+
/**
|
|
24131
|
+
* TODO: [🐤] Deduplicate `AgentModelRequirements` and `ModelRequirements` model requirements
|
|
24132
|
+
*/
|
|
24133
|
+
|
|
24141
24134
|
/**
|
|
24142
24135
|
* Parses agent source using the new commitment system with multiline support
|
|
24143
24136
|
* This function replaces the hardcoded commitment parsing in the original parseAgentSource
|
|
@@ -24228,29 +24221,6 @@
|
|
|
24228
24221
|
};
|
|
24229
24222
|
}
|
|
24230
24223
|
|
|
24231
|
-
/**
|
|
24232
|
-
* Removes comment lines (lines starting with #) from a system message
|
|
24233
|
-
* This is used to clean up the final system message before sending it to the AI model
|
|
24234
|
-
* while preserving the original content with comments in metadata
|
|
24235
|
-
*
|
|
24236
|
-
* @param systemMessage The system message that may contain comment lines
|
|
24237
|
-
* @returns The system message with comment lines removed
|
|
24238
|
-
*
|
|
24239
|
-
* @private - TODO: [🧠] Maybe should be public?
|
|
24240
|
-
*/
|
|
24241
|
-
function removeCommentsFromSystemMessage(systemMessage) {
|
|
24242
|
-
if (!systemMessage) {
|
|
24243
|
-
return systemMessage;
|
|
24244
|
-
}
|
|
24245
|
-
const lines = systemMessage.split('\n');
|
|
24246
|
-
const filteredLines = lines.filter((line) => {
|
|
24247
|
-
const trimmedLine = line.trim();
|
|
24248
|
-
// Remove lines that start with # (comments)
|
|
24249
|
-
return !trimmedLine.startsWith('#');
|
|
24250
|
-
});
|
|
24251
|
-
return filteredLines.join('\n').trim();
|
|
24252
|
-
}
|
|
24253
|
-
|
|
24254
24224
|
/**
|
|
24255
24225
|
* Parses parameters from text using both supported notations:
|
|
24256
24226
|
* 1. @Parameter - single word parameter starting with @
|
|
@@ -24309,6 +24279,29 @@
|
|
|
24309
24279
|
return uniqueParameters;
|
|
24310
24280
|
}
|
|
24311
24281
|
|
|
24282
|
+
/**
|
|
24283
|
+
* Removes comment lines (lines starting with #) from a system message
|
|
24284
|
+
* This is used to clean up the final system message before sending it to the AI model
|
|
24285
|
+
* while preserving the original content with comments in metadata
|
|
24286
|
+
*
|
|
24287
|
+
* @param systemMessage The system message that may contain comment lines
|
|
24288
|
+
* @returns The system message with comment lines removed
|
|
24289
|
+
*
|
|
24290
|
+
* @private - TODO: [🧠] Maybe should be public?
|
|
24291
|
+
*/
|
|
24292
|
+
function removeCommentsFromSystemMessage(systemMessage) {
|
|
24293
|
+
if (!systemMessage) {
|
|
24294
|
+
return systemMessage;
|
|
24295
|
+
}
|
|
24296
|
+
const lines = systemMessage.split('\n');
|
|
24297
|
+
const filteredLines = lines.filter((line) => {
|
|
24298
|
+
const trimmedLine = line.trim();
|
|
24299
|
+
// Remove lines that start with # (comments)
|
|
24300
|
+
return !trimmedLine.startsWith('#');
|
|
24301
|
+
});
|
|
24302
|
+
return filteredLines.join('\n').trim();
|
|
24303
|
+
}
|
|
24304
|
+
|
|
24312
24305
|
/**
|
|
24313
24306
|
* Creates agent model requirements using the new commitment system
|
|
24314
24307
|
* This function uses a reduce-like pattern where each commitment applies its changes
|