@alpic80/rivet-core 1.19.1-aidon.3 → 1.24.0-aidon.1
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/README.md +4 -0
- package/dist/cjs/bundle.cjs +3993 -943
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/esm/api/createProcessor.js +8 -17
- package/dist/esm/api/looseDataValue.js +16 -0
- package/dist/esm/exports.js +2 -0
- package/dist/esm/integrations/CodeRunner.js +36 -0
- package/dist/esm/integrations/GptTokenizerTokenizer.js +7 -4
- package/dist/esm/integrations/openai/OpenAIEmbeddingGenerator.js +1 -1
- package/dist/esm/model/DataValue.js +14 -2
- package/dist/esm/model/GraphProcessor.js +275 -104
- package/dist/esm/model/NodeBase.js +11 -1
- package/dist/esm/model/NodeImpl.js +8 -0
- package/dist/esm/model/Nodes.js +28 -4
- package/dist/esm/model/ProjectReferenceLoader.js +1 -0
- package/dist/esm/model/nodes/AssembleMessageNode.js +12 -2
- package/dist/esm/model/nodes/AssemblePromptNode.js +22 -0
- package/dist/esm/model/nodes/CallGraphNode.js +3 -4
- package/dist/esm/model/nodes/ChatLoopNode.js +150 -0
- package/dist/esm/model/nodes/ChatNode.js +7 -934
- package/dist/esm/model/nodes/ChatNodeBase.js +1275 -0
- package/dist/esm/model/nodes/ChunkNode.js +2 -2
- package/dist/esm/model/nodes/CodeNode.js +40 -4
- package/dist/esm/model/nodes/CronNode.js +248 -0
- package/dist/esm/model/nodes/DelegateFunctionCallNode.js +37 -12
- package/dist/esm/model/nodes/DestructureNode.js +1 -1
- package/dist/esm/model/nodes/DocumentNode.js +183 -0
- package/dist/esm/model/nodes/ExtractJsonNode.js +4 -4
- package/dist/esm/model/nodes/ExtractRegexNode.js +10 -11
- package/dist/esm/model/nodes/GetEmbeddingNode.js +1 -1
- package/dist/esm/model/nodes/HttpCallNode.js +3 -1
- package/dist/esm/model/nodes/IfNode.js +5 -0
- package/dist/esm/model/nodes/LoopUntilNode.js +214 -0
- package/dist/esm/model/nodes/PromptNode.js +29 -6
- package/dist/esm/model/nodes/ReadAllFilesNode.js +210 -0
- package/dist/esm/model/nodes/ReadDirectoryNode.js +31 -25
- package/dist/esm/model/nodes/ReferencedGraphAliasNode.js +199 -0
- package/dist/esm/model/nodes/TextNode.js +9 -4
- package/dist/esm/model/nodes/ToMarkdownTableNode.js +119 -0
- package/dist/esm/model/nodes/ToTreeNode.js +133 -0
- package/dist/esm/model/nodes/{GptFunctionNode.js → ToolNode.js} +10 -10
- package/dist/esm/model/nodes/UserInputNode.js +10 -12
- package/dist/esm/plugins/aidon/nodes/ChatAidonNode.js +2 -2
- package/dist/esm/plugins/anthropic/anthropic.js +29 -10
- package/dist/esm/plugins/anthropic/fetchEventSource.js +3 -2
- package/dist/esm/plugins/anthropic/nodes/ChatAnthropicNode.js +267 -147
- package/dist/esm/plugins/anthropic/plugin.js +9 -1
- package/dist/esm/plugins/gentrace/plugin.js +6 -6
- package/dist/esm/plugins/google/google.js +113 -5
- package/dist/esm/plugins/google/nodes/ChatGoogleNode.js +211 -54
- package/dist/esm/plugins/google/plugin.js +13 -6
- package/dist/esm/plugins/openai/nodes/RunThreadNode.js +2 -2
- package/dist/esm/recording/ExecutionRecorder.js +5 -1
- package/dist/esm/utils/chatMessageToOpenAIChatCompletionMessage.js +15 -2
- package/dist/esm/utils/coerceType.js +1 -1
- package/dist/esm/utils/fetchEventSource.js +1 -1
- package/dist/esm/utils/interpolation.js +108 -3
- package/dist/esm/utils/openai.js +106 -50
- package/dist/esm/utils/paths.js +80 -0
- package/dist/esm/utils/serialization/serialization_v4.js +5 -0
- package/dist/types/api/createProcessor.d.ts +11 -5
- package/dist/types/api/looseDataValue.d.ts +4 -0
- package/dist/types/api/streaming.d.ts +1 -1
- package/dist/types/exports.d.ts +2 -0
- package/dist/types/integrations/CodeRunner.d.ts +18 -0
- package/dist/types/model/DataValue.d.ts +29 -6
- package/dist/types/model/EditorDefinition.d.ts +6 -1
- package/dist/types/model/GraphProcessor.d.ts +14 -7
- package/dist/types/model/NodeBase.d.ts +4 -0
- package/dist/types/model/NodeImpl.d.ts +5 -4
- package/dist/types/model/Nodes.d.ts +12 -4
- package/dist/types/model/ProcessContext.d.ts +16 -1
- package/dist/types/model/Project.d.ts +19 -7
- package/dist/types/model/ProjectReferenceLoader.d.ts +5 -0
- package/dist/types/model/RivetPlugin.d.ts +6 -0
- package/dist/types/model/RivetUIContext.d.ts +5 -1
- package/dist/types/model/Settings.d.ts +1 -0
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +4 -1
- package/dist/types/model/nodes/ChatLoopNode.d.ts +21 -0
- package/dist/types/model/nodes/ChatNode.d.ts +2 -62
- package/dist/types/model/nodes/ChatNodeBase.d.ts +85 -0
- package/dist/types/model/nodes/CodeNode.d.ts +8 -2
- package/dist/types/model/nodes/CronNode.d.ts +34 -0
- package/dist/types/model/nodes/DelegateFunctionCallNode.d.ts +1 -0
- package/dist/types/model/nodes/DocumentNode.d.ts +28 -0
- package/dist/types/model/nodes/LoopUntilNode.d.ts +32 -0
- package/dist/types/model/nodes/PromptNode.d.ts +2 -0
- package/dist/types/model/nodes/ReadAllFilesNode.d.ts +30 -0
- package/dist/types/model/nodes/ReadDirectoryNode.d.ts +1 -1
- package/dist/types/model/nodes/ReferencedGraphAliasNode.d.ts +31 -0
- package/dist/types/model/nodes/ToMarkdownTableNode.d.ts +19 -0
- package/dist/types/model/nodes/ToTreeNode.d.ts +21 -0
- package/dist/types/model/nodes/UserInputNode.d.ts +2 -3
- package/dist/types/plugins/anthropic/anthropic.d.ts +94 -13
- package/dist/types/plugins/anthropic/nodes/ChatAnthropicNode.d.ts +7 -2
- package/dist/types/plugins/google/google.d.ts +93 -18
- package/dist/types/plugins/google/nodes/ChatGoogleNode.d.ts +3 -2
- package/dist/types/recording/RecordedEvents.d.ts +2 -0
- package/dist/types/utils/base64.d.ts +1 -1
- package/dist/types/utils/chatMessageToOpenAIChatCompletionMessage.d.ts +3 -1
- package/dist/types/utils/interpolation.d.ts +3 -0
- package/dist/types/utils/openai.d.ts +127 -21
- package/dist/types/utils/paths.d.ts +8 -0
- package/package.json +15 -11
- /package/dist/types/model/nodes/{GptFunctionNode.d.ts → ToolNode.d.ts} +0 -0
|
@@ -5,6 +5,7 @@ import {} from '../../index.js';
|
|
|
5
5
|
import { dedent } from 'ts-dedent';
|
|
6
6
|
import { nodeDefinition } from '../NodeDefinition.js';
|
|
7
7
|
import { coerceType } from '../../utils/coerceType.js';
|
|
8
|
+
import {} from '../ProcessContext.js';
|
|
8
9
|
export class UserInputNodeImpl extends NodeImpl {
|
|
9
10
|
static create() {
|
|
10
11
|
const chartNode = {
|
|
@@ -89,21 +90,18 @@ export class UserInputNodeImpl extends NodeImpl {
|
|
|
89
90
|
group: ['Input/Output'],
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
|
-
async process() {
|
|
93
|
+
async process(inputs, context) {
|
|
94
|
+
const questions = this.data.useInput ? coerceType(inputs['questions'], 'string[]') : [this.data.prompt];
|
|
95
|
+
const renderingFormat = this.data.renderingFormat === 'preformatted' ? 'text' : 'markdown';
|
|
96
|
+
const response = await context.requestUserInput(questions, renderingFormat);
|
|
93
97
|
return {
|
|
94
|
-
['output']:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
getOutputValuesFromUserInput(questions, answers) {
|
|
99
|
-
const questionsList = this.data.useInput
|
|
100
|
-
? coerceType(questions['questions'], 'string[]')
|
|
101
|
-
: [this.data.prompt];
|
|
102
|
-
return {
|
|
103
|
-
['output']: answers,
|
|
98
|
+
['output']: {
|
|
99
|
+
type: 'string[]',
|
|
100
|
+
value: response.value,
|
|
101
|
+
},
|
|
104
102
|
['questionsAndAnswers']: {
|
|
105
103
|
type: 'string[]',
|
|
106
|
-
value: zip(
|
|
104
|
+
value: zip(questions, response.value).map(([q, a]) => `${q}\n${a}`),
|
|
107
105
|
},
|
|
108
106
|
};
|
|
109
107
|
}
|
|
@@ -84,7 +84,7 @@ class ChatAidonNodeImpl extends ChatNodeImpl {
|
|
|
84
84
|
const customHeaders = schemaDetail.headers; // Moved this line up to the loop
|
|
85
85
|
// Check if custom headers are set and are of type string
|
|
86
86
|
if (customHeaders && typeof customHeaders === "string") {
|
|
87
|
-
|
|
87
|
+
const parsedCustomHeaders = JSON.parse(customHeaders);
|
|
88
88
|
headers = {
|
|
89
89
|
...headers,
|
|
90
90
|
...parsedCustomHeaders
|
|
@@ -129,7 +129,7 @@ class ChatAidonNodeImpl extends ChatNodeImpl {
|
|
|
129
129
|
//call the tool(s) to get the results to add to the message
|
|
130
130
|
for (const functionCall of functionCalls) {
|
|
131
131
|
// Find the schema detail that contains the function name
|
|
132
|
-
const toolSchema = toolSchemas.find(detail => detail.name
|
|
132
|
+
const toolSchema = toolSchemas.find(detail => detail.name === functionCall.name);
|
|
133
133
|
if (!toolSchema) {
|
|
134
134
|
throw new Error(`Function ${functionCall.name} not found in any schema`);
|
|
135
135
|
}
|
|
@@ -56,7 +56,7 @@ export const anthropicModels = {
|
|
|
56
56
|
},
|
|
57
57
|
displayName: 'Claude 3 Opus',
|
|
58
58
|
},
|
|
59
|
-
'claude-3-5-sonnet-
|
|
59
|
+
'claude-3-5-sonnet-latest': {
|
|
60
60
|
maxTokens: 200_000,
|
|
61
61
|
cost: {
|
|
62
62
|
prompt: 3e-6,
|
|
@@ -64,19 +64,36 @@ export const anthropicModels = {
|
|
|
64
64
|
},
|
|
65
65
|
displayName: 'Claude 3.5 Sonnet',
|
|
66
66
|
},
|
|
67
|
+
'claude-3-5-haiku-latest': {
|
|
68
|
+
maxTokens: 200_000,
|
|
69
|
+
cost: {
|
|
70
|
+
prompt: 0.8e-6,
|
|
71
|
+
completion: 4e-6,
|
|
72
|
+
},
|
|
73
|
+
displayName: 'Claude 3.5 Haiku',
|
|
74
|
+
},
|
|
75
|
+
'claude-3-7-sonnet-latest': {
|
|
76
|
+
maxTokens: 200_000,
|
|
77
|
+
cost: {
|
|
78
|
+
prompt: 3e-6,
|
|
79
|
+
completion: 15e-6,
|
|
80
|
+
},
|
|
81
|
+
displayName: 'Claude 3.7 Sonnet',
|
|
82
|
+
},
|
|
67
83
|
};
|
|
68
84
|
export const anthropicModelOptions = Object.entries(anthropicModels).map(([id, { displayName }]) => ({
|
|
69
85
|
value: id,
|
|
70
86
|
label: displayName,
|
|
71
87
|
}));
|
|
72
|
-
export async function* streamChatCompletions({ apiKey, signal, ...rest }) {
|
|
88
|
+
export async function* streamChatCompletions({ apiEndpoint, apiKey, signal, ...rest }) {
|
|
73
89
|
const defaultSignal = new AbortController().signal;
|
|
74
|
-
const response = await fetchEventSource(
|
|
90
|
+
const response = await fetchEventSource(`${apiEndpoint}/completions`, {
|
|
75
91
|
method: 'POST',
|
|
76
92
|
headers: {
|
|
77
93
|
'Content-Type': 'application/json',
|
|
78
94
|
'x-api-key': apiKey,
|
|
79
95
|
'anthropic-version': '2023-06-01',
|
|
96
|
+
'anthropic-dangerous-direct-browser-access': 'true',
|
|
80
97
|
},
|
|
81
98
|
body: JSON.stringify({
|
|
82
99
|
...rest,
|
|
@@ -110,15 +127,16 @@ export async function* streamChatCompletions({ apiKey, signal, ...rest }) {
|
|
|
110
127
|
throw new AnthropicError(`No chunks received. Response: ${JSON.stringify(responseJson)}`, response, responseJson);
|
|
111
128
|
}
|
|
112
129
|
}
|
|
113
|
-
export async function callMessageApi({ apiKey, signal, tools, ...rest }) {
|
|
130
|
+
export async function callMessageApi({ apiEndpoint, apiKey, signal, tools, beta, ...rest }) {
|
|
114
131
|
const defaultSignal = new AbortController().signal;
|
|
115
|
-
const response = await fetch(
|
|
132
|
+
const response = await fetch(`${apiEndpoint}/messages`, {
|
|
116
133
|
method: 'POST',
|
|
117
134
|
headers: {
|
|
118
135
|
'Content-Type': 'application/json',
|
|
119
136
|
'x-api-key': apiKey,
|
|
120
137
|
'anthropic-version': '2023-06-01',
|
|
121
|
-
'anthropic-
|
|
138
|
+
'anthropic-dangerous-direct-browser-access': 'true',
|
|
139
|
+
...(beta ? { 'anthropic-beta': beta } : {}),
|
|
122
140
|
},
|
|
123
141
|
body: JSON.stringify({
|
|
124
142
|
...rest,
|
|
@@ -133,16 +151,17 @@ export async function callMessageApi({ apiKey, signal, tools, ...rest }) {
|
|
|
133
151
|
}
|
|
134
152
|
return responseJson;
|
|
135
153
|
}
|
|
136
|
-
export async function* streamMessageApi({ apiKey, signal, ...rest }) {
|
|
154
|
+
export async function* streamMessageApi({ apiEndpoint, apiKey, signal, beta, ...rest }) {
|
|
137
155
|
// Use the Messages API for Claude 3 models
|
|
138
156
|
const defaultSignal = new AbortController().signal;
|
|
139
|
-
const response = await fetchEventSource(
|
|
157
|
+
const response = await fetchEventSource(`${apiEndpoint}/messages`, {
|
|
140
158
|
method: 'POST',
|
|
141
159
|
headers: {
|
|
142
160
|
'Content-Type': 'application/json',
|
|
143
161
|
'x-api-key': apiKey,
|
|
144
162
|
'anthropic-version': '2023-06-01',
|
|
145
|
-
'anthropic-
|
|
163
|
+
'anthropic-dangerous-direct-browser-access': 'true',
|
|
164
|
+
...(beta ? { 'anthropic-beta': beta } : {}),
|
|
146
165
|
},
|
|
147
166
|
body: JSON.stringify({
|
|
148
167
|
...rest,
|
|
@@ -157,7 +176,7 @@ export async function* streamMessageApi({ apiKey, signal, ...rest }) {
|
|
|
157
176
|
if (chunk === '[message_stop]') {
|
|
158
177
|
return;
|
|
159
178
|
}
|
|
160
|
-
else if (
|
|
179
|
+
else if (/^\[\w+\]$/.test(chunk)) {
|
|
161
180
|
nextDataType = chunk.slice(1, -1);
|
|
162
181
|
continue;
|
|
163
182
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_CHAT_NODE_TIMEOUT } from '../../utils/defaults.js';
|
|
1
2
|
// https://github.com/openai/openai-node/issues/18#issuecomment-1518715285
|
|
2
3
|
export class EventSourceResponse extends Response {
|
|
3
4
|
name;
|
|
@@ -24,7 +25,7 @@ export class EventSourceResponse extends Response {
|
|
|
24
25
|
const reader = this.streams.eventStream.getReader();
|
|
25
26
|
try {
|
|
26
27
|
while (true) {
|
|
27
|
-
const { done, value } = await this.raceWithTimeout(reader.read());
|
|
28
|
+
const { done, value } = await this.raceWithTimeout(reader.read(), DEFAULT_CHAT_NODE_TIMEOUT);
|
|
28
29
|
if (done) {
|
|
29
30
|
break;
|
|
30
31
|
}
|
|
@@ -36,7 +37,7 @@ export class EventSourceResponse extends Response {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
async raceWithTimeout(promise, timeout = 5000) {
|
|
39
|
-
// eslint-disable-next-line no-async-promise-executor -- Error handled correctly
|
|
40
|
+
// eslint-disable-next-line no-async-promise-executor,@typescript-eslint/no-misused-promises -- Error handled correctly
|
|
40
41
|
return new Promise(async (resolve, reject) => {
|
|
41
42
|
const timer = setTimeout(() => {
|
|
42
43
|
reject(new Error('Timeout: API response took too long.'));
|