@promptbook/core 0.110.0-3 → 0.110.0-4
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 +90 -21
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/types.index.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatActionsBar.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/Chat/ChatMessageList.d.ts +0 -2
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +0 -7
- package/esm/typings/src/book-components/Chat/SourceChip/SourceChip.d.ts +5 -1
- package/esm/typings/src/book-components/Chat/hooks/useChatActionsOverlap.d.ts +6 -3
- package/esm/typings/src/book-components/Chat/utils/collectTeamToolCallSummary.d.ts +69 -0
- package/esm/typings/src/book-components/Chat/utils/getToolCallChipletInfo.d.ts +13 -6
- package/esm/typings/src/book-components/Chat/utils/parseCitationsFromContent.d.ts +9 -0
- package/esm/typings/src/book-components/Chat/utils/toolCallParsing.d.ts +4 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +0 -6
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +9 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
- package/esm/typings/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +29 -0
- package/package.json +1 -4
- package/umd/index.umd.js +90 -21
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -27,7 +27,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
27
27
|
* @generated
|
|
28
28
|
* @see https://github.com/webgptorg/promptbook
|
|
29
29
|
*/
|
|
30
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-
|
|
30
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-4';
|
|
31
31
|
/**
|
|
32
32
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
33
33
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -13347,11 +13347,16 @@ function createTeamToolFunction(entry) {
|
|
|
13347
13347
|
const request = buildTeammateRequest(message, args.context);
|
|
13348
13348
|
let response = '';
|
|
13349
13349
|
let error = null;
|
|
13350
|
+
let toolCalls;
|
|
13350
13351
|
try {
|
|
13351
13352
|
const remoteAgent = await getRemoteTeammateAgent(entry.teammate.url);
|
|
13352
13353
|
const prompt = buildTeammatePrompt(request);
|
|
13353
13354
|
const teammateResult = await remoteAgent.callChatModel(prompt);
|
|
13354
13355
|
response = teammateResult.content || '';
|
|
13356
|
+
toolCalls =
|
|
13357
|
+
'toolCalls' in teammateResult && Array.isArray(teammateResult.toolCalls)
|
|
13358
|
+
? teammateResult.toolCalls
|
|
13359
|
+
: undefined;
|
|
13355
13360
|
}
|
|
13356
13361
|
catch (err) {
|
|
13357
13362
|
error = err instanceof Error ? err.message : String(err);
|
|
@@ -13361,6 +13366,7 @@ function createTeamToolFunction(entry) {
|
|
|
13361
13366
|
teammate: teammateMetadata,
|
|
13362
13367
|
request,
|
|
13363
13368
|
response: teammateReply,
|
|
13369
|
+
toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
13364
13370
|
error,
|
|
13365
13371
|
conversation: [
|
|
13366
13372
|
{
|
|
@@ -24233,7 +24239,20 @@ class AgentLlmExecutionTools {
|
|
|
24233
24239
|
const requirementsHash = SHA256(JSON.stringify(modelRequirements)).toString();
|
|
24234
24240
|
const cached = AgentLlmExecutionTools.assistantCache.get(this.title);
|
|
24235
24241
|
let assistant;
|
|
24236
|
-
if (
|
|
24242
|
+
if (this.options.assistantPreparationMode === 'external') {
|
|
24243
|
+
assistant = this.options.llmTools;
|
|
24244
|
+
if (this.options.isVerbose) {
|
|
24245
|
+
console.info('[🤰]', 'Using externally managed OpenAI Assistant', {
|
|
24246
|
+
agent: this.title,
|
|
24247
|
+
assistantId: assistant.assistantId,
|
|
24248
|
+
});
|
|
24249
|
+
}
|
|
24250
|
+
AgentLlmExecutionTools.assistantCache.set(this.title, {
|
|
24251
|
+
assistantId: assistant.assistantId,
|
|
24252
|
+
requirementsHash,
|
|
24253
|
+
});
|
|
24254
|
+
}
|
|
24255
|
+
else if (cached) {
|
|
24237
24256
|
if (cached.requirementsHash === requirementsHash) {
|
|
24238
24257
|
if (this.options.isVerbose) {
|
|
24239
24258
|
console.info('[🤰]', 'Using cached OpenAI Assistant', {
|
|
@@ -24299,11 +24318,6 @@ class AgentLlmExecutionTools {
|
|
|
24299
24318
|
requirementsHash,
|
|
24300
24319
|
});
|
|
24301
24320
|
}
|
|
24302
|
-
// [0] Expose prepared externals
|
|
24303
|
-
if (this.preparedExternals) {
|
|
24304
|
-
this /* <- TODO: !!!!!! Remove */.preparedExternals.openaiAssistantId =
|
|
24305
|
-
assistant.assistantId;
|
|
24306
|
-
}
|
|
24307
24321
|
// Create modified chat prompt with agent system message specific to OpenAI Assistant
|
|
24308
24322
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = {
|
|
24309
24323
|
...promptWithAgentModelRequirements,
|
|
@@ -24457,6 +24471,7 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
24457
24471
|
super({
|
|
24458
24472
|
isVerbose: options.isVerbose,
|
|
24459
24473
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
24474
|
+
assistantPreparationMode: options.assistantPreparationMode,
|
|
24460
24475
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
24461
24476
|
});
|
|
24462
24477
|
_Agent_instances.add(this);
|
|
@@ -24496,10 +24511,6 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
24496
24511
|
* Human-readable titles for tool functions
|
|
24497
24512
|
*/
|
|
24498
24513
|
this.toolTitles = {};
|
|
24499
|
-
/**
|
|
24500
|
-
* Externals prepared for the agent, like OpenAI assistant, etc.
|
|
24501
|
-
*/
|
|
24502
|
-
this.preparedExternals = {};
|
|
24503
24514
|
// TODO: [🐱🚀] Add `Agent` simple "mocked" learning by appending to agent source
|
|
24504
24515
|
// TODO: [🐱🚀] Add `Agent` learning by promptbookAgent
|
|
24505
24516
|
this.teacherAgent = options.teacherAgent;
|
|
@@ -24860,6 +24871,63 @@ function book(strings, ...values) {
|
|
|
24860
24871
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24861
24872
|
*/
|
|
24862
24873
|
|
|
24874
|
+
/**
|
|
24875
|
+
* Resolve a remote META IMAGE value into an absolute URL when possible.
|
|
24876
|
+
*/
|
|
24877
|
+
function resolveRemoteImageUrl(imageUrl, agentUrl) {
|
|
24878
|
+
if (!imageUrl) {
|
|
24879
|
+
return undefined;
|
|
24880
|
+
}
|
|
24881
|
+
if (imageUrl.startsWith('http://') ||
|
|
24882
|
+
imageUrl.startsWith('https://') ||
|
|
24883
|
+
imageUrl.startsWith('data:') ||
|
|
24884
|
+
imageUrl.startsWith('blob:')) {
|
|
24885
|
+
return imageUrl;
|
|
24886
|
+
}
|
|
24887
|
+
try {
|
|
24888
|
+
return new URL(imageUrl, agentUrl).href;
|
|
24889
|
+
}
|
|
24890
|
+
catch (_a) {
|
|
24891
|
+
return imageUrl;
|
|
24892
|
+
}
|
|
24893
|
+
}
|
|
24894
|
+
/**
|
|
24895
|
+
* Format a META commitment line when the value is provided.
|
|
24896
|
+
*/
|
|
24897
|
+
function formatMetaLine(label, value) {
|
|
24898
|
+
if (!value) {
|
|
24899
|
+
return null;
|
|
24900
|
+
}
|
|
24901
|
+
return `META ${label} ${value}`;
|
|
24902
|
+
}
|
|
24903
|
+
/**
|
|
24904
|
+
* Build a minimal agent source snapshot for remote agents.
|
|
24905
|
+
*/
|
|
24906
|
+
function buildRemoteAgentSource(profile, meta) {
|
|
24907
|
+
const metaLines = [
|
|
24908
|
+
formatMetaLine('FULLNAME', meta === null || meta === void 0 ? void 0 : meta.fullname),
|
|
24909
|
+
formatMetaLine('IMAGE', meta === null || meta === void 0 ? void 0 : meta.image),
|
|
24910
|
+
formatMetaLine('DESCRIPTION', meta === null || meta === void 0 ? void 0 : meta.description),
|
|
24911
|
+
formatMetaLine('COLOR', meta === null || meta === void 0 ? void 0 : meta.color),
|
|
24912
|
+
formatMetaLine('FONT', meta === null || meta === void 0 ? void 0 : meta.font),
|
|
24913
|
+
formatMetaLine('LINK', meta === null || meta === void 0 ? void 0 : meta.link),
|
|
24914
|
+
]
|
|
24915
|
+
.filter((line) => Boolean(line))
|
|
24916
|
+
.join('\n');
|
|
24917
|
+
const personaBlock = profile.personaDescription
|
|
24918
|
+
? spaceTrim$2((block) => `
|
|
24919
|
+
PERSONA
|
|
24920
|
+
${block(profile.personaDescription || '')}
|
|
24921
|
+
`)
|
|
24922
|
+
: '';
|
|
24923
|
+
return book `
|
|
24924
|
+
${profile.agentName}
|
|
24925
|
+
|
|
24926
|
+
${metaLines}
|
|
24927
|
+
|
|
24928
|
+
${personaBlock}
|
|
24929
|
+
`;
|
|
24930
|
+
}
|
|
24863
24931
|
/**
|
|
24864
24932
|
* Represents one AI Agent
|
|
24865
24933
|
*
|
|
@@ -24874,6 +24942,7 @@ function book(strings, ...values) {
|
|
|
24874
24942
|
*/
|
|
24875
24943
|
class RemoteAgent extends Agent {
|
|
24876
24944
|
static async connect(options) {
|
|
24945
|
+
var _a, _b, _c;
|
|
24877
24946
|
const agentProfileUrl = `${options.agentUrl}/api/profile`;
|
|
24878
24947
|
const profileResponse = await fetch(agentProfileUrl);
|
|
24879
24948
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
@@ -24893,14 +24962,14 @@ class RemoteAgent extends Agent {
|
|
|
24893
24962
|
|
|
24894
24963
|
`));
|
|
24895
24964
|
}
|
|
24896
|
-
const profile = await profileResponse.json();
|
|
24965
|
+
const profile = (await profileResponse.json());
|
|
24966
|
+
const resolvedMeta = {
|
|
24967
|
+
...(profile.meta || {}),
|
|
24968
|
+
image: resolveRemoteImageUrl((_a = profile.meta) === null || _a === void 0 ? void 0 : _a.image, options.agentUrl),
|
|
24969
|
+
};
|
|
24897
24970
|
// Note: We are creating dummy agent source because we don't have the source from the remote agent
|
|
24898
24971
|
// But we populate the metadata from the profile
|
|
24899
|
-
const agentSource = new BehaviorSubject(
|
|
24900
|
-
${profile.agentName}
|
|
24901
|
-
|
|
24902
|
-
${profile.personaDescription}
|
|
24903
|
-
`);
|
|
24972
|
+
const agentSource = new BehaviorSubject(buildRemoteAgentSource(profile, resolvedMeta));
|
|
24904
24973
|
// <- TODO: [🐱🚀] createBookFromProfile
|
|
24905
24974
|
// <- TODO: [🐱🚀] Support updating and self-updating
|
|
24906
24975
|
const remoteAgent = new RemoteAgent({
|
|
@@ -24923,10 +24992,10 @@ class RemoteAgent extends Agent {
|
|
|
24923
24992
|
});
|
|
24924
24993
|
remoteAgent._remoteAgentName = profile.agentName;
|
|
24925
24994
|
remoteAgent._remoteAgentHash = profile.agentHash;
|
|
24926
|
-
remoteAgent.personaDescription = profile.personaDescription;
|
|
24927
|
-
remoteAgent.initialMessage = profile.initialMessage;
|
|
24928
|
-
remoteAgent.links = profile.links;
|
|
24929
|
-
remoteAgent.meta =
|
|
24995
|
+
remoteAgent.personaDescription = (_b = profile.personaDescription) !== null && _b !== void 0 ? _b : null;
|
|
24996
|
+
remoteAgent.initialMessage = (_c = profile.initialMessage) !== null && _c !== void 0 ? _c : null;
|
|
24997
|
+
remoteAgent.links = profile.links || [];
|
|
24998
|
+
remoteAgent.meta = resolvedMeta;
|
|
24930
24999
|
remoteAgent.capabilities = profile.capabilities || [];
|
|
24931
25000
|
remoteAgent.samples = profile.samples || [];
|
|
24932
25001
|
remoteAgent.toolTitles = profile.toolTitles || {};
|