@promptbook/wizard 0.112.0-64 → 0.112.0-65
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 +87 -235
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/components.index.d.ts +0 -2
- package/esm/src/_packages/core.index.d.ts +2 -2
- package/esm/src/_packages/types.index.d.ts +0 -2
- package/esm/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/esm/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/esm/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/esm/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/esm/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/esm/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/esm/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/esm/src/formfactors/index.d.ts +2 -2
- package/esm/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/esm/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/esm/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/esm/src/version.d.ts +1 -1
- package/package.json +2 -3
- package/umd/index.umd.js +87 -235
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/components.index.d.ts +0 -2
- package/umd/src/_packages/core.index.d.ts +2 -2
- package/umd/src/_packages/types.index.d.ts +0 -2
- package/umd/src/book-2.0/book-language-documentation/BookLanguageDocumentationExample.d.ts +27 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageCommonPitfalls.d.ts +25 -0
- package/umd/src/book-2.0/book-language-documentation/bookLanguageDocumentationExamples.d.ts +10 -0
- package/umd/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.d.ts +14 -0
- package/umd/src/book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.d.ts +43 -0
- package/umd/src/book-components/Chat/types/ChatMessage.d.ts +0 -34
- package/umd/src/commitments/KNOWLEDGE/KNOWLEDGE.d.ts +0 -11
- package/umd/src/commitments/_common/toolRuntimeContext.d.ts +0 -6
- package/umd/src/formfactors/index.d.ts +2 -2
- package/umd/src/formfactors/matcher/MatcherFormfactorDefinition.d.ts +1 -1
- package/umd/src/formfactors/translator/TranslatorFormfactorDefinition.d.ts +1 -1
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionTools.d.ts +0 -4
- package/umd/src/llm-providers/openai/OpenAiAgentKitExecutionToolsOptions.d.ts +0 -9
- package/umd/src/version.d.ts +1 -1
- /package/esm/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
- /package/umd/src/{commitments/KNOWLEDGE/KNOWLEDGE.test.d.ts → book-2.0/book-language-documentation/renderGroupedCommitmentDocumentationMarkdown.test.d.ts} +0 -0
package/umd/index.umd.js
CHANGED
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
* @generated
|
|
50
50
|
* @see https://github.com/webgptorg/promptbook
|
|
51
51
|
*/
|
|
52
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
52
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-65';
|
|
53
53
|
/**
|
|
54
54
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
55
55
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9226,9 +9226,11 @@
|
|
|
9226
9226
|
* Creates the retry-history error message shared by all OpenAI-compatible model variants.
|
|
9227
9227
|
*/
|
|
9228
9228
|
createAttemptHistoryError(finalErrorMessage) {
|
|
9229
|
-
return new PipelineExecutionError(
|
|
9230
|
-
|
|
9231
|
-
|
|
9229
|
+
return new PipelineExecutionError(_spaceTrim.spaceTrim((block) => `
|
|
9230
|
+
All attempts failed. Attempt history:
|
|
9231
|
+
${block(formatUnsupportedParameterAttemptHistory(this.attemptStack))}
|
|
9232
|
+
Final error: ${finalErrorMessage}
|
|
9233
|
+
`));
|
|
9232
9234
|
}
|
|
9233
9235
|
}
|
|
9234
9236
|
|
|
@@ -20745,18 +20747,6 @@
|
|
|
20745
20747
|
return count;
|
|
20746
20748
|
}
|
|
20747
20749
|
|
|
20748
|
-
/**
|
|
20749
|
-
* Name of the tool used by agents to search configured `KNOWLEDGE` sources.
|
|
20750
|
-
*
|
|
20751
|
-
* @public exported from `@promptbook/core`
|
|
20752
|
-
*/
|
|
20753
|
-
const KNOWLEDGE_SEARCH_TOOL_NAME = 'knowledge_search';
|
|
20754
|
-
/**
|
|
20755
|
-
* Title of the system-message section generated for `KNOWLEDGE` commitments.
|
|
20756
|
-
*
|
|
20757
|
-
* @private constant of `KnowledgeCommitmentDefinition`
|
|
20758
|
-
*/
|
|
20759
|
-
const KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE = 'Knowledge Search';
|
|
20760
20750
|
/**
|
|
20761
20751
|
* KNOWLEDGE commitment definition
|
|
20762
20752
|
*
|
|
@@ -20878,17 +20868,9 @@
|
|
|
20878
20868
|
knowledgeInfoEntries.push(`Knowledge Source Inline: ${inlineSource.filename} (derived from inline content and processed for retrieval during chat)`);
|
|
20879
20869
|
}
|
|
20880
20870
|
if (knowledgeInfoEntries.length === 0) {
|
|
20881
|
-
return
|
|
20871
|
+
return nextRequirements;
|
|
20882
20872
|
}
|
|
20883
|
-
return
|
|
20884
|
-
}
|
|
20885
|
-
/**
|
|
20886
|
-
* Gets human-readable titles for tool functions provided by this commitment.
|
|
20887
|
-
*/
|
|
20888
|
-
getToolTitles() {
|
|
20889
|
-
return {
|
|
20890
|
-
[KNOWLEDGE_SEARCH_TOOL_NAME]: 'Knowledge search',
|
|
20891
|
-
};
|
|
20873
|
+
return this.appendToSystemMessage(nextRequirements, knowledgeInfoEntries.join('\n'), '\n\n');
|
|
20892
20874
|
}
|
|
20893
20875
|
}
|
|
20894
20876
|
/**
|
|
@@ -20902,128 +20884,6 @@
|
|
|
20902
20884
|
const significantText = contentWithoutUrls.replace(/[\s.,!?;:'"`()[\]{}<>/-]+/g, '');
|
|
20903
20885
|
return significantText.length > 0;
|
|
20904
20886
|
}
|
|
20905
|
-
/**
|
|
20906
|
-
* Adds the shared `knowledge_search` tool definition and the consolidated system-message section.
|
|
20907
|
-
*
|
|
20908
|
-
* @param requirements - Requirements after one `KNOWLEDGE` commitment was applied.
|
|
20909
|
-
* @returns Requirements with the knowledge search instructions and tool definition.
|
|
20910
|
-
*
|
|
20911
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20912
|
-
*/
|
|
20913
|
-
function addKnowledgeSearchToolAndSystemSection(requirements) {
|
|
20914
|
-
const nextRequirements = addKnowledgeSearchTool(requirements);
|
|
20915
|
-
const section = createKnowledgeSearchSystemSection(nextRequirements);
|
|
20916
|
-
const sectionHeader = `## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}`;
|
|
20917
|
-
if (nextRequirements.systemMessage.includes(sectionHeader)) {
|
|
20918
|
-
return {
|
|
20919
|
-
...nextRequirements,
|
|
20920
|
-
systemMessage: nextRequirements.systemMessage.replace(new RegExp(`## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}[\\s\\S]*?(?=\\n\\n##|$)`), section),
|
|
20921
|
-
};
|
|
20922
|
-
}
|
|
20923
|
-
return {
|
|
20924
|
-
...nextRequirements,
|
|
20925
|
-
systemMessage: nextRequirements.systemMessage.trim()
|
|
20926
|
-
? `${nextRequirements.systemMessage}\n\n${section}`
|
|
20927
|
-
: section,
|
|
20928
|
-
};
|
|
20929
|
-
}
|
|
20930
|
-
/**
|
|
20931
|
-
* Adds the `knowledge_search` model tool when it is not already present.
|
|
20932
|
-
*
|
|
20933
|
-
* @param requirements - Current model requirements.
|
|
20934
|
-
* @returns Requirements with the tool definition available to the model.
|
|
20935
|
-
*
|
|
20936
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20937
|
-
*/
|
|
20938
|
-
function addKnowledgeSearchTool(requirements) {
|
|
20939
|
-
const existingTools = requirements.tools || [];
|
|
20940
|
-
if (existingTools.some((tool) => tool.name === KNOWLEDGE_SEARCH_TOOL_NAME)) {
|
|
20941
|
-
return requirements;
|
|
20942
|
-
}
|
|
20943
|
-
return {
|
|
20944
|
-
...requirements,
|
|
20945
|
-
tools: [
|
|
20946
|
-
...existingTools,
|
|
20947
|
-
{
|
|
20948
|
-
name: KNOWLEDGE_SEARCH_TOOL_NAME,
|
|
20949
|
-
description: _spaceTrim.spaceTrim(`
|
|
20950
|
-
Search the agent's configured knowledge sources and return relevant excerpts with citation ids.
|
|
20951
|
-
Use this before answering questions that may depend on the agent's KNOWLEDGE commitments.
|
|
20952
|
-
`),
|
|
20953
|
-
parameters: {
|
|
20954
|
-
type: 'object',
|
|
20955
|
-
properties: {
|
|
20956
|
-
query: {
|
|
20957
|
-
type: 'string',
|
|
20958
|
-
description: 'The natural-language search query for the knowledge base.',
|
|
20959
|
-
},
|
|
20960
|
-
limit: {
|
|
20961
|
-
type: 'integer',
|
|
20962
|
-
description: 'Maximum number of matching source excerpts to return.',
|
|
20963
|
-
},
|
|
20964
|
-
},
|
|
20965
|
-
required: ['query'],
|
|
20966
|
-
},
|
|
20967
|
-
},
|
|
20968
|
-
],
|
|
20969
|
-
};
|
|
20970
|
-
}
|
|
20971
|
-
/**
|
|
20972
|
-
* Creates the model-facing system-message section for knowledge search.
|
|
20973
|
-
*
|
|
20974
|
-
* @param requirements - Current model requirements.
|
|
20975
|
-
* @returns Markdown system-message section.
|
|
20976
|
-
*
|
|
20977
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
20978
|
-
*/
|
|
20979
|
-
function createKnowledgeSearchSystemSection(requirements) {
|
|
20980
|
-
const sourceEntries = createKnowledgeSourceSystemEntries(requirements);
|
|
20981
|
-
const sourceList = sourceEntries.length > 0 ? sourceEntries.map((entry) => `- ${entry}`).join('\n') : '- None';
|
|
20982
|
-
return _spaceTrim.spaceTrim(`
|
|
20983
|
-
## ${KNOWLEDGE_SEARCH_SYSTEM_SECTION_TITLE}
|
|
20984
|
-
|
|
20985
|
-
- Use \`${KNOWLEDGE_SEARCH_TOOL_NAME}\` to search the configured knowledge sources before answering questions that depend on this agent's knowledge base.
|
|
20986
|
-
- Base source-backed factual answers on the returned excerpts.
|
|
20987
|
-
- When you use a returned excerpt, include its citation marker in the answer body, for example \`[0:0]\`.
|
|
20988
|
-
- If the search returns no relevant information, say that the knowledge base did not contain the answer instead of inventing it.
|
|
20989
|
-
|
|
20990
|
-
Configured knowledge sources:
|
|
20991
|
-
${sourceList}
|
|
20992
|
-
`);
|
|
20993
|
-
}
|
|
20994
|
-
/**
|
|
20995
|
-
* Builds a stable list of configured knowledge sources for system-message diagnostics.
|
|
20996
|
-
*
|
|
20997
|
-
* @param requirements - Current model requirements.
|
|
20998
|
-
* @returns Human-readable source entries.
|
|
20999
|
-
*
|
|
21000
|
-
* @private internal utility of `KnowledgeCommitmentDefinition`
|
|
21001
|
-
*/
|
|
21002
|
-
function createKnowledgeSourceSystemEntries(requirements) {
|
|
21003
|
-
var _a;
|
|
21004
|
-
const entries = [];
|
|
21005
|
-
const seenEntries = new Set();
|
|
21006
|
-
for (const source of requirements.knowledgeSources || []) {
|
|
21007
|
-
const entry = `Source URL: ${source} (processed for retrieval during chat)`;
|
|
21008
|
-
if (seenEntries.has(entry)) {
|
|
21009
|
-
continue;
|
|
21010
|
-
}
|
|
21011
|
-
seenEntries.add(entry);
|
|
21012
|
-
entries.push(entry);
|
|
21013
|
-
}
|
|
21014
|
-
const inlineSources = (((_a = requirements._metadata) === null || _a === void 0 ? void 0 : _a.inlineKnowledgeSources) || [])
|
|
21015
|
-
.map((source) => source.filename)
|
|
21016
|
-
.filter(Boolean);
|
|
21017
|
-
for (const filename of inlineSources) {
|
|
21018
|
-
const entry = `Knowledge Source Inline: ${filename} (Inline source: processed for retrieval during chat)`;
|
|
21019
|
-
if (seenEntries.has(entry)) {
|
|
21020
|
-
continue;
|
|
21021
|
-
}
|
|
21022
|
-
seenEntries.add(entry);
|
|
21023
|
-
entries.push(entry);
|
|
21024
|
-
}
|
|
21025
|
-
return entries;
|
|
21026
|
-
}
|
|
21027
20887
|
|
|
21028
20888
|
/**
|
|
21029
20889
|
* LANGUAGE commitment definition
|
|
@@ -26645,7 +26505,11 @@
|
|
|
26645
26505
|
// Create new system message with persona at the beginning
|
|
26646
26506
|
// Format: "You are {agentName}\n{personaContent}"
|
|
26647
26507
|
// The # PERSONA comment will be removed later by removeCommentsFromSystemMessage
|
|
26648
|
-
const personaSection =
|
|
26508
|
+
const personaSection = _spaceTrim.spaceTrim((block) => `
|
|
26509
|
+
# PERSONA
|
|
26510
|
+
You are ${agentName}
|
|
26511
|
+
${block(mergedPersonaContent)}
|
|
26512
|
+
`);
|
|
26649
26513
|
const newSystemMessage = cleanedMessage ? `${personaSection}\n\n${cleanedMessage}` : personaSection;
|
|
26650
26514
|
return {
|
|
26651
26515
|
...requirements,
|
|
@@ -36246,7 +36110,7 @@
|
|
|
36246
36110
|
*/
|
|
36247
36111
|
async function prepareSdkTranspilerContext(book, options) {
|
|
36248
36112
|
const { agentName } = await parseAgentSource(book);
|
|
36249
|
-
const
|
|
36113
|
+
const modelRequirements = await createAgentModelRequirements(book, undefined, undefined, undefined, {
|
|
36250
36114
|
agentReferenceResolver: options === null || options === void 0 ? void 0 : options.agentReferenceResolver,
|
|
36251
36115
|
inlineKnowledgeSourceUploader: options === null || options === void 0 ? void 0 : options.inlineKnowledgeSourceUploader,
|
|
36252
36116
|
teammateProfileResolver: options === null || options === void 0 ? void 0 : options.teammateProfileResolver,
|
|
@@ -36256,12 +36120,7 @@
|
|
|
36256
36120
|
const knowledgeContent = knowledgeCommitments.map((commitment) => commitment.content.trim());
|
|
36257
36121
|
const directKnowledge = knowledgeContent.filter((content) => !isKnowledgeSourceUrl(content));
|
|
36258
36122
|
const knowledgeSources = knowledgeContent.filter((content) => isKnowledgeSourceUrl(content));
|
|
36259
|
-
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD ||
|
|
36260
|
-
knowledgeSources.length > 0 ||
|
|
36261
|
-
knowledgeCommitments.length > 0;
|
|
36262
|
-
const modelRequirements = normalizeSdkTranspilerModelRequirements(rawModelRequirements, {
|
|
36263
|
-
isKnowledgeHandledWithRetrieval,
|
|
36264
|
-
});
|
|
36123
|
+
const isKnowledgeHandledWithRetrieval = directKnowledge.join('\n').length > SDK_TRANSPILER_KNOWLEDGE_THRESHOLD || knowledgeSources.length > 0;
|
|
36265
36124
|
const transpiledTeam = createTranspiledTeamExportForContext({
|
|
36266
36125
|
agentName,
|
|
36267
36126
|
agentSource: book,
|
|
@@ -36279,36 +36138,6 @@
|
|
|
36279
36138
|
transpiledTeam,
|
|
36280
36139
|
};
|
|
36281
36140
|
}
|
|
36282
|
-
/**
|
|
36283
|
-
* Removes the runtime-only knowledge-search tool from SDK harnesses that provide
|
|
36284
|
-
* their own generated retrieval scaffold.
|
|
36285
|
-
*
|
|
36286
|
-
* @param modelRequirements - Raw compiled model requirements.
|
|
36287
|
-
* @param options - Knowledge handling mode selected for the generated harness.
|
|
36288
|
-
* @returns Model requirements safe to embed into a standalone SDK export.
|
|
36289
|
-
*/
|
|
36290
|
-
function normalizeSdkTranspilerModelRequirements(modelRequirements, options) {
|
|
36291
|
-
var _a;
|
|
36292
|
-
if (!options.isKnowledgeHandledWithRetrieval) {
|
|
36293
|
-
return modelRequirements;
|
|
36294
|
-
}
|
|
36295
|
-
const tools = (_a = modelRequirements.tools) === null || _a === void 0 ? void 0 : _a.filter((tool) => tool.name !== KNOWLEDGE_SEARCH_TOOL_NAME);
|
|
36296
|
-
return {
|
|
36297
|
-
...modelRequirements,
|
|
36298
|
-
systemMessage: removeKnowledgeSearchSystemSection(modelRequirements.systemMessage),
|
|
36299
|
-
...(tools ? { tools } : {}),
|
|
36300
|
-
};
|
|
36301
|
-
}
|
|
36302
|
-
/**
|
|
36303
|
-
* Removes the generated `## Knowledge Search` instructions from SDK exports
|
|
36304
|
-
* that answer with the transpiler's native retrieval scaffold instead.
|
|
36305
|
-
*
|
|
36306
|
-
* @param systemMessage - Raw system message from compiled model requirements.
|
|
36307
|
-
* @returns System message without the runtime-only knowledge-search section.
|
|
36308
|
-
*/
|
|
36309
|
-
function removeKnowledgeSearchSystemSection(systemMessage) {
|
|
36310
|
-
return systemMessage.replace(/(?:^|\n\n)## Knowledge Search[\s\S]*?(?=\n\n##|$)/, '').trim();
|
|
36311
|
-
}
|
|
36312
36141
|
/**
|
|
36313
36142
|
* Detects whether one knowledge commitment points to a URL instead of inline text.
|
|
36314
36143
|
*
|
|
@@ -41581,8 +41410,10 @@
|
|
|
41581
41410
|
*/
|
|
41582
41411
|
const MatcherFormfactorDefinition = {
|
|
41583
41412
|
name: 'EXPERIMENTAL_MATCHER',
|
|
41584
|
-
description: `
|
|
41585
|
-
|
|
41413
|
+
description: _spaceTrim.spaceTrim(`
|
|
41414
|
+
An evaluation system that determines whether content meets specific criteria or patterns.
|
|
41415
|
+
Used for content validation, quality assessment, and intelligent filtering tasks. Currently in experimental phase.
|
|
41416
|
+
`),
|
|
41586
41417
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/177`,
|
|
41587
41418
|
pipelineInterface: {
|
|
41588
41419
|
inputParameters: [
|
|
@@ -41639,9 +41470,11 @@
|
|
|
41639
41470
|
*/
|
|
41640
41471
|
const TranslatorFormfactorDefinition = {
|
|
41641
41472
|
name: 'TRANSLATOR',
|
|
41642
|
-
description: `
|
|
41643
|
-
|
|
41644
|
-
|
|
41473
|
+
description: _spaceTrim.spaceTrim(`
|
|
41474
|
+
A text transformation system that converts input content into different forms,
|
|
41475
|
+
including language translations, paraphrasing, style conversions, and tone adjustments.
|
|
41476
|
+
This form factor takes one input and produces one transformed output.
|
|
41477
|
+
`),
|
|
41645
41478
|
documentationUrl: `https://github.com/webgptorg/promptbook/discussions/175`,
|
|
41646
41479
|
pipelineInterface: {
|
|
41647
41480
|
inputParameters: [
|
|
@@ -43001,12 +42834,21 @@
|
|
|
43001
42834
|
// <- TODO: [🧠] Make this dynamic, async, prepare-phase HLAs
|
|
43002
42835
|
],
|
|
43003
42836
|
});
|
|
43004
|
-
// TODO: Use spaceTrim in multiline strings
|
|
43005
42837
|
$pipelineJson.tasks.push({
|
|
43006
42838
|
taskType: 'PROMPT_TASK',
|
|
43007
42839
|
name: 'create-an-answer',
|
|
43008
42840
|
title: 'Create an answer',
|
|
43009
|
-
content:
|
|
42841
|
+
content: _spaceTrim.spaceTrim(`
|
|
42842
|
+
Write a response to the user message:
|
|
42843
|
+
|
|
42844
|
+
**Question from user**
|
|
42845
|
+
|
|
42846
|
+
> {userMessage}
|
|
42847
|
+
|
|
42848
|
+
**Previous conversation**
|
|
42849
|
+
|
|
42850
|
+
> {previousConversationSummary}
|
|
42851
|
+
`),
|
|
43010
42852
|
resultingParameterName: 'chatbotResponse',
|
|
43011
42853
|
personaName,
|
|
43012
42854
|
dependentParameterNames: [
|
|
@@ -43018,7 +42860,26 @@
|
|
|
43018
42860
|
taskType: 'PROMPT_TASK',
|
|
43019
42861
|
name: 'summarize-the-conversation',
|
|
43020
42862
|
title: 'Summarize the conversation',
|
|
43021
|
-
content:
|
|
42863
|
+
content: _spaceTrim.spaceTrim(`
|
|
42864
|
+
Summarize the conversation in a few words:
|
|
42865
|
+
|
|
42866
|
+
## Rules
|
|
42867
|
+
|
|
42868
|
+
- Summarise the text of the conversation in a few words
|
|
42869
|
+
- Convert the text to its basic idea
|
|
42870
|
+
- Imagine you are writing the headline or subject line of an email
|
|
42871
|
+
- Respond with a few words of summary only
|
|
42872
|
+
|
|
42873
|
+
## Conversation
|
|
42874
|
+
|
|
42875
|
+
**User:**
|
|
42876
|
+
|
|
42877
|
+
> {userMessage}
|
|
42878
|
+
|
|
42879
|
+
**You:**
|
|
42880
|
+
|
|
42881
|
+
> {chatbotResponse}
|
|
42882
|
+
`),
|
|
43022
42883
|
resultingParameterName: 'conversationSummary',
|
|
43023
42884
|
personaName,
|
|
43024
42885
|
expectations: {
|
|
@@ -45401,11 +45262,11 @@
|
|
|
45401
45262
|
if (attachments.length === 0) {
|
|
45402
45263
|
return '';
|
|
45403
45264
|
}
|
|
45404
|
-
return
|
|
45405
|
-
CHAT_ATTACHMENTS_HEADING
|
|
45406
|
-
|
|
45407
|
-
CHAT_ATTACHMENTS_INSTRUCTION
|
|
45408
|
-
|
|
45265
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
45266
|
+
${CHAT_ATTACHMENTS_HEADING}
|
|
45267
|
+
${block(attachments.map((attachment) => formatChatAttachmentLine(attachment)).join('\n'))}
|
|
45268
|
+
${CHAT_ATTACHMENTS_INSTRUCTION}
|
|
45269
|
+
`);
|
|
45409
45270
|
}
|
|
45410
45271
|
|
|
45411
45272
|
/**
|
|
@@ -45646,24 +45507,24 @@
|
|
|
45646
45507
|
: ''}`
|
|
45647
45508
|
: null;
|
|
45648
45509
|
const warningsLine = contentResolution.warnings.length > 0 ? `Warnings: ${contentResolution.warnings.join(' | ')}` : null;
|
|
45649
|
-
|
|
45510
|
+
const metadataLines = [decodingLine, warningsLine].filter((line) => Boolean(line)).join('\n');
|
|
45511
|
+
const resolvedContent = contentResolution.content;
|
|
45512
|
+
if (!resolvedContent) {
|
|
45650
45513
|
const reason = contentResolution.reason || 'content unavailable';
|
|
45651
|
-
return
|
|
45652
|
-
.
|
|
45653
|
-
|
|
45514
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
45515
|
+
- ${attachmentLabel}: ${reason}. URL: ${contentResolution.attachment.url}
|
|
45516
|
+
${block(metadataLines)}
|
|
45517
|
+
`);
|
|
45654
45518
|
}
|
|
45655
45519
|
const truncatedLabel = contentResolution.isTruncated ? ' [truncated]' : '';
|
|
45656
|
-
return
|
|
45657
|
-
|
|
45658
|
-
|
|
45659
|
-
|
|
45660
|
-
|
|
45661
|
-
|
|
45662
|
-
|
|
45663
|
-
|
|
45664
|
-
]
|
|
45665
|
-
.filter(Boolean)
|
|
45666
|
-
.join('\n');
|
|
45520
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
45521
|
+
File: ${attachmentLabel}${truncatedLabel}
|
|
45522
|
+
URL: ${contentResolution.attachment.url}
|
|
45523
|
+
${block(metadataLines)}
|
|
45524
|
+
\`\`\`text
|
|
45525
|
+
${block(resolvedContent)}
|
|
45526
|
+
\`\`\`
|
|
45527
|
+
`);
|
|
45667
45528
|
}
|
|
45668
45529
|
/**
|
|
45669
45530
|
* Formats inline attachment-content context section for the model.
|
|
@@ -45677,11 +45538,14 @@
|
|
|
45677
45538
|
if (resolvedContents.length === 0) {
|
|
45678
45539
|
return '';
|
|
45679
45540
|
}
|
|
45680
|
-
return
|
|
45681
|
-
CHAT_ATTACHMENT_CONTENT_HEADING
|
|
45682
|
-
CHAT_ATTACHMENT_CONTENT_INSTRUCTION
|
|
45683
|
-
|
|
45684
|
-
|
|
45541
|
+
return _spaceTrim.spaceTrim((block) => `
|
|
45542
|
+
${CHAT_ATTACHMENT_CONTENT_HEADING}
|
|
45543
|
+
${CHAT_ATTACHMENT_CONTENT_INSTRUCTION}
|
|
45544
|
+
|
|
45545
|
+
${block(resolvedContents
|
|
45546
|
+
.map((resolvedContent) => formatResolvedChatAttachmentContent(resolvedContent))
|
|
45547
|
+
.join('\n\n'))}
|
|
45548
|
+
`);
|
|
45685
45549
|
}
|
|
45686
45550
|
|
|
45687
45551
|
/**
|
|
@@ -46299,7 +46163,7 @@
|
|
|
46299
46163
|
});
|
|
46300
46164
|
}
|
|
46301
46165
|
let vectorStoreId = cachedVectorStoreId;
|
|
46302
|
-
if (
|
|
46166
|
+
if (!vectorStoreId && knowledgeSources && knowledgeSources.length > 0) {
|
|
46303
46167
|
const vectorStoreResult = await this.createVectorStoreWithKnowledgeSources({
|
|
46304
46168
|
client: await this.getClient(),
|
|
46305
46169
|
name,
|
|
@@ -46308,19 +46172,13 @@
|
|
|
46308
46172
|
});
|
|
46309
46173
|
vectorStoreId = vectorStoreResult.vectorStoreId;
|
|
46310
46174
|
}
|
|
46311
|
-
else if (
|
|
46175
|
+
else if (vectorStoreId && this.options.isVerbose) {
|
|
46312
46176
|
console.info('[🤰]', 'Using cached vector store for AgentKit agent', {
|
|
46313
46177
|
name,
|
|
46314
46178
|
vectorStoreId,
|
|
46315
46179
|
});
|
|
46316
46180
|
}
|
|
46317
|
-
|
|
46318
|
-
vectorStoreId = undefined;
|
|
46319
|
-
}
|
|
46320
|
-
const agentKitTools = this.buildAgentKitTools({
|
|
46321
|
-
tools,
|
|
46322
|
-
vectorStoreId,
|
|
46323
|
-
});
|
|
46181
|
+
const agentKitTools = this.buildAgentKitTools({ tools, vectorStoreId });
|
|
46324
46182
|
const openAiAgentKitAgent = new agents.Agent({
|
|
46325
46183
|
name,
|
|
46326
46184
|
model: this.agentKitModelName,
|
|
@@ -46339,7 +46197,7 @@
|
|
|
46339
46197
|
name,
|
|
46340
46198
|
model: this.agentKitModelName,
|
|
46341
46199
|
toolCount: agentKitTools.length,
|
|
46342
|
-
hasVectorStore:
|
|
46200
|
+
hasVectorStore: Boolean(vectorStoreId),
|
|
46343
46201
|
});
|
|
46344
46202
|
}
|
|
46345
46203
|
return preparedAgent;
|
|
@@ -46838,12 +46696,6 @@
|
|
|
46838
46696
|
get agentKitOptions() {
|
|
46839
46697
|
return this.options;
|
|
46840
46698
|
}
|
|
46841
|
-
/**
|
|
46842
|
-
* Returns true when hosted OpenAI vector-store search should back `knowledgeSources`.
|
|
46843
|
-
*/
|
|
46844
|
-
get isNativeKnowledgeSearchEnabled() {
|
|
46845
|
-
return this.agentKitOptions.isNativeKnowledgeSearchEnabled !== false;
|
|
46846
|
-
}
|
|
46847
46699
|
/**
|
|
46848
46700
|
* Discriminant for type guards.
|
|
46849
46701
|
*/
|