@promptbook/node 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 +3 -5
- package/umd/index.umd.js +90 -21
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -34,7 +34,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
34
34
|
* @generated
|
|
35
35
|
* @see https://github.com/webgptorg/promptbook
|
|
36
36
|
*/
|
|
37
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-
|
|
37
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-4';
|
|
38
38
|
/**
|
|
39
39
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
40
40
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -16974,11 +16974,16 @@ function createTeamToolFunction(entry) {
|
|
|
16974
16974
|
const request = buildTeammateRequest(message, args.context);
|
|
16975
16975
|
let response = '';
|
|
16976
16976
|
let error = null;
|
|
16977
|
+
let toolCalls;
|
|
16977
16978
|
try {
|
|
16978
16979
|
const remoteAgent = await getRemoteTeammateAgent(entry.teammate.url);
|
|
16979
16980
|
const prompt = buildTeammatePrompt(request);
|
|
16980
16981
|
const teammateResult = await remoteAgent.callChatModel(prompt);
|
|
16981
16982
|
response = teammateResult.content || '';
|
|
16983
|
+
toolCalls =
|
|
16984
|
+
'toolCalls' in teammateResult && Array.isArray(teammateResult.toolCalls)
|
|
16985
|
+
? teammateResult.toolCalls
|
|
16986
|
+
: undefined;
|
|
16982
16987
|
}
|
|
16983
16988
|
catch (err) {
|
|
16984
16989
|
error = err instanceof Error ? err.message : String(err);
|
|
@@ -16988,6 +16993,7 @@ function createTeamToolFunction(entry) {
|
|
|
16988
16993
|
teammate: teammateMetadata,
|
|
16989
16994
|
request,
|
|
16990
16995
|
response: teammateReply,
|
|
16996
|
+
toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
16991
16997
|
error,
|
|
16992
16998
|
conversation: [
|
|
16993
16999
|
{
|
|
@@ -24552,7 +24558,20 @@ class AgentLlmExecutionTools {
|
|
|
24552
24558
|
const requirementsHash = SHA256(JSON.stringify(modelRequirements)).toString();
|
|
24553
24559
|
const cached = AgentLlmExecutionTools.assistantCache.get(this.title);
|
|
24554
24560
|
let assistant;
|
|
24555
|
-
if (
|
|
24561
|
+
if (this.options.assistantPreparationMode === 'external') {
|
|
24562
|
+
assistant = this.options.llmTools;
|
|
24563
|
+
if (this.options.isVerbose) {
|
|
24564
|
+
console.info('[🤰]', 'Using externally managed OpenAI Assistant', {
|
|
24565
|
+
agent: this.title,
|
|
24566
|
+
assistantId: assistant.assistantId,
|
|
24567
|
+
});
|
|
24568
|
+
}
|
|
24569
|
+
AgentLlmExecutionTools.assistantCache.set(this.title, {
|
|
24570
|
+
assistantId: assistant.assistantId,
|
|
24571
|
+
requirementsHash,
|
|
24572
|
+
});
|
|
24573
|
+
}
|
|
24574
|
+
else if (cached) {
|
|
24556
24575
|
if (cached.requirementsHash === requirementsHash) {
|
|
24557
24576
|
if (this.options.isVerbose) {
|
|
24558
24577
|
console.info('[🤰]', 'Using cached OpenAI Assistant', {
|
|
@@ -24618,11 +24637,6 @@ class AgentLlmExecutionTools {
|
|
|
24618
24637
|
requirementsHash,
|
|
24619
24638
|
});
|
|
24620
24639
|
}
|
|
24621
|
-
// [0] Expose prepared externals
|
|
24622
|
-
if (this.preparedExternals) {
|
|
24623
|
-
this /* <- TODO: !!!!!! Remove */.preparedExternals.openaiAssistantId =
|
|
24624
|
-
assistant.assistantId;
|
|
24625
|
-
}
|
|
24626
24640
|
// Create modified chat prompt with agent system message specific to OpenAI Assistant
|
|
24627
24641
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = {
|
|
24628
24642
|
...promptWithAgentModelRequirements,
|
|
@@ -24776,6 +24790,7 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
24776
24790
|
super({
|
|
24777
24791
|
isVerbose: options.isVerbose,
|
|
24778
24792
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
24793
|
+
assistantPreparationMode: options.assistantPreparationMode,
|
|
24779
24794
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
24780
24795
|
});
|
|
24781
24796
|
_Agent_instances.add(this);
|
|
@@ -24815,10 +24830,6 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
24815
24830
|
* Human-readable titles for tool functions
|
|
24816
24831
|
*/
|
|
24817
24832
|
this.toolTitles = {};
|
|
24818
|
-
/**
|
|
24819
|
-
* Externals prepared for the agent, like OpenAI assistant, etc.
|
|
24820
|
-
*/
|
|
24821
|
-
this.preparedExternals = {};
|
|
24822
24833
|
// TODO: [🐱🚀] Add `Agent` simple "mocked" learning by appending to agent source
|
|
24823
24834
|
// TODO: [🐱🚀] Add `Agent` learning by promptbookAgent
|
|
24824
24835
|
this.teacherAgent = options.teacherAgent;
|
|
@@ -25055,6 +25066,63 @@ async function _Agent_selfLearnTeacher(prompt, result) {
|
|
|
25055
25066
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
25056
25067
|
*/
|
|
25057
25068
|
|
|
25069
|
+
/**
|
|
25070
|
+
* Resolve a remote META IMAGE value into an absolute URL when possible.
|
|
25071
|
+
*/
|
|
25072
|
+
function resolveRemoteImageUrl(imageUrl, agentUrl) {
|
|
25073
|
+
if (!imageUrl) {
|
|
25074
|
+
return undefined;
|
|
25075
|
+
}
|
|
25076
|
+
if (imageUrl.startsWith('http://') ||
|
|
25077
|
+
imageUrl.startsWith('https://') ||
|
|
25078
|
+
imageUrl.startsWith('data:') ||
|
|
25079
|
+
imageUrl.startsWith('blob:')) {
|
|
25080
|
+
return imageUrl;
|
|
25081
|
+
}
|
|
25082
|
+
try {
|
|
25083
|
+
return new URL(imageUrl, agentUrl).href;
|
|
25084
|
+
}
|
|
25085
|
+
catch (_a) {
|
|
25086
|
+
return imageUrl;
|
|
25087
|
+
}
|
|
25088
|
+
}
|
|
25089
|
+
/**
|
|
25090
|
+
* Format a META commitment line when the value is provided.
|
|
25091
|
+
*/
|
|
25092
|
+
function formatMetaLine(label, value) {
|
|
25093
|
+
if (!value) {
|
|
25094
|
+
return null;
|
|
25095
|
+
}
|
|
25096
|
+
return `META ${label} ${value}`;
|
|
25097
|
+
}
|
|
25098
|
+
/**
|
|
25099
|
+
* Build a minimal agent source snapshot for remote agents.
|
|
25100
|
+
*/
|
|
25101
|
+
function buildRemoteAgentSource(profile, meta) {
|
|
25102
|
+
const metaLines = [
|
|
25103
|
+
formatMetaLine('FULLNAME', meta === null || meta === void 0 ? void 0 : meta.fullname),
|
|
25104
|
+
formatMetaLine('IMAGE', meta === null || meta === void 0 ? void 0 : meta.image),
|
|
25105
|
+
formatMetaLine('DESCRIPTION', meta === null || meta === void 0 ? void 0 : meta.description),
|
|
25106
|
+
formatMetaLine('COLOR', meta === null || meta === void 0 ? void 0 : meta.color),
|
|
25107
|
+
formatMetaLine('FONT', meta === null || meta === void 0 ? void 0 : meta.font),
|
|
25108
|
+
formatMetaLine('LINK', meta === null || meta === void 0 ? void 0 : meta.link),
|
|
25109
|
+
]
|
|
25110
|
+
.filter((line) => Boolean(line))
|
|
25111
|
+
.join('\n');
|
|
25112
|
+
const personaBlock = profile.personaDescription
|
|
25113
|
+
? spaceTrim$2((block) => `
|
|
25114
|
+
PERSONA
|
|
25115
|
+
${block(profile.personaDescription || '')}
|
|
25116
|
+
`)
|
|
25117
|
+
: '';
|
|
25118
|
+
return book `
|
|
25119
|
+
${profile.agentName}
|
|
25120
|
+
|
|
25121
|
+
${metaLines}
|
|
25122
|
+
|
|
25123
|
+
${personaBlock}
|
|
25124
|
+
`;
|
|
25125
|
+
}
|
|
25058
25126
|
/**
|
|
25059
25127
|
* Represents one AI Agent
|
|
25060
25128
|
*
|
|
@@ -25069,6 +25137,7 @@ async function _Agent_selfLearnTeacher(prompt, result) {
|
|
|
25069
25137
|
*/
|
|
25070
25138
|
class RemoteAgent extends Agent {
|
|
25071
25139
|
static async connect(options) {
|
|
25140
|
+
var _a, _b, _c;
|
|
25072
25141
|
const agentProfileUrl = `${options.agentUrl}/api/profile`;
|
|
25073
25142
|
const profileResponse = await fetch(agentProfileUrl);
|
|
25074
25143
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
@@ -25088,14 +25157,14 @@ class RemoteAgent extends Agent {
|
|
|
25088
25157
|
|
|
25089
25158
|
`));
|
|
25090
25159
|
}
|
|
25091
|
-
const profile = await profileResponse.json();
|
|
25160
|
+
const profile = (await profileResponse.json());
|
|
25161
|
+
const resolvedMeta = {
|
|
25162
|
+
...(profile.meta || {}),
|
|
25163
|
+
image: resolveRemoteImageUrl((_a = profile.meta) === null || _a === void 0 ? void 0 : _a.image, options.agentUrl),
|
|
25164
|
+
};
|
|
25092
25165
|
// Note: We are creating dummy agent source because we don't have the source from the remote agent
|
|
25093
25166
|
// But we populate the metadata from the profile
|
|
25094
|
-
const agentSource = new BehaviorSubject(
|
|
25095
|
-
${profile.agentName}
|
|
25096
|
-
|
|
25097
|
-
${profile.personaDescription}
|
|
25098
|
-
`);
|
|
25167
|
+
const agentSource = new BehaviorSubject(buildRemoteAgentSource(profile, resolvedMeta));
|
|
25099
25168
|
// <- TODO: [🐱🚀] createBookFromProfile
|
|
25100
25169
|
// <- TODO: [🐱🚀] Support updating and self-updating
|
|
25101
25170
|
const remoteAgent = new RemoteAgent({
|
|
@@ -25118,10 +25187,10 @@ class RemoteAgent extends Agent {
|
|
|
25118
25187
|
});
|
|
25119
25188
|
remoteAgent._remoteAgentName = profile.agentName;
|
|
25120
25189
|
remoteAgent._remoteAgentHash = profile.agentHash;
|
|
25121
|
-
remoteAgent.personaDescription = profile.personaDescription;
|
|
25122
|
-
remoteAgent.initialMessage = profile.initialMessage;
|
|
25123
|
-
remoteAgent.links = profile.links;
|
|
25124
|
-
remoteAgent.meta =
|
|
25190
|
+
remoteAgent.personaDescription = (_b = profile.personaDescription) !== null && _b !== void 0 ? _b : null;
|
|
25191
|
+
remoteAgent.initialMessage = (_c = profile.initialMessage) !== null && _c !== void 0 ? _c : null;
|
|
25192
|
+
remoteAgent.links = profile.links || [];
|
|
25193
|
+
remoteAgent.meta = resolvedMeta;
|
|
25125
25194
|
remoteAgent.capabilities = profile.capabilities || [];
|
|
25126
25195
|
remoteAgent.samples = profile.samples || [];
|
|
25127
25196
|
remoteAgent.toolTitles = profile.toolTitles || {};
|