@valerypopoff/rivet2-core 2.1.8 → 2.1.10
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/dist/cjs/bundle.cjs +4457 -1809
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +298 -21
- package/dist/cjs/webAppRuntime.cjs.map +4 -4
- package/dist/esm/exports.js +1 -0
- package/dist/esm/model/AgentResponseTrace.js +448 -0
- package/dist/esm/model/ConnectedToolContinuationHost.js +33 -0
- package/dist/esm/model/GraphProcessor.js +152 -74
- package/dist/esm/model/NodeImpl.js +6 -0
- package/dist/esm/model/ProcessContextBuilder.js +3 -1
- package/dist/esm/model/RecordingPlayer.js +164 -22
- package/dist/esm/model/SplitRunProcessor.js +68 -18
- package/dist/esm/model/SubprocessorBridge.js +2 -0
- package/dist/esm/model/ToolCallContinuationCoordinator.js +13 -4
- package/dist/esm/model/UiGraph.js +21 -0
- package/dist/esm/model/UiGraphActionProtocol.js +2 -0
- package/dist/esm/model/UiGraphBrowserRuntime.js +133 -4
- package/dist/esm/model/UiGraphRendererStyles.js +221 -0
- package/dist/esm/model/UiGraphRuntimeModel.js +9 -3
- package/dist/esm/model/UiGraphSchema.js +7 -1
- package/dist/esm/model/chat/aiSdkMessages.js +8 -0
- package/dist/esm/model/chat/aiSdkTools.js +3 -2
- package/dist/esm/model/chat-v2/chatV2CallObserver.js +11 -5
- package/dist/esm/model/chat-v2/chatV2EditorCache.js +58 -10
- package/dist/esm/model/chat-v2/chatV2Errors.js +7 -19
- package/dist/esm/model/chat-v2/chatV2FeatureCompatibility.js +1 -1
- package/dist/esm/model/chat-v2/chatV2Outputs.js +56 -106
- package/dist/esm/model/chat-v2/chatV2Pipeline.js +142 -149
- package/dist/esm/model/chat-v2/chatV2ProviderProfile.js +9 -2
- package/dist/esm/model/chat-v2/chatV2ProviderRegistry.js +9 -0
- package/dist/esm/model/chat-v2/chatV2RequestPlan.js +5 -5
- package/dist/esm/model/chat-v2/chatV2ResponseBodyCapture.js +55 -0
- package/dist/esm/model/chat-v2/chatV2ResponseFormat.js +8 -4
- package/dist/esm/model/chat-v2/chatV2Retry.js +4 -3
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +6 -1
- package/dist/esm/model/chat-v2/chatV2Shared.js +1 -6
- package/dist/esm/model/chat-v2/chatV2Types.js +7 -1
- package/dist/esm/model/chat-v2/chatV2UsageAccounting.js +78 -0
- package/dist/esm/model/chat-v2/customProviderApi.js +42 -0
- package/dist/esm/model/chat-v2/developerMessageRoles.js +45 -0
- package/dist/esm/model/chat-v2/index.js +12 -0
- package/dist/esm/model/chat-v2/llmChatV2Body.js +281 -0
- package/dist/esm/model/chat-v2/llmChatV2CacheBoundary.js +32 -0
- package/dist/esm/model/chat-v2/llmChatV2CachePolicy.js +20 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeData.js +8 -54
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +41 -20
- package/dist/esm/model/chat-v2/llmChatV2NodeMigration.js +24 -0
- package/dist/esm/model/chat-v2/llmChatV2NodeRuntime.js +178 -94
- package/dist/esm/model/chat-v2/llmInvocationCoordinator.js +60 -0
- package/dist/esm/model/chat-v2/llmInvocationDecision.js +11 -0
- package/dist/esm/model/chat-v2/llmInvocationJournal.js +43 -0
- package/dist/esm/model/chat-v2/llmInvocationPlan.js +68 -0
- package/dist/esm/model/chat-v2/llmInvocationProjections.js +5 -0
- package/dist/esm/model/chat-v2/llmInvocationResultProjector.js +48 -0
- package/dist/esm/model/chat-v2/llmModelCandidate.js +75 -0
- package/dist/esm/model/chat-v2/llmProfile.js +31 -65
- package/dist/esm/model/chat-v2/llmProfileBody.js +183 -0
- package/dist/esm/model/chat-v2/llmProfileFallback.js +244 -0
- package/dist/esm/model/chat-v2/llmProfileFieldRegistry.js +67 -0
- package/dist/esm/model/chat-v2/llmProfileNodeRuntime.js +3 -0
- package/dist/esm/model/chat-v2/llmProfileTypes.js +1 -18
- package/dist/esm/model/chat-v2/llmResponseMaterializer.js +42 -0
- package/dist/esm/model/chat-v2/messageConverter.js +14 -0
- package/dist/esm/model/chat-v2/modelRegistry.js +54 -4
- package/dist/esm/model/chat-v2/parallelToolCalls.js +9 -2
- package/dist/esm/model/chat-v2/providerOptions.js +120 -21
- package/dist/esm/model/chat-v2/rivetToolRegistry.js +9 -0
- package/dist/esm/model/chat-v2/toolCallCodec.js +52 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +72 -39
- package/dist/esm/model/chat-v2/toolHandlerResolver.js +23 -0
- package/dist/esm/model/chat-v2/toolRoundExecutor.js +12 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +6 -0
- package/dist/esm/model/nodes/ChatNode.js +6 -0
- package/dist/esm/model/nodes/ChatNodeBase.js +1 -0
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +26 -1
- package/dist/esm/model/nodes/LLMChatV2Node.js +131 -144
- package/dist/esm/model/nodes/LLMProfileNode.js +27 -8
- package/dist/esm/model/nodes/PromptNode.js +16 -2
- package/dist/esm/model/nodes/ToolNode.js +7 -0
- package/dist/esm/model/nodes/toolCallDelegation.js +193 -110
- package/dist/esm/plugins/anthropic/anthropic.js +4 -4
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +29 -28
- package/dist/esm/plugins/google/google.js +25 -18
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +21 -7
- package/dist/esm/recording/ExecutionRecorder.js +13 -5
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +4 -0
- package/dist/esm/utils/emitDetached.js +6 -3
- package/dist/esm/utils/openai.js +60 -16
- package/dist/esm/utils/serialization/serialization.js +2 -0
- package/dist/esm/webAppRuntime.js +3 -2
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/model/AgentResponseTrace.d.ts +110 -0
- package/dist/types/model/ConnectedToolContinuationHost.d.ts +34 -0
- package/dist/types/model/DataValue.d.ts +7 -1
- package/dist/types/model/ExecutorProtocol.d.ts +25 -7
- package/dist/types/model/GraphProcessor.d.ts +27 -5
- package/dist/types/model/NodeBase.d.ts +6 -0
- package/dist/types/model/NodeImpl.d.ts +18 -1
- package/dist/types/model/Nodes.d.ts +2 -2
- package/dist/types/model/ProcessContext.d.ts +51 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +3 -1
- package/dist/types/model/RecordingPlayer.d.ts +6 -0
- package/dist/types/model/SplitRunProcessor.d.ts +11 -3
- package/dist/types/model/UiGraph.d.ts +8 -0
- package/dist/types/model/UiGraphActionProtocol.d.ts +2 -0
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +11 -2
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/UiGraphRuntimeModel.d.ts +2 -0
- package/dist/types/model/UiGraphSchema.d.ts +1 -0
- package/dist/types/model/chat-v2/chatV2CallObserver.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2EditorCache.d.ts +3 -1
- package/dist/types/model/chat-v2/chatV2Outputs.d.ts +7 -17
- package/dist/types/model/chat-v2/chatV2Pipeline.d.ts +29 -0
- package/dist/types/model/chat-v2/chatV2ProviderProfile.d.ts +5 -0
- package/dist/types/model/chat-v2/chatV2ProviderRegistry.d.ts +8 -0
- package/dist/types/model/chat-v2/chatV2RequestPlan.d.ts +2 -2
- package/dist/types/model/chat-v2/chatV2ResponseBodyCapture.d.ts +19 -0
- package/dist/types/model/chat-v2/chatV2ResponseFormat.d.ts +3 -2
- package/dist/types/model/chat-v2/chatV2Retry.d.ts +2 -0
- package/dist/types/model/chat-v2/chatV2Shared.d.ts +0 -1
- package/dist/types/model/chat-v2/chatV2Types.d.ts +35 -1
- package/dist/types/model/chat-v2/chatV2UsageAccounting.d.ts +14 -0
- package/dist/types/model/chat-v2/customProviderApi.d.ts +23 -0
- package/dist/types/model/chat-v2/developerMessageRoles.d.ts +10 -0
- package/dist/types/model/chat-v2/index.d.ts +12 -0
- package/dist/types/model/chat-v2/llmChatV2Body.d.ts +24 -0
- package/dist/types/model/chat-v2/llmChatV2CacheBoundary.d.ts +10 -0
- package/dist/types/model/chat-v2/llmChatV2CachePolicy.d.ts +13 -0
- package/dist/types/model/chat-v2/llmChatV2NodeData.d.ts +13 -3
- package/dist/types/model/chat-v2/llmChatV2NodeMigration.d.ts +8 -0
- package/dist/types/model/chat-v2/llmChatV2NodeRuntime.d.ts +18 -4
- package/dist/types/model/chat-v2/llmInvocationCoordinator.d.ts +16 -0
- package/dist/types/model/chat-v2/llmInvocationDecision.d.ts +21 -0
- package/dist/types/model/chat-v2/llmInvocationJournal.d.ts +38 -0
- package/dist/types/model/chat-v2/llmInvocationPlan.d.ts +41 -0
- package/dist/types/model/chat-v2/llmInvocationProjections.d.ts +3 -0
- package/dist/types/model/chat-v2/llmInvocationResultProjector.d.ts +26 -0
- package/dist/types/model/chat-v2/llmModelCandidate.d.ts +18 -0
- package/dist/types/model/chat-v2/llmProfile.d.ts +7 -0
- package/dist/types/model/chat-v2/llmProfileBody.d.ts +20 -0
- package/dist/types/model/chat-v2/llmProfileFallback.d.ts +47 -0
- package/dist/types/model/chat-v2/llmProfileFieldRegistry.d.ts +189 -0
- package/dist/types/model/chat-v2/llmProfileTypes.d.ts +1 -1
- package/dist/types/model/chat-v2/llmResponseMaterializer.d.ts +20 -0
- package/dist/types/model/chat-v2/modelRegistry.d.ts +17 -187
- package/dist/types/model/chat-v2/parallelToolCalls.d.ts +3 -1
- package/dist/types/model/chat-v2/providerOptions.d.ts +11 -0
- package/dist/types/model/chat-v2/rivetToolRegistry.d.ts +11 -0
- package/dist/types/model/chat-v2/toolCallCodec.d.ts +7 -0
- package/dist/types/model/chat-v2/toolContinuation.d.ts +3 -3
- package/dist/types/model/chat-v2/toolHandlerResolver.d.ts +25 -0
- package/dist/types/model/chat-v2/toolRoundExecutor.d.ts +18 -0
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +2 -1
- package/dist/types/model/nodes/ChatNode.d.ts +2 -1
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +2 -1
- package/dist/types/model/nodes/LLMChatV2Node.d.ts +2 -1
- package/dist/types/model/nodes/LLMProfileNode.d.ts +2 -1
- package/dist/types/model/nodes/PromptNode.d.ts +6 -3
- package/dist/types/model/nodes/ToolNode.d.ts +2 -1
- package/dist/types/model/nodes/toolCallDelegation.d.ts +10 -3
- package/dist/types/plugins/anthropic/anthropic.d.ts +1 -0
- package/dist/types/plugins/google/google.d.ts +14 -9
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +2 -1
- package/dist/types/recording/RecordedEvents.d.ts +6 -0
- package/dist/types/utils/emitDetached.d.ts +3 -2
- package/dist/types/utils/openai.d.ts +49 -0
- package/dist/types/webAppRuntime.d.ts +4 -2
- package/package.json +2 -2
|
@@ -5,45 +5,19 @@ import { NodeImpl } from '../NodeImpl.js';
|
|
|
5
5
|
import { getCommonChatV2Inputs, getCommonChatV2Outputs } from '../chat-v2/chatV2Shared.js';
|
|
6
6
|
import { getLLMChatV2Editors } from '../chat-v2/llmChatV2NodeEditors.js';
|
|
7
7
|
import { createLLMChatV2NodeData, shouldIncludeLLMChatV2ToolCalls, } from '../chat-v2/llmChatV2NodeData.js';
|
|
8
|
+
import { getLLMChatV2BodySections } from '../chat-v2/llmChatV2Body.js';
|
|
8
9
|
import { isLLMChatV2StructuredResponseFormat } from '../chat-v2/chatV2FeatureCompatibility.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { LLMInvocationJournal } from '../chat-v2/llmInvocationJournal.js';
|
|
11
|
+
import { executeLLMInvocation } from '../chat-v2/llmInvocationCoordinator.js';
|
|
12
|
+
import { projectLLMInvocationDiagnostics, projectLLMInvocationResult, } from '../chat-v2/llmInvocationResultProjector.js';
|
|
13
|
+
import { isChatV2PipelineProviderFailureResult } from '../chat-v2/chatV2Pipeline.js';
|
|
14
|
+
import { shouldOutputChatV2RequestBody, shouldOutputChatV2ResponseBody } from '../chat-v2/chatV2Types.js';
|
|
15
|
+
import { buildLLMChatV2EditorCacheKey, resolveLLMChatV2RuntimeConfig, resolveLLMChatV2RuntimeProviderOptions, } from '../chat-v2/llmChatV2NodeRuntime.js';
|
|
16
|
+
import { projectLLMChatV2EditorCacheHit, writeLLMChatV2EditorCache } from '../chat-v2/llmChatV2CacheBoundary.js';
|
|
15
17
|
export { buildLLMChatV2EditorCacheKey, resolveLLMChatV2RuntimeProviderOptions };
|
|
16
18
|
function usesBaseURLInput(data) {
|
|
17
19
|
return data.provider === 'custom' && data.useCustomProviderBaseURLInput;
|
|
18
20
|
}
|
|
19
|
-
function getCustomProviderBaseURLBodyValue(data) {
|
|
20
|
-
if (data.provider !== 'custom') {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
if (data.useCustomProviderBaseURLInput) {
|
|
24
|
-
return '(Using Input)';
|
|
25
|
-
}
|
|
26
|
-
const baseURL = data.customProviderBaseURL.trim();
|
|
27
|
-
return baseURL || undefined;
|
|
28
|
-
}
|
|
29
|
-
function getOptionLabel(options, value) {
|
|
30
|
-
return options.find((option) => option.value === (value ?? ''))?.label ?? value ?? 'Default';
|
|
31
|
-
}
|
|
32
|
-
function getProviderBodyLabel(data) {
|
|
33
|
-
return data.provider === 'custom' ? 'Custom' : getChatV2ProviderLabel(data.provider);
|
|
34
|
-
}
|
|
35
|
-
function getReasoningEffortBodyValue(data) {
|
|
36
|
-
switch (data.provider) {
|
|
37
|
-
case 'openai':
|
|
38
|
-
return getOptionLabel(openAIReasoningEffortOptions, data.openAIReasoningEffort);
|
|
39
|
-
case 'anthropic':
|
|
40
|
-
return getOptionLabel(anthropicEffortOptions, data.anthropicEffort);
|
|
41
|
-
case 'google':
|
|
42
|
-
return getOptionLabel(googleThinkingLevelOptions, data.googleThinkingLevel);
|
|
43
|
-
case 'custom':
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
21
|
function escapeMarkdownInline(value) {
|
|
48
22
|
return value
|
|
49
23
|
.replace(/\r/g, '\\r')
|
|
@@ -57,20 +31,19 @@ function escapeMarkdownInline(value) {
|
|
|
57
31
|
function getBodyLine(label, value) {
|
|
58
32
|
return `<span style="opacity: 0.55">${label}:</span> ${escapeMarkdownInline(value)}`;
|
|
59
33
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
return getBodyLine(label, '(Using Input)');
|
|
63
|
-
}
|
|
64
|
-
return value === undefined ? undefined : getBodyLine(label, `${value}`);
|
|
34
|
+
function escapeMarkdownPreformatted(value) {
|
|
35
|
+
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
65
36
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
function getBodySectionText(section) {
|
|
38
|
+
return [
|
|
39
|
+
...section.fields.map((field) => getBodyLine(field.label, field.value)),
|
|
40
|
+
...(section.snippet
|
|
41
|
+
? [
|
|
42
|
+
`<span style="opacity: 0.55">${section.snippet.label}:</span>`,
|
|
43
|
+
`<pre>${escapeMarkdownPreformatted(section.snippet.text)}</pre>`,
|
|
44
|
+
]
|
|
45
|
+
: []),
|
|
46
|
+
].join('\n');
|
|
74
47
|
}
|
|
75
48
|
export class LLMChatV2NodeImpl extends NodeImpl {
|
|
76
49
|
static create() {
|
|
@@ -86,6 +59,12 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
86
59
|
data: createLLMChatV2NodeData(),
|
|
87
60
|
};
|
|
88
61
|
}
|
|
62
|
+
getRunActivityDescriptor() {
|
|
63
|
+
return {
|
|
64
|
+
category: 'model',
|
|
65
|
+
primaryOutputPortId: 'response',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
89
68
|
getInputDefinitions() {
|
|
90
69
|
const usesProfile = this.data.configurationMode === 'profile';
|
|
91
70
|
const commonInputData = usesProfile
|
|
@@ -108,9 +87,12 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
108
87
|
if (usesProfile) {
|
|
109
88
|
inputs.unshift({
|
|
110
89
|
id: 'llmProfile',
|
|
111
|
-
title: 'LLM
|
|
112
|
-
dataType: 'llm-config',
|
|
90
|
+
title: 'LLM Profiles',
|
|
91
|
+
dataType: ['llm-config', 'llm-config[]'],
|
|
113
92
|
required: true,
|
|
93
|
+
coerced: true,
|
|
94
|
+
splitRunBehavior: 'preserve-array',
|
|
95
|
+
description: 'One LLM Profile or an ordered fallback chain. Profiles are tried left to right.',
|
|
114
96
|
});
|
|
115
97
|
}
|
|
116
98
|
if (!usesProfile && this.data.apiKeySource === 'input') {
|
|
@@ -207,34 +189,52 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
207
189
|
});
|
|
208
190
|
const responseOutput = outputs.find((output) => output.id === 'response');
|
|
209
191
|
if (responseOutput != null && isLLMChatV2StructuredResponseFormat(this.data.responseFormat)) {
|
|
210
|
-
responseOutput.dataType =
|
|
211
|
-
'
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
192
|
+
responseOutput.dataType =
|
|
193
|
+
this.data.responseFormat === 'json_schema'
|
|
194
|
+
? 'object'
|
|
195
|
+
: [
|
|
196
|
+
'object',
|
|
197
|
+
'object[]',
|
|
198
|
+
'any',
|
|
199
|
+
'any[]',
|
|
200
|
+
'string',
|
|
201
|
+
'string[]',
|
|
202
|
+
'number',
|
|
203
|
+
'number[]',
|
|
204
|
+
'boolean',
|
|
205
|
+
'boolean[]',
|
|
206
|
+
];
|
|
222
207
|
}
|
|
223
|
-
if (this.data
|
|
208
|
+
if (shouldOutputChatV2RequestBody(this.data)) {
|
|
224
209
|
outputs.push({
|
|
225
|
-
id: 'requestStatus',
|
|
226
|
-
title: 'Response Status',
|
|
227
|
-
dataType: this.data.retryOnNon200 ? 'number[]' : 'number',
|
|
228
|
-
}, {
|
|
229
|
-
id: 'requestError',
|
|
230
|
-
title: 'Response Error',
|
|
231
|
-
dataType: this.data.retryOnNon200 ? 'string[]' : 'string',
|
|
232
|
-
}, {
|
|
233
210
|
id: 'requestBody',
|
|
234
211
|
title: 'LLM request body',
|
|
235
212
|
dataType: ['object', 'object[]', 'string', 'string[]', 'any', 'any[]'],
|
|
236
213
|
});
|
|
237
214
|
}
|
|
215
|
+
if (shouldOutputChatV2ResponseBody(this.data)) {
|
|
216
|
+
outputs.push({
|
|
217
|
+
id: 'responseBody',
|
|
218
|
+
title: 'LLM response body',
|
|
219
|
+
dataType: ['object', 'object[]', 'string', 'string[]', 'any', 'any[]'],
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (this.data.outputLLMAttempts) {
|
|
223
|
+
outputs.push({
|
|
224
|
+
id: 'llmAttempts',
|
|
225
|
+
title: 'LLM Attempts',
|
|
226
|
+
dataType: 'object[]',
|
|
227
|
+
description: 'Chronological provider configuration, request, and response-validation attempts for this LLM Chat run.',
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
if (this.data.configurationMode === 'profile') {
|
|
231
|
+
outputs.push({
|
|
232
|
+
id: 'llmProfileSummary',
|
|
233
|
+
title: 'LLM Profile Summary',
|
|
234
|
+
dataType: 'string',
|
|
235
|
+
description: 'Human-readable profile fallback outcome for this LLM Chat run.',
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
238
|
return outputs;
|
|
239
239
|
}
|
|
240
240
|
static getUIData() {
|
|
@@ -254,95 +254,82 @@ export class LLMChatV2NodeImpl extends NodeImpl {
|
|
|
254
254
|
return getLLMChatV2Editors(this.data, context);
|
|
255
255
|
}
|
|
256
256
|
getBody() {
|
|
257
|
-
if (this.data.configurationMode === 'profile') {
|
|
258
|
-
return {
|
|
259
|
-
type: 'markdown',
|
|
260
|
-
disableLinks: true,
|
|
261
|
-
text: [
|
|
262
|
-
getBodyLine('Configuration', 'From LLM Profile input'),
|
|
263
|
-
...(this.data.useToolCalling ? [getBodyLine('Tools', 'Enabled')] : []),
|
|
264
|
-
...(this.data.responseFormat ? [getBodyLine('Response format', this.data.responseFormat)] : []),
|
|
265
|
-
].join('\n'),
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
const modelInfo = getChatV2ModelInfo(this.data.provider, this.data.model);
|
|
269
|
-
const providerLabel = getProviderBodyLabel(this.data);
|
|
270
|
-
const baseURLValue = getCustomProviderBaseURLBodyValue(this.data);
|
|
271
|
-
const modelLine = modelInfo?.displayName ?? this.data.model;
|
|
272
|
-
const providerDetails = [
|
|
273
|
-
getBodyLine('Provider', providerLabel),
|
|
274
|
-
...(baseURLValue ? [getBodyLine('Base URL', baseURLValue)] : []),
|
|
275
|
-
getBodyLine('Model', modelLine),
|
|
276
|
-
];
|
|
277
|
-
const reasoningEffortValue = getReasoningEffortBodyValue(this.data);
|
|
278
257
|
return {
|
|
279
258
|
type: 'markdown',
|
|
280
259
|
disableLinks: true,
|
|
281
|
-
text:
|
|
282
|
-
...providerDetails,
|
|
283
|
-
...(reasoningEffortValue ? [getBodyLine('Reasoning effort', reasoningEffortValue)] : []),
|
|
284
|
-
getBodyLine('Temperature', this.data.useTemperatureInput ? '(Using Input)' : `${this.data.temperature}`),
|
|
285
|
-
getBodyLine('Max output tokens', this.data.useMaxTokensInput ? '(Using Input)' : `${this.data.maxTokens}`),
|
|
286
|
-
getOptionalNumberBodyLine('Top P', this.data.topP, this.data.useTopPInput),
|
|
287
|
-
getOptionalNumberBodyLine('Top K', this.data.topK, this.data.useTopKInput),
|
|
288
|
-
getOptionalNumberBodyLine('Presence penalty', this.data.presencePenalty, this.data.usePresencePenaltyInput),
|
|
289
|
-
getOptionalNumberBodyLine('Frequency penalty', this.data.frequencyPenalty, this.data.useFrequencyPenaltyInput),
|
|
290
|
-
getStopSequencesBodyLine(this.data),
|
|
291
|
-
getOptionalNumberBodyLine('Seed', this.data.seed, this.data.useSeedInput),
|
|
292
|
-
]
|
|
293
|
-
.filter((line) => line !== undefined)
|
|
294
|
-
.join('\n'),
|
|
260
|
+
text: getLLMChatV2BodySections(this.data).map(getBodySectionText).join('\n\n'),
|
|
295
261
|
};
|
|
296
262
|
}
|
|
297
263
|
async process(inputs, context) {
|
|
264
|
+
const invocationJournal = new LLMInvocationJournal();
|
|
265
|
+
// Retries, fallback profiles, and tool continuation produce several
|
|
266
|
+
// physical provider calls underneath one node invocation. Always observe
|
|
267
|
+
// them locally so every later output projection shares one truthful
|
|
268
|
+
// boundary; whether Usage is exposed remains an output-setting decision.
|
|
269
|
+
const usageTrackingContext = {
|
|
270
|
+
...context,
|
|
271
|
+
onChatV2CallFinished: (event) => {
|
|
272
|
+
try {
|
|
273
|
+
invocationJournal.recordModelCall(event);
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Accounting is observational and must never affect a provider call.
|
|
277
|
+
}
|
|
278
|
+
return context.onChatV2CallFinished?.(event);
|
|
279
|
+
},
|
|
280
|
+
};
|
|
298
281
|
const runtime = await resolveLLMChatV2RuntimeConfig({
|
|
299
282
|
data: this.data,
|
|
300
283
|
nodeId: this.chartNode.id,
|
|
301
284
|
inputs,
|
|
302
|
-
context,
|
|
285
|
+
context: usageTrackingContext,
|
|
286
|
+
onLLMAttempt: (attempt) => invocationJournal.recordLLMAttempt(attempt),
|
|
303
287
|
});
|
|
304
288
|
const toolCallContinuation = context.toolCallContinuation;
|
|
305
|
-
|
|
306
|
-
|
|
289
|
+
const cacheHit = projectLLMChatV2EditorCacheHit(runtime);
|
|
290
|
+
if (cacheHit != null) {
|
|
291
|
+
context.markResultAsEditorCacheHit?.();
|
|
292
|
+
return cacheHit;
|
|
307
293
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const results = await toolCallContinuation.run(toolCalls, preToolMessage);
|
|
317
|
-
return results.map((result) => ({
|
|
318
|
-
type: 'chat-message',
|
|
319
|
-
value: result.message,
|
|
320
|
-
delegatedToolCall: result.record,
|
|
321
|
-
}));
|
|
322
|
-
}
|
|
323
|
-
: undefined,
|
|
324
|
-
delegateToolCall: async (toolCall) => {
|
|
325
|
-
const delegated = await delegateToolCall(toolCall, context, {
|
|
326
|
-
handlers: [],
|
|
327
|
-
unknownHandler: undefined,
|
|
328
|
-
autoDelegate: true,
|
|
329
|
-
fallBackToExternalCall: true,
|
|
330
|
-
passthroughErrors: true,
|
|
331
|
-
});
|
|
332
|
-
return {
|
|
333
|
-
type: 'chat-message',
|
|
334
|
-
value: delegated.message,
|
|
335
|
-
delegatedToolCall: delegated.record,
|
|
336
|
-
};
|
|
337
|
-
},
|
|
338
|
-
})
|
|
339
|
-
: await runChatV2Pipeline(runtime.runOptions);
|
|
340
|
-
if (toolCallContinuation && result.functionCalls.length > 0) {
|
|
341
|
-
toolCallContinuation.release();
|
|
294
|
+
let result;
|
|
295
|
+
try {
|
|
296
|
+
result = await executeLLMInvocation({
|
|
297
|
+
context,
|
|
298
|
+
journal: invocationJournal,
|
|
299
|
+
runtime,
|
|
300
|
+
toolCallContinuation,
|
|
301
|
+
});
|
|
342
302
|
}
|
|
343
|
-
|
|
344
|
-
|
|
303
|
+
catch (error) {
|
|
304
|
+
try {
|
|
305
|
+
const diagnostics = projectLLMInvocationDiagnostics({
|
|
306
|
+
runOptions: runtime.runOptions,
|
|
307
|
+
outputLLMAttempts: this.data.outputLLMAttempts,
|
|
308
|
+
llmAttempts: invocationJournal.llmAttempts,
|
|
309
|
+
profileSummary: runtime.getProfileSummary?.(),
|
|
310
|
+
});
|
|
311
|
+
if (Object.keys(diagnostics).length > 0) {
|
|
312
|
+
context.onPartialOutputs?.(diagnostics);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
catch {
|
|
316
|
+
// Developer diagnostics are observational and must never replace the
|
|
317
|
+
// provider/configuration error which caused this node to fail.
|
|
318
|
+
}
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
projectLLMInvocationResult({
|
|
322
|
+
result,
|
|
323
|
+
modelCalls: invocationJournal.modelCalls,
|
|
324
|
+
outputUsage: this.data.outputUsage,
|
|
325
|
+
outputLLMAttempts: this.data.outputLLMAttempts,
|
|
326
|
+
llmAttempts: invocationJournal.llmAttempts,
|
|
327
|
+
profileSummary: runtime.getProfileSummary?.(),
|
|
328
|
+
});
|
|
329
|
+
if (toolCallContinuation && !isChatV2PipelineProviderFailureResult(result) && result.functionCalls.length > 0) {
|
|
330
|
+
toolCallContinuation.release();
|
|
345
331
|
}
|
|
332
|
+
writeLLMChatV2EditorCache({ runtime, result });
|
|
346
333
|
return result.commonOutputs;
|
|
347
334
|
}
|
|
348
335
|
}
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { nanoid } from 'nanoid/non-secure';
|
|
2
|
-
import { dedent } from 'ts-dedent';
|
|
3
2
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
3
|
import { NodeImpl } from '../NodeImpl.js';
|
|
5
4
|
import { getLLMProfileEditors } from '../chat-v2/llmChatV2NodeEditors.js';
|
|
5
|
+
import { getLLMProfileBodySections } from '../chat-v2/llmProfileBody.js';
|
|
6
6
|
import { resolveLLMProfileNodeValue } from '../chat-v2/llmProfileNodeRuntime.js';
|
|
7
7
|
import { createLLMProfileNodeData } from '../chat-v2/llmProfileTypes.js';
|
|
8
|
-
|
|
8
|
+
function escapeMarkdownInline(value) {
|
|
9
|
+
return String(value)
|
|
10
|
+
.replace(/\r/g, '\\r')
|
|
11
|
+
.replace(/\n/g, '\\n')
|
|
12
|
+
.replace(/&/g, '&')
|
|
13
|
+
.replace(/</g, '<')
|
|
14
|
+
.replace(/>/g, '>')
|
|
15
|
+
.replace(/"/g, '"')
|
|
16
|
+
.replace(/([\\`*_[\]{}()#+\-.!|])/g, '\\$1');
|
|
17
|
+
}
|
|
18
|
+
function getBodyLine(label, value) {
|
|
19
|
+
return `<span style="opacity: 0.55">${label}:</span> ${escapeMarkdownInline(value)}`;
|
|
20
|
+
}
|
|
9
21
|
export class LLMProfileNodeImpl extends NodeImpl {
|
|
10
22
|
static create() {
|
|
11
23
|
return {
|
|
@@ -101,12 +113,19 @@ export class LLMProfileNodeImpl extends NodeImpl {
|
|
|
101
113
|
return await getLLMProfileEditors(this.data, context);
|
|
102
114
|
}
|
|
103
115
|
getBody() {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
return {
|
|
117
|
+
type: 'markdown',
|
|
118
|
+
disableLinks: true,
|
|
119
|
+
text: getLLMProfileBodySections(this.data)
|
|
120
|
+
.map((section) => {
|
|
121
|
+
const fields = section.fields.map((field) => getBodyLine(field.label, field.value));
|
|
122
|
+
const snippet = section.snippet
|
|
123
|
+
? `${getBodyLine(section.snippet.label, '')}\n${escapeMarkdownInline(section.snippet.text)}`
|
|
124
|
+
: undefined;
|
|
125
|
+
return [...fields, ...(snippet ? [snippet] : [])].join('\n');
|
|
126
|
+
})
|
|
127
|
+
.join('\n\n'),
|
|
128
|
+
};
|
|
110
129
|
}
|
|
111
130
|
static getUIData() {
|
|
112
131
|
return {
|
|
@@ -90,6 +90,13 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
90
90
|
}
|
|
91
91
|
return outputs;
|
|
92
92
|
}
|
|
93
|
+
getRunActivityDescriptor() {
|
|
94
|
+
// A Prompt can additionally emit a token count, but its user-visible
|
|
95
|
+
// result is always the generated chat-message on `output`.
|
|
96
|
+
return {
|
|
97
|
+
primaryOutputPortId: 'output',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
93
100
|
getEditors() {
|
|
94
101
|
return [
|
|
95
102
|
{
|
|
@@ -102,6 +109,7 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
102
109
|
label: 'Type',
|
|
103
110
|
options: [
|
|
104
111
|
{ value: 'system', label: 'System' },
|
|
112
|
+
{ value: 'developer', label: 'Developer' },
|
|
105
113
|
{ value: 'user', label: 'User' },
|
|
106
114
|
{ value: 'assistant', label: 'Assistant' },
|
|
107
115
|
{ value: 'function', label: 'Function' },
|
|
@@ -162,7 +170,7 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
162
170
|
static getUIData() {
|
|
163
171
|
return {
|
|
164
172
|
infoBoxBody: dedent `
|
|
165
|
-
Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System) and optionally an attached "name".
|
|
173
|
+
Outputs a chat message, which is a string of text with an attached "type" saying who sent the message (User, Assistant, System, Developer) and optionally an attached "name".
|
|
166
174
|
|
|
167
175
|
Also provides the same <span style="color: var(--primary)">{{interpolation}}</span> capabilities as a Text node.
|
|
168
176
|
|
|
@@ -182,7 +190,7 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
182
190
|
outputValue = outputValue.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
183
191
|
const type = getInputOrData(this.data, inputs, 'type', 'string');
|
|
184
192
|
const isCacheBreakpoint = getInputOrData(this.data, inputs, 'isCacheBreakpoint', 'boolean');
|
|
185
|
-
if (['assistant', 'system', 'user', 'function'].includes(type) === false) {
|
|
193
|
+
if (['assistant', 'system', 'developer', 'user', 'function'].includes(type) === false) {
|
|
186
194
|
throw new Error(`Invalid type: ${type}`);
|
|
187
195
|
}
|
|
188
196
|
const message = match(type)
|
|
@@ -190,6 +198,11 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
190
198
|
type,
|
|
191
199
|
message: outputValue,
|
|
192
200
|
isCacheBreakpoint,
|
|
201
|
+
}))
|
|
202
|
+
.with('developer', (type) => ({
|
|
203
|
+
type,
|
|
204
|
+
message: outputValue,
|
|
205
|
+
isCacheBreakpoint,
|
|
193
206
|
}))
|
|
194
207
|
.with('user', (type) => ({
|
|
195
208
|
type,
|
|
@@ -246,6 +259,7 @@ export class PromptNodeImpl extends NodeImpl {
|
|
|
246
259
|
export const promptNode = nodeDefinition(PromptNodeImpl, 'Prompt');
|
|
247
260
|
const typeDisplay = {
|
|
248
261
|
assistant: 'Assistant',
|
|
262
|
+
developer: 'Developer',
|
|
249
263
|
system: 'System',
|
|
250
264
|
user: 'User',
|
|
251
265
|
function: 'Function',
|
|
@@ -84,6 +84,13 @@ export class GptFunctionNodeImpl extends NodeImpl {
|
|
|
84
84
|
},
|
|
85
85
|
];
|
|
86
86
|
}
|
|
87
|
+
getRunActivityDescriptor() {
|
|
88
|
+
return {
|
|
89
|
+
category: 'tool',
|
|
90
|
+
primaryOutputPortId: 'function',
|
|
91
|
+
fullOutputActionLabel: 'Open tool definition',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
87
94
|
getEditors() {
|
|
88
95
|
return [
|
|
89
96
|
{
|