@valerypopoff/rivet2-core 2.1.5 → 2.1.7
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 +3198 -296
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +129 -4
- package/dist/cjs/webAppRuntime.cjs.map +2 -2
- package/dist/esm/api/createProcessor.js +1 -0
- package/dist/esm/exports.js +4 -0
- package/dist/esm/integrations/KnowledgeStore.js +1 -0
- package/dist/esm/integrations/KnowledgeStoreProvider.js +292 -0
- package/dist/esm/integrations/KnowledgeStoreValidation.js +428 -0
- package/dist/esm/integrations/ManagedKnowledgeStore.js +539 -0
- package/dist/esm/model/DataValue.js +22 -2
- package/dist/esm/model/GraphProcessor.js +14 -0
- package/dist/esm/model/Nodes.js +18 -0
- package/dist/esm/model/UiGraph.js +2 -2
- package/dist/esm/model/UiGraphBrowserRuntime.js +112 -1
- package/dist/esm/model/UiGraphRendererStyles.js +111 -9
- package/dist/esm/model/UiGraphRuntimeModel.js +26 -2
- package/dist/esm/model/chat/openAIChatRequest.js +8 -2
- package/dist/esm/model/chat-v2/chatV2RuntimeOptions.js +8 -8
- package/dist/esm/model/chat-v2/llmChatV2NodeEditors.js +3 -1
- package/dist/esm/model/chat-v2/parallelToolCalls.js +38 -0
- package/dist/esm/model/chat-v2/toolContinuation.js +39 -0
- package/dist/esm/model/nodes/BuildKnowledgeContextNode.js +157 -0
- package/dist/esm/model/nodes/GetKnowledgeSourceStatusNode.js +79 -0
- package/dist/esm/model/nodes/KnowledgeDocumentNode.js +88 -0
- package/dist/esm/model/nodes/KnowledgeSourceNode.js +94 -0
- package/dist/esm/model/nodes/PassthroughNode.js +36 -8
- package/dist/esm/model/nodes/SearchKnowledgeNode.js +127 -0
- package/dist/esm/model/nodes/StoredValueNodeUtils.js +10 -0
- package/dist/esm/model/nodes/SyncKnowledgeSourceNode.js +149 -0
- package/dist/esm/model/nodes/ToolNode.js +14 -0
- package/dist/esm/plugins/pinecone/PineconeKnowledgeStore.js +553 -0
- package/dist/esm/plugins/pinecone/plugin.js +32 -0
- package/dist/esm/utils/coerceType.js +24 -2
- package/dist/esm/utils/getPluginConfig.js +12 -6
- package/dist/esm/utils/serialization/serialization.js +4 -1
- package/dist/esm/utils/serialization/serializationUtils.js +59 -1
- package/dist/esm/webAppRuntime.js +1 -1
- package/dist/types/api/createProcessor.d.ts +2 -0
- package/dist/types/exports.d.ts +4 -0
- package/dist/types/integrations/KnowledgeStore.d.ts +131 -0
- package/dist/types/integrations/KnowledgeStoreProvider.d.ts +46 -0
- package/dist/types/integrations/KnowledgeStoreValidation.d.ts +16 -0
- package/dist/types/integrations/ManagedKnowledgeStore.d.ts +57 -0
- package/dist/types/model/DataValue.d.ts +10 -3
- package/dist/types/model/EditorDefinition.d.ts +7 -1
- package/dist/types/model/GraphProcessor.d.ts +2 -0
- package/dist/types/model/Nodes.d.ts +8 -2
- package/dist/types/model/ProcessContext.d.ts +3 -0
- package/dist/types/model/Project.d.ts +11 -0
- package/dist/types/model/UiGraph.d.ts +3 -1
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +25 -1
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/chat-v2/parallelToolCalls.d.ts +9 -0
- package/dist/types/model/nodes/BuildKnowledgeContextNode.d.ts +23 -0
- package/dist/types/model/nodes/GetKnowledgeSourceStatusNode.d.ts +19 -0
- package/dist/types/model/nodes/KnowledgeDocumentNode.d.ts +26 -0
- package/dist/types/model/nodes/KnowledgeSourceNode.d.ts +25 -0
- package/dist/types/model/nodes/PassthroughNode.d.ts +15 -1
- package/dist/types/model/nodes/SearchKnowledgeNode.d.ts +25 -0
- package/dist/types/model/nodes/StoredValueNodeUtils.d.ts +1 -1
- package/dist/types/model/nodes/SyncKnowledgeSourceNode.d.ts +27 -0
- package/dist/types/model/nodes/ToolNode.d.ts +2 -0
- package/dist/types/plugins/pinecone/PineconeKnowledgeStore.d.ts +11 -0
- package/dist/types/utils/serialization/serializationUtils.d.ts +4 -0
- package/dist/types/webAppRuntime.d.ts +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { nanoid } from 'nanoid/non-secure';
|
|
2
|
+
import { dedent } from 'ts-dedent';
|
|
3
|
+
import { nodeDefinition } from '../NodeDefinition.js';
|
|
4
|
+
import { NodeImpl } from '../NodeImpl.js';
|
|
5
|
+
import { coerceType } from '../../utils/coerceType.js';
|
|
6
|
+
import { normalizeKnowledgeDocument, normalizeKnowledgeMetadata, normalizeKnowledgeSourceReference, normalizeSyncKnowledgeSourceResult, } from '../../integrations/KnowledgeStoreValidation.js';
|
|
7
|
+
export class SyncKnowledgeSourceNodeImpl extends NodeImpl {
|
|
8
|
+
static create() {
|
|
9
|
+
return {
|
|
10
|
+
id: nanoid(),
|
|
11
|
+
type: 'syncKnowledgeSource',
|
|
12
|
+
title: 'Sync Knowledge Source',
|
|
13
|
+
visualData: { x: 0, y: 0, width: 290 },
|
|
14
|
+
data: {
|
|
15
|
+
metadata: {},
|
|
16
|
+
useMetadataInput: false,
|
|
17
|
+
forceRefresh: false,
|
|
18
|
+
useForceRefreshInput: false,
|
|
19
|
+
chunkUnit: 'characters',
|
|
20
|
+
targetSize: 2600,
|
|
21
|
+
overlap: 260,
|
|
22
|
+
minimumBoundarySize: 1400,
|
|
23
|
+
includeTitle: true,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
getInputDefinitions() {
|
|
28
|
+
const inputs = [
|
|
29
|
+
{ id: 'source', title: 'Source', dataType: 'knowledge-source', required: true },
|
|
30
|
+
{
|
|
31
|
+
id: 'documents',
|
|
32
|
+
title: 'Documents',
|
|
33
|
+
dataType: ['string', 'string[]', 'knowledge-document', 'knowledge-document[]'],
|
|
34
|
+
required: true,
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
if (this.data.useMetadataInput)
|
|
38
|
+
inputs.push({ id: 'metadata', title: 'Source Metadata', dataType: 'object' });
|
|
39
|
+
if (this.data.useForceRefreshInput)
|
|
40
|
+
inputs.push({ id: 'force-refresh', title: 'Force Refresh', dataType: 'boolean' });
|
|
41
|
+
return inputs;
|
|
42
|
+
}
|
|
43
|
+
getOutputDefinitions() {
|
|
44
|
+
return [
|
|
45
|
+
{ id: 'source', title: 'Resolved Source', dataType: 'knowledge-source' },
|
|
46
|
+
{ id: 'result', title: 'Result', dataType: 'string' },
|
|
47
|
+
{ id: 'document-count', title: 'Document Count', dataType: 'number' },
|
|
48
|
+
{ id: 'chunk-count', title: 'Chunk Count', dataType: 'number' },
|
|
49
|
+
{ id: 'previous-version', title: 'Previous Version', dataType: 'string' },
|
|
50
|
+
{ id: 'warnings', title: 'Warnings', dataType: 'string[]' },
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
getEditors() {
|
|
54
|
+
return [
|
|
55
|
+
{
|
|
56
|
+
type: 'jsonObject',
|
|
57
|
+
dataKey: 'metadata',
|
|
58
|
+
useInputToggleDataKey: 'useMetadataInput',
|
|
59
|
+
label: 'Source Metadata',
|
|
60
|
+
helperMessage: 'Enter a flat JSON object, or leave {} when the source has no metadata.',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'toggle',
|
|
64
|
+
dataKey: 'forceRefresh',
|
|
65
|
+
useInputToggleDataKey: 'useForceRefreshInput',
|
|
66
|
+
label: 'Force Refresh',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'dropdown',
|
|
70
|
+
dataKey: 'chunkUnit',
|
|
71
|
+
label: 'Chunk Size Unit',
|
|
72
|
+
options: [
|
|
73
|
+
{ value: 'characters', label: 'Characters' },
|
|
74
|
+
{ value: 'tokens', label: 'Tokens' },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{ type: 'number', dataKey: 'targetSize', label: 'Target Chunk Size', min: 100, max: 100000 },
|
|
78
|
+
{ type: 'number', dataKey: 'overlap', label: 'Chunk Overlap', min: 0, max: 99999 },
|
|
79
|
+
{ type: 'number', dataKey: 'minimumBoundarySize', label: 'Minimum Boundary Size', min: 1, max: 100000 },
|
|
80
|
+
{ type: 'toggle', dataKey: 'includeTitle', label: 'Include Title In Indexed Text' },
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
getBody() {
|
|
84
|
+
return dedent `
|
|
85
|
+
${this.data.targetSize} ${this.data.chunkUnit}
|
|
86
|
+
${this.data.overlap} overlap
|
|
87
|
+
${this.data.includeTitle ? 'Includes titles' : 'Content only'}
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
static getUIData() {
|
|
91
|
+
return {
|
|
92
|
+
contextMenuTitle: 'Sync Knowledge Source',
|
|
93
|
+
infoBoxTitle: 'Sync Knowledge Source Node',
|
|
94
|
+
infoBoxBody: 'Idempotently chunks and activates a complete immutable version of a knowledge source.',
|
|
95
|
+
group: 'Knowledge',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async process(inputs, context) {
|
|
99
|
+
const source = normalizeKnowledgeSourceReference(coerceType(inputs['source'], 'knowledge-source'));
|
|
100
|
+
const documents = normalizeDocumentsInput(inputs['documents']);
|
|
101
|
+
const metadataRaw = this.data.useMetadataInput
|
|
102
|
+
? coerceType(inputs['metadata'], 'object')
|
|
103
|
+
: this.data.metadata;
|
|
104
|
+
const metadata = normalizeKnowledgeMetadata(metadataRaw, 'Source metadata');
|
|
105
|
+
const forceRefresh = this.data.useForceRefreshInput
|
|
106
|
+
? coerceType(inputs['force-refresh'], 'boolean')
|
|
107
|
+
: this.data.forceRefresh;
|
|
108
|
+
const store = await context.getKnowledgeStore(source.connectionId);
|
|
109
|
+
const result = normalizeSyncKnowledgeSourceResult(await store.syncSource({
|
|
110
|
+
source,
|
|
111
|
+
documents,
|
|
112
|
+
metadata,
|
|
113
|
+
forceRefresh,
|
|
114
|
+
chunking: {
|
|
115
|
+
unit: this.data.chunkUnit,
|
|
116
|
+
targetSize: this.data.targetSize,
|
|
117
|
+
overlap: this.data.overlap,
|
|
118
|
+
minimumBoundarySize: this.data.minimumBoundarySize,
|
|
119
|
+
includeTitle: this.data.includeTitle,
|
|
120
|
+
},
|
|
121
|
+
}, {
|
|
122
|
+
signal: context.signal,
|
|
123
|
+
reportProgress: context.reportProgress,
|
|
124
|
+
getTokenCount: (text) => context.tokenizer.getTokenCountForString(text, { node: context.node }),
|
|
125
|
+
}), source);
|
|
126
|
+
return {
|
|
127
|
+
['source']: { type: 'knowledge-source', value: result.source },
|
|
128
|
+
['result']: { type: 'string', value: result.result },
|
|
129
|
+
['document-count']: { type: 'number', value: result.documentCount },
|
|
130
|
+
['chunk-count']: { type: 'number', value: result.chunkCount },
|
|
131
|
+
['previous-version']: { type: 'string', value: result.previousVersion ?? '' },
|
|
132
|
+
['warnings']: { type: 'string[]', value: result.warnings },
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function normalizeDocumentsInput(value) {
|
|
137
|
+
if (!value)
|
|
138
|
+
throw new Error('Sync Knowledge Source is missing its Documents input.');
|
|
139
|
+
if (value.type === 'string')
|
|
140
|
+
return [normalizeKnowledgeDocument(value.value, 0)];
|
|
141
|
+
if (value.type === 'string[]')
|
|
142
|
+
return value.value.map((document, index) => normalizeKnowledgeDocument(document, index));
|
|
143
|
+
if (value.type === 'knowledge-document')
|
|
144
|
+
return [normalizeKnowledgeDocument(value.value, 0)];
|
|
145
|
+
if (value.type === 'knowledge-document[]')
|
|
146
|
+
return value.value.map((document, index) => normalizeKnowledgeDocument(document, index));
|
|
147
|
+
throw new Error(`Sync Knowledge Source cannot use ${value.type} as Documents.`);
|
|
148
|
+
}
|
|
149
|
+
export const syncKnowledgeSourceNode = nodeDefinition(SyncKnowledgeSourceNodeImpl, 'Sync Knowledge Source');
|
|
@@ -24,6 +24,7 @@ export class GptFunctionNodeImpl extends NodeImpl {
|
|
|
24
24
|
data: {
|
|
25
25
|
name: 'newTool',
|
|
26
26
|
description: 'No description provided',
|
|
27
|
+
resultHandling: 'continue',
|
|
27
28
|
schema: dedent `
|
|
28
29
|
{
|
|
29
30
|
"type": "object",
|
|
@@ -105,6 +106,17 @@ export class GptFunctionNodeImpl extends NodeImpl {
|
|
|
105
106
|
theme: 'prompt-interpolation',
|
|
106
107
|
height: 100,
|
|
107
108
|
},
|
|
109
|
+
{
|
|
110
|
+
type: 'dropdown',
|
|
111
|
+
label: 'Result handling',
|
|
112
|
+
dataKey: 'resultHandling',
|
|
113
|
+
defaultValue: 'continue',
|
|
114
|
+
options: [
|
|
115
|
+
{ label: 'Continue with LLM', value: 'continue' },
|
|
116
|
+
{ label: 'Return directly', value: 'return-direct' },
|
|
117
|
+
],
|
|
118
|
+
helperMessage: 'Return directly uses the handler output as the final LLM Chat response when it is the only tool call in an auto-continued round.',
|
|
119
|
+
},
|
|
108
120
|
{
|
|
109
121
|
type: 'code',
|
|
110
122
|
label: 'Schema',
|
|
@@ -141,6 +153,7 @@ export class GptFunctionNodeImpl extends NodeImpl {
|
|
|
141
153
|
async process(inputs) {
|
|
142
154
|
const name = getInputOrData(this.data, inputs, 'name');
|
|
143
155
|
const description = getInputOrData(this.data, inputs, 'description');
|
|
156
|
+
const resultHandling = this.data.resultHandling === 'return-direct' ? 'return-direct' : 'continue';
|
|
144
157
|
let schema;
|
|
145
158
|
if (this.data.useSchemaInput) {
|
|
146
159
|
schema = coerceType(inputs['schema'], 'object');
|
|
@@ -165,6 +178,7 @@ export class GptFunctionNodeImpl extends NodeImpl {
|
|
|
165
178
|
description,
|
|
166
179
|
parameters: schema,
|
|
167
180
|
strict: this.data.strict ?? false,
|
|
181
|
+
resultHandling,
|
|
168
182
|
},
|
|
169
183
|
},
|
|
170
184
|
};
|