@promptbook/browser 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 +2 -5
- package/umd/index.umd.js +90 -21
- package/umd/index.umd.js.map +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.110.0-4';
|
|
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
|
|
@@ -8616,11 +8616,16 @@ function createTeamToolFunction(entry) {
|
|
|
8616
8616
|
const request = buildTeammateRequest(message, args.context);
|
|
8617
8617
|
let response = '';
|
|
8618
8618
|
let error = null;
|
|
8619
|
+
let toolCalls;
|
|
8619
8620
|
try {
|
|
8620
8621
|
const remoteAgent = await getRemoteTeammateAgent(entry.teammate.url);
|
|
8621
8622
|
const prompt = buildTeammatePrompt(request);
|
|
8622
8623
|
const teammateResult = await remoteAgent.callChatModel(prompt);
|
|
8623
8624
|
response = teammateResult.content || '';
|
|
8625
|
+
toolCalls =
|
|
8626
|
+
'toolCalls' in teammateResult && Array.isArray(teammateResult.toolCalls)
|
|
8627
|
+
? teammateResult.toolCalls
|
|
8628
|
+
: undefined;
|
|
8624
8629
|
}
|
|
8625
8630
|
catch (err) {
|
|
8626
8631
|
error = err instanceof Error ? err.message : String(err);
|
|
@@ -8630,6 +8635,7 @@ function createTeamToolFunction(entry) {
|
|
|
8630
8635
|
teammate: teammateMetadata,
|
|
8631
8636
|
request,
|
|
8632
8637
|
response: teammateReply,
|
|
8638
|
+
toolCalls: toolCalls && toolCalls.length > 0 ? toolCalls : undefined,
|
|
8633
8639
|
error,
|
|
8634
8640
|
conversation: [
|
|
8635
8641
|
{
|
|
@@ -19218,7 +19224,20 @@ class AgentLlmExecutionTools {
|
|
|
19218
19224
|
const requirementsHash = SHA256(JSON.stringify(modelRequirements)).toString();
|
|
19219
19225
|
const cached = AgentLlmExecutionTools.assistantCache.get(this.title);
|
|
19220
19226
|
let assistant;
|
|
19221
|
-
if (
|
|
19227
|
+
if (this.options.assistantPreparationMode === 'external') {
|
|
19228
|
+
assistant = this.options.llmTools;
|
|
19229
|
+
if (this.options.isVerbose) {
|
|
19230
|
+
console.info('[🤰]', 'Using externally managed OpenAI Assistant', {
|
|
19231
|
+
agent: this.title,
|
|
19232
|
+
assistantId: assistant.assistantId,
|
|
19233
|
+
});
|
|
19234
|
+
}
|
|
19235
|
+
AgentLlmExecutionTools.assistantCache.set(this.title, {
|
|
19236
|
+
assistantId: assistant.assistantId,
|
|
19237
|
+
requirementsHash,
|
|
19238
|
+
});
|
|
19239
|
+
}
|
|
19240
|
+
else if (cached) {
|
|
19222
19241
|
if (cached.requirementsHash === requirementsHash) {
|
|
19223
19242
|
if (this.options.isVerbose) {
|
|
19224
19243
|
console.info('[🤰]', 'Using cached OpenAI Assistant', {
|
|
@@ -19284,11 +19303,6 @@ class AgentLlmExecutionTools {
|
|
|
19284
19303
|
requirementsHash,
|
|
19285
19304
|
});
|
|
19286
19305
|
}
|
|
19287
|
-
// [0] Expose prepared externals
|
|
19288
|
-
if (this.preparedExternals) {
|
|
19289
|
-
this /* <- TODO: !!!!!! Remove */.preparedExternals.openaiAssistantId =
|
|
19290
|
-
assistant.assistantId;
|
|
19291
|
-
}
|
|
19292
19306
|
// Create modified chat prompt with agent system message specific to OpenAI Assistant
|
|
19293
19307
|
const promptWithAgentModelRequirementsForOpenAiAssistantExecutionTools = {
|
|
19294
19308
|
...promptWithAgentModelRequirements,
|
|
@@ -19442,6 +19456,7 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19442
19456
|
super({
|
|
19443
19457
|
isVerbose: options.isVerbose,
|
|
19444
19458
|
llmTools: getSingleLlmExecutionTools(options.executionTools.llm),
|
|
19459
|
+
assistantPreparationMode: options.assistantPreparationMode,
|
|
19445
19460
|
agentSource: agentSource.value, // <- TODO: [🐱🚀] Allow to pass BehaviorSubject<string_book> OR refresh llmExecutionTools.callChat on agentSource change
|
|
19446
19461
|
});
|
|
19447
19462
|
_Agent_instances.add(this);
|
|
@@ -19481,10 +19496,6 @@ class Agent extends AgentLlmExecutionTools {
|
|
|
19481
19496
|
* Human-readable titles for tool functions
|
|
19482
19497
|
*/
|
|
19483
19498
|
this.toolTitles = {};
|
|
19484
|
-
/**
|
|
19485
|
-
* Externals prepared for the agent, like OpenAI assistant, etc.
|
|
19486
|
-
*/
|
|
19487
|
-
this.preparedExternals = {};
|
|
19488
19499
|
// TODO: [🐱🚀] Add `Agent` simple "mocked" learning by appending to agent source
|
|
19489
19500
|
// TODO: [🐱🚀] Add `Agent` learning by promptbookAgent
|
|
19490
19501
|
this.teacherAgent = options.teacherAgent;
|
|
@@ -19721,6 +19732,63 @@ async function _Agent_selfLearnTeacher(prompt, result) {
|
|
|
19721
19732
|
* TODO: [🧠][😰]Agent is not working with the parameters, should it be?
|
|
19722
19733
|
*/
|
|
19723
19734
|
|
|
19735
|
+
/**
|
|
19736
|
+
* Resolve a remote META IMAGE value into an absolute URL when possible.
|
|
19737
|
+
*/
|
|
19738
|
+
function resolveRemoteImageUrl(imageUrl, agentUrl) {
|
|
19739
|
+
if (!imageUrl) {
|
|
19740
|
+
return undefined;
|
|
19741
|
+
}
|
|
19742
|
+
if (imageUrl.startsWith('http://') ||
|
|
19743
|
+
imageUrl.startsWith('https://') ||
|
|
19744
|
+
imageUrl.startsWith('data:') ||
|
|
19745
|
+
imageUrl.startsWith('blob:')) {
|
|
19746
|
+
return imageUrl;
|
|
19747
|
+
}
|
|
19748
|
+
try {
|
|
19749
|
+
return new URL(imageUrl, agentUrl).href;
|
|
19750
|
+
}
|
|
19751
|
+
catch (_a) {
|
|
19752
|
+
return imageUrl;
|
|
19753
|
+
}
|
|
19754
|
+
}
|
|
19755
|
+
/**
|
|
19756
|
+
* Format a META commitment line when the value is provided.
|
|
19757
|
+
*/
|
|
19758
|
+
function formatMetaLine(label, value) {
|
|
19759
|
+
if (!value) {
|
|
19760
|
+
return null;
|
|
19761
|
+
}
|
|
19762
|
+
return `META ${label} ${value}`;
|
|
19763
|
+
}
|
|
19764
|
+
/**
|
|
19765
|
+
* Build a minimal agent source snapshot for remote agents.
|
|
19766
|
+
*/
|
|
19767
|
+
function buildRemoteAgentSource(profile, meta) {
|
|
19768
|
+
const metaLines = [
|
|
19769
|
+
formatMetaLine('FULLNAME', meta === null || meta === void 0 ? void 0 : meta.fullname),
|
|
19770
|
+
formatMetaLine('IMAGE', meta === null || meta === void 0 ? void 0 : meta.image),
|
|
19771
|
+
formatMetaLine('DESCRIPTION', meta === null || meta === void 0 ? void 0 : meta.description),
|
|
19772
|
+
formatMetaLine('COLOR', meta === null || meta === void 0 ? void 0 : meta.color),
|
|
19773
|
+
formatMetaLine('FONT', meta === null || meta === void 0 ? void 0 : meta.font),
|
|
19774
|
+
formatMetaLine('LINK', meta === null || meta === void 0 ? void 0 : meta.link),
|
|
19775
|
+
]
|
|
19776
|
+
.filter((line) => Boolean(line))
|
|
19777
|
+
.join('\n');
|
|
19778
|
+
const personaBlock = profile.personaDescription
|
|
19779
|
+
? spaceTrim$2((block) => `
|
|
19780
|
+
PERSONA
|
|
19781
|
+
${block(profile.personaDescription || '')}
|
|
19782
|
+
`)
|
|
19783
|
+
: '';
|
|
19784
|
+
return book `
|
|
19785
|
+
${profile.agentName}
|
|
19786
|
+
|
|
19787
|
+
${metaLines}
|
|
19788
|
+
|
|
19789
|
+
${personaBlock}
|
|
19790
|
+
`;
|
|
19791
|
+
}
|
|
19724
19792
|
/**
|
|
19725
19793
|
* Represents one AI Agent
|
|
19726
19794
|
*
|
|
@@ -19735,6 +19803,7 @@ async function _Agent_selfLearnTeacher(prompt, result) {
|
|
|
19735
19803
|
*/
|
|
19736
19804
|
class RemoteAgent extends Agent {
|
|
19737
19805
|
static async connect(options) {
|
|
19806
|
+
var _a, _b, _c;
|
|
19738
19807
|
const agentProfileUrl = `${options.agentUrl}/api/profile`;
|
|
19739
19808
|
const profileResponse = await fetch(agentProfileUrl);
|
|
19740
19809
|
// <- TODO: [🐱🚀] What about closed-source agents?
|
|
@@ -19754,14 +19823,14 @@ class RemoteAgent extends Agent {
|
|
|
19754
19823
|
|
|
19755
19824
|
`));
|
|
19756
19825
|
}
|
|
19757
|
-
const profile = await profileResponse.json();
|
|
19826
|
+
const profile = (await profileResponse.json());
|
|
19827
|
+
const resolvedMeta = {
|
|
19828
|
+
...(profile.meta || {}),
|
|
19829
|
+
image: resolveRemoteImageUrl((_a = profile.meta) === null || _a === void 0 ? void 0 : _a.image, options.agentUrl),
|
|
19830
|
+
};
|
|
19758
19831
|
// Note: We are creating dummy agent source because we don't have the source from the remote agent
|
|
19759
19832
|
// But we populate the metadata from the profile
|
|
19760
|
-
const agentSource = new BehaviorSubject(
|
|
19761
|
-
${profile.agentName}
|
|
19762
|
-
|
|
19763
|
-
${profile.personaDescription}
|
|
19764
|
-
`);
|
|
19833
|
+
const agentSource = new BehaviorSubject(buildRemoteAgentSource(profile, resolvedMeta));
|
|
19765
19834
|
// <- TODO: [🐱🚀] createBookFromProfile
|
|
19766
19835
|
// <- TODO: [🐱🚀] Support updating and self-updating
|
|
19767
19836
|
const remoteAgent = new RemoteAgent({
|
|
@@ -19784,10 +19853,10 @@ class RemoteAgent extends Agent {
|
|
|
19784
19853
|
});
|
|
19785
19854
|
remoteAgent._remoteAgentName = profile.agentName;
|
|
19786
19855
|
remoteAgent._remoteAgentHash = profile.agentHash;
|
|
19787
|
-
remoteAgent.personaDescription = profile.personaDescription;
|
|
19788
|
-
remoteAgent.initialMessage = profile.initialMessage;
|
|
19789
|
-
remoteAgent.links = profile.links;
|
|
19790
|
-
remoteAgent.meta =
|
|
19856
|
+
remoteAgent.personaDescription = (_b = profile.personaDescription) !== null && _b !== void 0 ? _b : null;
|
|
19857
|
+
remoteAgent.initialMessage = (_c = profile.initialMessage) !== null && _c !== void 0 ? _c : null;
|
|
19858
|
+
remoteAgent.links = profile.links || [];
|
|
19859
|
+
remoteAgent.meta = resolvedMeta;
|
|
19791
19860
|
remoteAgent.capabilities = profile.capabilities || [];
|
|
19792
19861
|
remoteAgent.samples = profile.samples || [];
|
|
19793
19862
|
remoteAgent.toolTitles = profile.toolTitles || {};
|