@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
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider-neutral numeric contract shared by LLM Chat V2 usage consumers.
|
|
3
|
+
* Provider metadata is untrusted, so callers must not treat negative, NaN, or
|
|
4
|
+
* infinite token counts as real usage.
|
|
5
|
+
*/
|
|
6
|
+
export function isChatV2FiniteNonNegativeNumber(value) {
|
|
7
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Aggregates one node invocation's physical provider calls into its portable
|
|
11
|
+
* Usage output. The call id is a stable transport identity, so a redelivered
|
|
12
|
+
* lifecycle event replaces prior metadata instead of inflating totals.
|
|
13
|
+
*/
|
|
14
|
+
export function summarizeChatV2PhysicalCallUsage(events) {
|
|
15
|
+
const eventsByCallId = new Map();
|
|
16
|
+
const callIdsInOrder = [];
|
|
17
|
+
for (const event of events) {
|
|
18
|
+
const callId = event.callId;
|
|
19
|
+
if (!eventsByCallId.has(callId)) {
|
|
20
|
+
callIdsInOrder.push(callId);
|
|
21
|
+
}
|
|
22
|
+
eventsByCallId.set(callId, event);
|
|
23
|
+
}
|
|
24
|
+
let promptTokens = 0;
|
|
25
|
+
let completionTokens = 0;
|
|
26
|
+
let totalTokens = 0;
|
|
27
|
+
let cachedTokens = 0;
|
|
28
|
+
let reasoningTokens = 0;
|
|
29
|
+
let hasUsage = false;
|
|
30
|
+
let totalCost = 0;
|
|
31
|
+
let hasExactCost = callIdsInOrder.length > 0;
|
|
32
|
+
for (const callId of callIdsInOrder) {
|
|
33
|
+
const event = eventsByCallId.get(callId);
|
|
34
|
+
const usage = event.normalizedUsage;
|
|
35
|
+
const safePromptTokens = isChatV2FiniteNonNegativeNumber(usage?.promptTokens) ? usage.promptTokens : undefined;
|
|
36
|
+
const safeCompletionTokens = isChatV2FiniteNonNegativeNumber(usage?.completionTokens)
|
|
37
|
+
? usage.completionTokens
|
|
38
|
+
: undefined;
|
|
39
|
+
const safeTotalTokens = isChatV2FiniteNonNegativeNumber(usage?.totalTokens) ? usage.totalTokens : undefined;
|
|
40
|
+
const safeCachedTokens = isChatV2FiniteNonNegativeNumber(usage?.cachedTokens) ? usage.cachedTokens : undefined;
|
|
41
|
+
const safeReasoningTokens = isChatV2FiniteNonNegativeNumber(usage?.reasoningTokens)
|
|
42
|
+
? usage.reasoningTokens
|
|
43
|
+
: undefined;
|
|
44
|
+
// Physical-call traces preserve omitted fields rather than manufacturing
|
|
45
|
+
// zeros. The node-level Usage contract, however, has always exposed a
|
|
46
|
+
// total; retain that contract when a provider reports only input or output
|
|
47
|
+
// tokens by deriving a total from the safe fields that are present.
|
|
48
|
+
const totalTokensForCall = safeTotalTokens ?? (safePromptTokens ?? 0) + (safeCompletionTokens ?? 0);
|
|
49
|
+
if (safePromptTokens != null ||
|
|
50
|
+
safeCompletionTokens != null ||
|
|
51
|
+
safeTotalTokens != null ||
|
|
52
|
+
safeCachedTokens != null ||
|
|
53
|
+
safeReasoningTokens != null) {
|
|
54
|
+
hasUsage = true;
|
|
55
|
+
promptTokens += safePromptTokens ?? 0;
|
|
56
|
+
completionTokens += safeCompletionTokens ?? 0;
|
|
57
|
+
totalTokens += totalTokensForCall;
|
|
58
|
+
cachedTokens += safeCachedTokens ?? 0;
|
|
59
|
+
reasoningTokens += safeReasoningTokens ?? 0;
|
|
60
|
+
}
|
|
61
|
+
if (event.pricing.status === 'known' && isChatV2FiniteNonNegativeNumber(event.pricing.costUsd)) {
|
|
62
|
+
totalCost += event.pricing.costUsd;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
hasExactCost = false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return hasUsage
|
|
69
|
+
? {
|
|
70
|
+
promptTokens,
|
|
71
|
+
completionTokens,
|
|
72
|
+
totalTokens,
|
|
73
|
+
cachedTokens,
|
|
74
|
+
reasoningTokens,
|
|
75
|
+
totalCost: hasExactCost ? totalCost : undefined,
|
|
76
|
+
}
|
|
77
|
+
: undefined;
|
|
78
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export const customProviderApiOptions = [
|
|
2
|
+
{ value: 'completions', label: 'Completions' },
|
|
3
|
+
{ value: 'responses', label: 'Responses' },
|
|
4
|
+
];
|
|
5
|
+
const customProviderApiContracts = {
|
|
6
|
+
completions: {
|
|
7
|
+
api: 'completions',
|
|
8
|
+
adapter: 'openai-compatible',
|
|
9
|
+
providerOptionsKey: 'custom',
|
|
10
|
+
endpointPath: '/chat/completions',
|
|
11
|
+
label: 'Custom Completions',
|
|
12
|
+
structuredOutput: 'raw-response-format',
|
|
13
|
+
parallelToolCalls: 'enabled-only-raw-field',
|
|
14
|
+
},
|
|
15
|
+
responses: {
|
|
16
|
+
api: 'responses',
|
|
17
|
+
adapter: 'openai-responses',
|
|
18
|
+
providerOptionsKey: 'openai',
|
|
19
|
+
endpointPath: '/responses',
|
|
20
|
+
label: 'Custom Responses',
|
|
21
|
+
structuredOutput: 'sdk-output',
|
|
22
|
+
parallelToolCalls: 'openai-option',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Keep legacy nodes on Chat Completions while rejecting corrupt/API-authored
|
|
27
|
+
* values before a provider request is created.
|
|
28
|
+
*/
|
|
29
|
+
export function parseCustomProviderApi(value) {
|
|
30
|
+
switch (value) {
|
|
31
|
+
case undefined:
|
|
32
|
+
case 'completions':
|
|
33
|
+
return 'completions';
|
|
34
|
+
case 'responses':
|
|
35
|
+
return 'responses';
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Unsupported Custom provider API: ${String(value)}.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function getCustomProviderApiContract(value) {
|
|
41
|
+
return customProviderApiContracts[parseCustomProviderApi(value)];
|
|
42
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function getInstructionMessageRoles(messages) {
|
|
2
|
+
return messages
|
|
3
|
+
.filter((message) => message.type === 'system' || message.type === 'developer')
|
|
4
|
+
.map((message) => message.type);
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* AI SDK's provider-neutral ModelMessage represents both Rivet system and
|
|
8
|
+
* developer instructions with role `system`. Restore the explicit Rivet roles
|
|
9
|
+
* only at OpenAI-compatible wire boundaries, after the provider has built its
|
|
10
|
+
* request body.
|
|
11
|
+
*/
|
|
12
|
+
export function restoreOpenAICompatibleInstructionRoles(body, roles) {
|
|
13
|
+
if (roles.length === 0) {
|
|
14
|
+
return body;
|
|
15
|
+
}
|
|
16
|
+
if (body == null || typeof body !== 'object' || Array.isArray(body)) {
|
|
17
|
+
throw new Error('Could not preserve developer messages: provider request body is not a JSON object.');
|
|
18
|
+
}
|
|
19
|
+
const record = body;
|
|
20
|
+
const listKey = Array.isArray(record.messages) ? 'messages' : Array.isArray(record.input) ? 'input' : undefined;
|
|
21
|
+
if (listKey == null) {
|
|
22
|
+
throw new Error('Could not preserve developer messages: provider request body has no messages or input array.');
|
|
23
|
+
}
|
|
24
|
+
const items = record[listKey];
|
|
25
|
+
const instructionIndexes = items.flatMap((item, index) => item != null &&
|
|
26
|
+
typeof item === 'object' &&
|
|
27
|
+
!Array.isArray(item) &&
|
|
28
|
+
(item.role === 'system' || item.role === 'developer')
|
|
29
|
+
? [index]
|
|
30
|
+
: []);
|
|
31
|
+
if (instructionIndexes.length !== roles.length) {
|
|
32
|
+
throw new Error(`Could not preserve developer messages: expected ${roles.length} instruction message(s), but the provider request contains ${instructionIndexes.length}.`);
|
|
33
|
+
}
|
|
34
|
+
const rewrittenItems = [...items];
|
|
35
|
+
instructionIndexes.forEach((itemIndex, roleIndex) => {
|
|
36
|
+
rewrittenItems[itemIndex] = {
|
|
37
|
+
...rewrittenItems[itemIndex],
|
|
38
|
+
role: roles[roleIndex],
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
...record,
|
|
43
|
+
[listKey]: rewrittenItems,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -7,8 +7,20 @@ export * from './chatV2ResponseFormat.js';
|
|
|
7
7
|
export * from './chatV2Shared.js';
|
|
8
8
|
export * from './chatV2Types.js';
|
|
9
9
|
export * from './llmProfileTypes.js';
|
|
10
|
+
export * from './llmProfileBody.js';
|
|
11
|
+
export * from './llmChatV2Body.js';
|
|
10
12
|
export * from './messageConverter.js';
|
|
11
13
|
export * from './modelRegistry.js';
|
|
12
14
|
export * from './providerOptions.js';
|
|
13
15
|
export * from './toolConverter.js';
|
|
14
16
|
export * from './toolContinuationConnection.js';
|
|
17
|
+
export * from './chatV2ProviderRegistry.js';
|
|
18
|
+
export * from './llmChatV2NodeMigration.js';
|
|
19
|
+
export * from './llmInvocationCoordinator.js';
|
|
20
|
+
export * from './llmInvocationProjections.js';
|
|
21
|
+
export * from './llmInvocationDecision.js';
|
|
22
|
+
export * from './llmChatV2CacheBoundary.js';
|
|
23
|
+
export * from './llmResponseMaterializer.js';
|
|
24
|
+
export * from './toolCallCodec.js';
|
|
25
|
+
export * from './toolHandlerResolver.js';
|
|
26
|
+
export * from './toolRoundExecutor.js';
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES, } from './chatV2Retry.js';
|
|
2
|
+
import { getChatV2ModelInfo } from './modelRegistry.js';
|
|
3
|
+
import { anthropicCacheControlTtlOptions, anthropicEffortOptions, anthropicThinkingModeOptions, getChatV2ProviderLabel, getCustomProviderApiContract, googleThinkingLevelOptions, openAIReasoningEffortOptions, openAIWebSearchContextSizeOptions, } from './providerOptions.js';
|
|
4
|
+
function getOptionLabel(options, value) {
|
|
5
|
+
const optionValue = typeof value === 'string' ? value : '';
|
|
6
|
+
return options.find((option) => option.value === optionValue)?.label ?? (optionValue || 'Default');
|
|
7
|
+
}
|
|
8
|
+
function getProviderBodyLabel(data) {
|
|
9
|
+
return data.provider === 'custom' ? 'Custom' : getChatV2ProviderLabel(data.provider);
|
|
10
|
+
}
|
|
11
|
+
function getModelBodyValue(data) {
|
|
12
|
+
if (data.useModelInput) {
|
|
13
|
+
return '(Using Input)';
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
return getChatV2ModelInfo(data.provider, data.model)?.displayName ?? data.model;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Hand-authored/corrupt projects should remain inspectable on the canvas.
|
|
20
|
+
return data.model;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function getCustomProviderBaseURLBodyValue(data) {
|
|
24
|
+
if (data.provider !== 'custom') {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (data.useCustomProviderBaseURLInput) {
|
|
28
|
+
return '(Using Input)';
|
|
29
|
+
}
|
|
30
|
+
const baseURL = typeof data.customProviderBaseURL === 'string' ? data.customProviderBaseURL.trim() : '';
|
|
31
|
+
return baseURL || undefined;
|
|
32
|
+
}
|
|
33
|
+
function getCustomProviderApiBodyField(data) {
|
|
34
|
+
if (data.provider !== 'custom') {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const api = getCustomProviderApiContract(data.customProviderApi);
|
|
39
|
+
return api.api === 'completions' ? undefined : { label: 'API', value: api.label };
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return { label: 'API', value: `Unsupported (${String(data.customProviderApi)})` };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function getOptionalNumberBodyField(label, value, usesInput) {
|
|
46
|
+
if (usesInput) {
|
|
47
|
+
return { label, value: '(Using Input)' };
|
|
48
|
+
}
|
|
49
|
+
return value === undefined ? undefined : { label, value: `${value}` };
|
|
50
|
+
}
|
|
51
|
+
function getOptionalStringBodyField(label, value, usesInput) {
|
|
52
|
+
if (usesInput) {
|
|
53
|
+
return { label, value: '(Using Input)' };
|
|
54
|
+
}
|
|
55
|
+
return typeof value === 'string' && value.trim().length > 0 ? { label, value } : undefined;
|
|
56
|
+
}
|
|
57
|
+
function getStopSequencesBodyField(data) {
|
|
58
|
+
if (data.useStopSequencesInput) {
|
|
59
|
+
return { label: 'Stop sequences', value: '(Using Input)' };
|
|
60
|
+
}
|
|
61
|
+
const stopSequences = Array.isArray(data.stopSequences)
|
|
62
|
+
? data.stopSequences.filter((sequence) => typeof sequence === 'string' && sequence.length > 0)
|
|
63
|
+
: [];
|
|
64
|
+
return stopSequences.length === 0
|
|
65
|
+
? undefined
|
|
66
|
+
: { label: 'Stop sequences', value: stopSequences.map((sequence) => JSON.stringify(sequence)).join(', ') };
|
|
67
|
+
}
|
|
68
|
+
function getHeadersBodyField(data) {
|
|
69
|
+
if (data.useHeadersInput) {
|
|
70
|
+
return { label: 'Headers', value: '(Using Input)' };
|
|
71
|
+
}
|
|
72
|
+
const headers = Array.isArray(data.headers)
|
|
73
|
+
? data.headers.filter((header) => typeof header?.key === 'string' && header.key.trim().length > 0 && typeof header.value === 'string')
|
|
74
|
+
: [];
|
|
75
|
+
return headers.length > 0
|
|
76
|
+
? { label: 'Headers', value: headers.map(({ key, value }) => `${key}: ${value}`).join(', ') }
|
|
77
|
+
: undefined;
|
|
78
|
+
}
|
|
79
|
+
function getProviderBodyFields(data) {
|
|
80
|
+
switch (data.provider) {
|
|
81
|
+
case 'openai':
|
|
82
|
+
return [
|
|
83
|
+
getOptionalStringBodyField('Previous response ID', data.openAIPreviousResponseId, data.useOpenAIPreviousResponseIdInput),
|
|
84
|
+
...(data.openAIReasoningSummary ? [{ label: 'Reasoning summary', value: data.openAIReasoningSummary }] : []),
|
|
85
|
+
...(data.enableOpenAIWebSearch
|
|
86
|
+
? [
|
|
87
|
+
{
|
|
88
|
+
label: 'Web search',
|
|
89
|
+
value: `Enabled (${getOptionLabel(openAIWebSearchContextSizeOptions, data.openAIWebSearchContextSize)})`,
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
: []),
|
|
93
|
+
...(data.enableOpenAICodeInterpreter ? [{ label: 'Code interpreter', value: 'Enabled' }] : []),
|
|
94
|
+
].filter((field) => field !== undefined);
|
|
95
|
+
case 'anthropic':
|
|
96
|
+
return [
|
|
97
|
+
...(data.anthropicThinkingMode
|
|
98
|
+
? [
|
|
99
|
+
{
|
|
100
|
+
label: 'Thinking mode',
|
|
101
|
+
value: getOptionLabel(anthropicThinkingModeOptions, data.anthropicThinkingMode),
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
: []),
|
|
105
|
+
getOptionalNumberBodyField('Thinking budget', data.anthropicThinkingBudget, data.useAnthropicThinkingBudgetInput),
|
|
106
|
+
...(data.anthropicCacheControlTtl
|
|
107
|
+
? [
|
|
108
|
+
{
|
|
109
|
+
label: 'Cache breakpoint TTL',
|
|
110
|
+
value: getOptionLabel(anthropicCacheControlTtlOptions, data.anthropicCacheControlTtl),
|
|
111
|
+
},
|
|
112
|
+
]
|
|
113
|
+
: []),
|
|
114
|
+
].filter((field) => field !== undefined);
|
|
115
|
+
case 'google':
|
|
116
|
+
return [
|
|
117
|
+
getOptionalNumberBodyField('Thinking budget', data.googleThinkingBudget, data.useGoogleThinkingBudgetInput),
|
|
118
|
+
...(data.googleIncludeThoughts ? [{ label: 'Include thoughts', value: 'Enabled' }] : []),
|
|
119
|
+
...(data.enableGoogleSearchGrounding ? [{ label: 'Google search grounding', value: 'Enabled' }] : []),
|
|
120
|
+
...(data.enableGoogleUrlContext ? [{ label: 'URL context', value: 'Enabled' }] : []),
|
|
121
|
+
].filter((field) => field !== undefined);
|
|
122
|
+
case 'custom':
|
|
123
|
+
default:
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getResponseFormatBodyFields(data) {
|
|
128
|
+
if (!data.responseFormat) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
const responseFormatLabel = data.responseFormat === 'json_schema' ? 'JSON schema' : data.responseFormat === 'json' ? 'JSON object' : 'Text';
|
|
132
|
+
const hasSchemaMetadata = data.responseFormat === 'json' || data.responseFormat === 'json_schema';
|
|
133
|
+
return [
|
|
134
|
+
{ label: 'Response format', value: responseFormatLabel },
|
|
135
|
+
...(hasSchemaMetadata
|
|
136
|
+
? [
|
|
137
|
+
getOptionalStringBodyField('Schema name', data.responseSchemaName, !!data.useResponseSchemaNameInput),
|
|
138
|
+
getOptionalStringBodyField('Schema description', data.responseSchemaDescription, !!data.useResponseSchemaDescriptionInput),
|
|
139
|
+
]
|
|
140
|
+
: []),
|
|
141
|
+
].filter((field) => field !== undefined);
|
|
142
|
+
}
|
|
143
|
+
function getToolBodyFields(data) {
|
|
144
|
+
if (!data.useToolCalling) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
return [
|
|
148
|
+
{ label: 'Tool use', value: 'Enabled' },
|
|
149
|
+
...(data.toolChoice
|
|
150
|
+
? [
|
|
151
|
+
{
|
|
152
|
+
label: 'Tool choice',
|
|
153
|
+
value: data.toolChoice === 'function'
|
|
154
|
+
? data.toolChoiceFunction?.trim()
|
|
155
|
+
? `Specific tool (${data.toolChoiceFunction})`
|
|
156
|
+
: 'Specific tool'
|
|
157
|
+
: data.toolChoice === 'required'
|
|
158
|
+
? 'Required'
|
|
159
|
+
: 'Auto',
|
|
160
|
+
},
|
|
161
|
+
]
|
|
162
|
+
: []),
|
|
163
|
+
...(data.parallelToolCalls ? [{ label: 'Parallel toolcalls', value: 'Enabled' }] : []),
|
|
164
|
+
...(data.autoContinueToolCalls
|
|
165
|
+
? [
|
|
166
|
+
{ label: 'Auto-continue toolcalls', value: 'Enabled' },
|
|
167
|
+
{ label: 'Maximum tool rounds', value: `${data.maxToolRounds ?? 3}` },
|
|
168
|
+
]
|
|
169
|
+
: []),
|
|
170
|
+
];
|
|
171
|
+
}
|
|
172
|
+
function getBehaviorBodyFields(data) {
|
|
173
|
+
return [
|
|
174
|
+
...(data.useAsGraphPartialOutput === false ? [{ label: 'Stream response', value: 'Disabled' }] : []),
|
|
175
|
+
...(data.cache ? [{ label: 'Editor cache (legacy)', value: 'Enabled' }] : []),
|
|
176
|
+
];
|
|
177
|
+
}
|
|
178
|
+
function getErrorBodyFields(data) {
|
|
179
|
+
if (!data.retryOnNon200) {
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const repeatTimes = data.retryOnNon200RepeatTimes ?? DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES;
|
|
183
|
+
const cooldownMs = data.retryOnNon200CooldownMs ?? DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS;
|
|
184
|
+
return [
|
|
185
|
+
{ label: 'Retry on non-200', value: 'Enabled' },
|
|
186
|
+
{ label: 'Repeat times', value: `${repeatTimes}` },
|
|
187
|
+
{ label: 'Cooldown, ms', value: `${cooldownMs}` },
|
|
188
|
+
];
|
|
189
|
+
}
|
|
190
|
+
function getAdvancedBodySection(data) {
|
|
191
|
+
const extraProviderOptions = !data.useExtraProviderOptionsInput &&
|
|
192
|
+
typeof data.extraProviderOptions === 'string' &&
|
|
193
|
+
data.extraProviderOptions.trim().length > 0
|
|
194
|
+
? { label: 'Extra provider options', text: data.extraProviderOptions }
|
|
195
|
+
: undefined;
|
|
196
|
+
return {
|
|
197
|
+
id: 'advanced',
|
|
198
|
+
fields: [
|
|
199
|
+
getHeadersBodyField(data),
|
|
200
|
+
...(data.useExtraProviderOptionsInput ? [{ label: 'Extra provider options', value: '(Using Input)' }] : []),
|
|
201
|
+
].filter((field) => field !== undefined),
|
|
202
|
+
snippet: extraProviderOptions,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function getInlineModelBodyFields(data) {
|
|
206
|
+
const customBaseURL = getCustomProviderBaseURLBodyValue(data);
|
|
207
|
+
return [
|
|
208
|
+
{ label: 'Provider', value: getProviderBodyLabel(data) },
|
|
209
|
+
getCustomProviderApiBodyField(data),
|
|
210
|
+
customBaseURL ? { label: 'Base URL', value: customBaseURL } : undefined,
|
|
211
|
+
{ label: 'Model', value: getModelBodyValue(data) },
|
|
212
|
+
...(data.apiKeySource === 'input' ? [{ label: 'API key source', value: 'Input port' }] : []),
|
|
213
|
+
...(data.provider === 'custom' && data.apiKeySource !== 'input'
|
|
214
|
+
? [
|
|
215
|
+
data.customProviderApiKeyProgrammaticName?.trim()
|
|
216
|
+
? { label: 'Alternative programmatic key', value: data.customProviderApiKeyProgrammaticName }
|
|
217
|
+
: undefined,
|
|
218
|
+
data.customProviderApiKeyEnvVarName?.trim() &&
|
|
219
|
+
data.customProviderApiKeyEnvVarName !== 'CUSTOM_PROVIDER_API_KEY'
|
|
220
|
+
? { label: 'Alternative API key env var', value: data.customProviderApiKeyEnvVarName }
|
|
221
|
+
: undefined,
|
|
222
|
+
]
|
|
223
|
+
: []),
|
|
224
|
+
].filter((field) => field !== undefined);
|
|
225
|
+
}
|
|
226
|
+
function getParameterBodyFields(data) {
|
|
227
|
+
const reasoningEffort = data.provider === 'openai'
|
|
228
|
+
? getOptionLabel(openAIReasoningEffortOptions, data.openAIReasoningEffort)
|
|
229
|
+
: data.provider === 'anthropic'
|
|
230
|
+
? getOptionLabel(anthropicEffortOptions, data.anthropicEffort)
|
|
231
|
+
: data.provider === 'google'
|
|
232
|
+
? getOptionLabel(googleThinkingLevelOptions, data.googleThinkingLevel)
|
|
233
|
+
: undefined;
|
|
234
|
+
return [
|
|
235
|
+
...(reasoningEffort ? [{ label: 'Reasoning effort', value: reasoningEffort }] : []),
|
|
236
|
+
{ label: 'Temperature', value: data.useTemperatureInput ? '(Using Input)' : `${data.temperature}` },
|
|
237
|
+
{ label: 'Max output tokens', value: data.useMaxTokensInput ? '(Using Input)' : `${data.maxTokens}` },
|
|
238
|
+
getOptionalNumberBodyField('Top P', data.topP, data.useTopPInput),
|
|
239
|
+
getOptionalNumberBodyField('Top K', data.topK, data.useTopKInput),
|
|
240
|
+
getOptionalNumberBodyField('Presence penalty', data.presencePenalty, data.usePresencePenaltyInput),
|
|
241
|
+
getOptionalNumberBodyField('Frequency penalty', data.frequencyPenalty, data.useFrequencyPenaltyInput),
|
|
242
|
+
getStopSequencesBodyField(data),
|
|
243
|
+
getOptionalNumberBodyField('Seed', data.seed, data.useSeedInput),
|
|
244
|
+
].filter((field) => field !== undefined);
|
|
245
|
+
}
|
|
246
|
+
function getInvocationSections(data) {
|
|
247
|
+
const sections = [
|
|
248
|
+
{ id: 'response-format', fields: getResponseFormatBodyFields(data) },
|
|
249
|
+
{ id: 'tools', fields: getToolBodyFields(data) },
|
|
250
|
+
{ id: 'behavior', fields: getBehaviorBodyFields(data) },
|
|
251
|
+
{ id: 'error', fields: getErrorBodyFields(data) },
|
|
252
|
+
];
|
|
253
|
+
return sections.filter((section) => section.fields.length > 0);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Stable canvas presentation data for LLM Chat configuration.
|
|
257
|
+
*
|
|
258
|
+
* Inline mode exposes its local model/provider settings plus every active
|
|
259
|
+
* invocation setting. Profile mode deliberately exposes only invocation-owned
|
|
260
|
+
* settings because provider configuration comes from the connected LLM Profile
|
|
261
|
+
* value at runtime. Output toggles are intentionally omitted: their ports are
|
|
262
|
+
* already the canonical canvas indication that an output is enabled.
|
|
263
|
+
*/
|
|
264
|
+
export function getLLMChatV2BodySections(data) {
|
|
265
|
+
if (data.configurationMode === 'profile') {
|
|
266
|
+
const sections = [
|
|
267
|
+
{ id: 'configuration', fields: [{ label: 'Configuration', value: 'From LLM Profiles input' }] },
|
|
268
|
+
...getInvocationSections(data),
|
|
269
|
+
];
|
|
270
|
+
return sections;
|
|
271
|
+
}
|
|
272
|
+
const advancedSection = getAdvancedBodySection(data);
|
|
273
|
+
const sections = [
|
|
274
|
+
{ id: 'model', fields: getInlineModelBodyFields(data) },
|
|
275
|
+
{ id: 'parameters', fields: getParameterBodyFields(data) },
|
|
276
|
+
{ id: 'provider', fields: getProviderBodyFields(data) },
|
|
277
|
+
...getInvocationSections(data),
|
|
278
|
+
advancedSection,
|
|
279
|
+
];
|
|
280
|
+
return sections.filter((section) => section.fields.length > 0 || section.snippet !== undefined);
|
|
281
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isChatV2PipelineProviderFailureResult } from './chatV2Pipeline.js';
|
|
2
|
+
import { cloneLLMChatV2EditorCacheOutputs } from './chatV2EditorCache.js';
|
|
3
|
+
/** Projects cache hits as current-run output without inventing provider work. */
|
|
4
|
+
export function projectLLMChatV2EditorCacheHit(runtime) {
|
|
5
|
+
const outputs = runtime.cachedOutputs;
|
|
6
|
+
if (outputs == null)
|
|
7
|
+
return undefined;
|
|
8
|
+
if (runtime.getProfileSummary != null) {
|
|
9
|
+
outputs['llmProfileSummary'] = {
|
|
10
|
+
type: 'string',
|
|
11
|
+
value: 'Editor cache hit — no LLM Profile calls were made for this run.',
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if (runtime.outputLLMAttempts) {
|
|
15
|
+
outputs['llmAttempts'] = { type: 'object[]', value: [] };
|
|
16
|
+
}
|
|
17
|
+
return outputs;
|
|
18
|
+
}
|
|
19
|
+
/** Caches only final model answers; failed invocations never reach this boundary. */
|
|
20
|
+
export function writeLLMChatV2EditorCache(params) {
|
|
21
|
+
const { runtime, result } = params;
|
|
22
|
+
if (runtime.cacheKey == null ||
|
|
23
|
+
runtime.editorCache == null ||
|
|
24
|
+
runtime.isProfileFallbackExhausted() ||
|
|
25
|
+
isChatV2PipelineProviderFailureResult(result)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const cacheOutputs = cloneLLMChatV2EditorCacheOutputs(result.commonOutputs);
|
|
29
|
+
delete cacheOutputs['llmAttempts'];
|
|
30
|
+
delete cacheOutputs['llmProfileSummary'];
|
|
31
|
+
runtime.editorCache.set(runtime.cacheKey, cacheOutputs);
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Editor-cache replay is safe only for ordinary deterministic model calls.
|
|
3
|
+
* Tool-capable calls can have side effects or live Delegate run shapes that a
|
|
4
|
+
* cached final output cannot reproduce.
|
|
5
|
+
*/
|
|
6
|
+
export function getLLMChatV2EditorCacheEligibility(data) {
|
|
7
|
+
if (!data.cache) {
|
|
8
|
+
return { eligible: false, reason: 'disabled' };
|
|
9
|
+
}
|
|
10
|
+
if (data.useToolCalling) {
|
|
11
|
+
return { eligible: false, reason: 'rivet-tools' };
|
|
12
|
+
}
|
|
13
|
+
if (data.enableOpenAIWebSearch ||
|
|
14
|
+
data.enableOpenAICodeInterpreter ||
|
|
15
|
+
data.enableGoogleSearchGrounding ||
|
|
16
|
+
data.enableGoogleUrlContext) {
|
|
17
|
+
return { eligible: false, reason: 'provider-native-tools' };
|
|
18
|
+
}
|
|
19
|
+
return { eligible: true };
|
|
20
|
+
}
|
|
@@ -1,53 +1,8 @@
|
|
|
1
1
|
import { createChatV2CommonNodeData } from './chatV2Shared.js';
|
|
2
2
|
import { DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS, DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES, } from './chatV2Retry.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
'temperature',
|
|
7
|
-
'useTemperatureInput',
|
|
8
|
-
'topP',
|
|
9
|
-
'useTopPInput',
|
|
10
|
-
'topK',
|
|
11
|
-
'useTopKInput',
|
|
12
|
-
'presencePenalty',
|
|
13
|
-
'usePresencePenaltyInput',
|
|
14
|
-
'frequencyPenalty',
|
|
15
|
-
'useFrequencyPenaltyInput',
|
|
16
|
-
'stopSequences',
|
|
17
|
-
'useStopSequencesInput',
|
|
18
|
-
'seed',
|
|
19
|
-
'useSeedInput',
|
|
20
|
-
'maxTokens',
|
|
21
|
-
'useMaxTokensInput',
|
|
22
|
-
'provider',
|
|
23
|
-
'apiKeySource',
|
|
24
|
-
'customProviderApiKeyProgrammaticName',
|
|
25
|
-
'customProviderApiKeyEnvVarName',
|
|
26
|
-
'customProviderBaseURL',
|
|
27
|
-
'useCustomProviderBaseURLInput',
|
|
28
|
-
'headers',
|
|
29
|
-
'useHeadersInput',
|
|
30
|
-
'extraProviderOptions',
|
|
31
|
-
'useExtraProviderOptionsInput',
|
|
32
|
-
'openAIReasoningEffort',
|
|
33
|
-
'openAIReasoningSummary',
|
|
34
|
-
'openAIPreviousResponseId',
|
|
35
|
-
'useOpenAIPreviousResponseIdInput',
|
|
36
|
-
'enableOpenAIWebSearch',
|
|
37
|
-
'openAIWebSearchContextSize',
|
|
38
|
-
'enableOpenAICodeInterpreter',
|
|
39
|
-
'anthropicThinkingMode',
|
|
40
|
-
'anthropicThinkingBudget',
|
|
41
|
-
'useAnthropicThinkingBudgetInput',
|
|
42
|
-
'anthropicEffort',
|
|
43
|
-
'anthropicCacheControlTtl',
|
|
44
|
-
'googleThinkingBudget',
|
|
45
|
-
'useGoogleThinkingBudgetInput',
|
|
46
|
-
'googleThinkingLevel',
|
|
47
|
-
'googleIncludeThoughts',
|
|
48
|
-
'enableGoogleSearchGrounding',
|
|
49
|
-
'enableGoogleUrlContext',
|
|
50
|
-
];
|
|
3
|
+
import { llmProfileDataKeys } from './llmProfileFieldRegistry.js';
|
|
4
|
+
/** @deprecated Use llmProfileDataKeys from llmProfileFieldRegistry instead. */
|
|
5
|
+
export const llmChatV2ProfileDataKeys = llmProfileDataKeys;
|
|
51
6
|
export function createLLMChatV2NodeData() {
|
|
52
7
|
return {
|
|
53
8
|
...createChatV2CommonNodeData({
|
|
@@ -60,6 +15,7 @@ export function createLLMChatV2NodeData() {
|
|
|
60
15
|
customProviderApiKeyEnvVarName: 'CUSTOM_PROVIDER_API_KEY',
|
|
61
16
|
customProviderBaseURL: '',
|
|
62
17
|
useCustomProviderBaseURLInput: false,
|
|
18
|
+
customProviderApi: 'completions',
|
|
63
19
|
baseURL: '',
|
|
64
20
|
useBaseURLInput: false,
|
|
65
21
|
headers: [],
|
|
@@ -97,13 +53,11 @@ export function createLLMChatV2NodeData() {
|
|
|
97
53
|
retryOnNon200: false,
|
|
98
54
|
retryOnNon200RepeatTimes: DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_REPEAT_TIMES,
|
|
99
55
|
retryOnNon200CooldownMs: DEFAULT_LLM_CHAT_V2_RETRY_ON_NON_200_COOLDOWN_MS,
|
|
100
|
-
|
|
56
|
+
outputLLMAttempts: false,
|
|
57
|
+
outputRequestBody: false,
|
|
58
|
+
outputResponseBody: false,
|
|
101
59
|
};
|
|
102
60
|
}
|
|
103
|
-
export function hasLLMChatV2BuiltInToolsEnabled(data) {
|
|
104
|
-
return ((data.provider === 'openai' && (data.enableOpenAIWebSearch || data.enableOpenAICodeInterpreter)) ||
|
|
105
|
-
(data.provider === 'google' && (data.enableGoogleSearchGrounding || data.enableGoogleUrlContext)));
|
|
106
|
-
}
|
|
107
61
|
export function shouldIncludeLLMChatV2ToolCalls(data) {
|
|
108
|
-
return data.
|
|
62
|
+
return data.useToolCalling;
|
|
109
63
|
}
|