@valerypopoff/rivet2-cli 2.0.10 → 2.0.11
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/bin/commands/serve.js +27 -12
- package/dist/types/commands/serve.d.ts +13 -1
- package/package.json +2 -2
package/bin/commands/serve.js
CHANGED
|
@@ -147,13 +147,13 @@ function buildGraphRunArgs(args, project, inputs, graph) {
|
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
149
|
async function streamGraph({ project, inputs, graph, openaiApiKey, openaiEndpoint, openaiOrganization, stream, streamNode, }) {
|
|
150
|
-
const { run, processor, getSSEStream } = createProcessor(project, {
|
|
151
|
-
inputs,
|
|
150
|
+
const { run, processor, getSSEStream } = createProcessor(project, buildStreamingGraphProcessorOptions({
|
|
152
151
|
graph,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
inputs,
|
|
153
|
+
openaiApiKey,
|
|
154
|
+
openaiEndpoint,
|
|
155
|
+
openaiOrganization,
|
|
156
|
+
}));
|
|
157
157
|
const responseStream = streamNode
|
|
158
158
|
? getSingleNodeStream(processor, streamNode)
|
|
159
159
|
: getSSEStream(buildStreamEventFilter(stream));
|
|
@@ -162,6 +162,21 @@ async function streamGraph({ project, inputs, graph, openaiApiKey, openaiEndpoin
|
|
|
162
162
|
});
|
|
163
163
|
return responseStream;
|
|
164
164
|
}
|
|
165
|
+
export function buildGraphProcessorOptions({ inputs, graph, openaiApiKey, openaiEndpoint, openaiOrganization, }) {
|
|
166
|
+
return {
|
|
167
|
+
inputs,
|
|
168
|
+
graph,
|
|
169
|
+
openAiKey: openaiApiKey,
|
|
170
|
+
openAiEndpoint: openaiEndpoint,
|
|
171
|
+
openAiOrganization: openaiOrganization,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function buildStreamingGraphProcessorOptions(args) {
|
|
175
|
+
return {
|
|
176
|
+
...buildGraphProcessorOptions(args),
|
|
177
|
+
runtimeProfile: 'compatible',
|
|
178
|
+
};
|
|
179
|
+
}
|
|
165
180
|
export function buildStreamEventFilter(stream) {
|
|
166
181
|
const streamTarget = stream?.trim();
|
|
167
182
|
if (!streamTarget) {
|
|
@@ -178,13 +193,13 @@ export function buildStreamEventFilter(stream) {
|
|
|
178
193
|
};
|
|
179
194
|
}
|
|
180
195
|
async function runGraph({ project, inputs, graph, openaiApiKey, openaiEndpoint, openaiOrganization, exposeCost, }) {
|
|
181
|
-
const { run } = createProcessor(project, {
|
|
182
|
-
inputs,
|
|
196
|
+
const { run } = createProcessor(project, buildGraphProcessorOptions({
|
|
183
197
|
graph,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
inputs,
|
|
199
|
+
openaiApiKey,
|
|
200
|
+
openaiEndpoint,
|
|
201
|
+
openaiOrganization,
|
|
202
|
+
}));
|
|
188
203
|
const outputs = await run();
|
|
189
204
|
if (!exposeCost) {
|
|
190
205
|
delete outputs.cost;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RivetEventStreamFilterSpec } from '@valerypopoff/rivet2-node';
|
|
1
|
+
import type { LooseDataValue, NodeCreateProcessorOptions, Project, RivetEventStreamFilterSpec } from '@valerypopoff/rivet2-node';
|
|
2
2
|
import type * as yargs from 'yargs';
|
|
3
3
|
type ServeArgs = {
|
|
4
4
|
port: number;
|
|
@@ -13,6 +13,16 @@ type ServeArgs = {
|
|
|
13
13
|
stream: string | undefined;
|
|
14
14
|
streamNode: string | undefined;
|
|
15
15
|
};
|
|
16
|
+
type GraphRunArgs = {
|
|
17
|
+
exposeCost: boolean;
|
|
18
|
+
graph: string | undefined;
|
|
19
|
+
inputs: Record<string, LooseDataValue>;
|
|
20
|
+
openaiApiKey: string | undefined;
|
|
21
|
+
openaiEndpoint: string | undefined;
|
|
22
|
+
openaiOrganization: string | undefined;
|
|
23
|
+
project: Project;
|
|
24
|
+
};
|
|
25
|
+
type GraphProcessorArgs = Omit<GraphRunArgs, 'exposeCost' | 'project'>;
|
|
16
26
|
export declare function makeCommand<T>(y: yargs.Argv<T>): yargs.Argv<T & {
|
|
17
27
|
port: number;
|
|
18
28
|
} & {
|
|
@@ -37,5 +47,7 @@ export declare function makeCommand<T>(y: yargs.Argv<T>): yargs.Argv<T & {
|
|
|
37
47
|
projectFile: string | undefined;
|
|
38
48
|
}>;
|
|
39
49
|
export declare function serve(args: ServeArgs): Promise<void>;
|
|
50
|
+
export declare function buildGraphProcessorOptions({ inputs, graph, openaiApiKey, openaiEndpoint, openaiOrganization, }: GraphProcessorArgs): NodeCreateProcessorOptions;
|
|
51
|
+
export declare function buildStreamingGraphProcessorOptions(args: GraphProcessorArgs): NodeCreateProcessorOptions;
|
|
40
52
|
export declare function buildStreamEventFilter(stream: string | undefined): RivetEventStreamFilterSpec;
|
|
41
53
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valerypopoff/rivet2-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"types": "dist/types/cli.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@hono/node-server": "^1.13.8",
|
|
26
26
|
"@types/dotenv": "^8.2.3",
|
|
27
|
-
"@valerypopoff/rivet2-node": "^2.0.
|
|
27
|
+
"@valerypopoff/rivet2-node": "^2.0.11",
|
|
28
28
|
"chalk": "^5.4.1",
|
|
29
29
|
"didyoumean2": "^7.0.4",
|
|
30
30
|
"dotenv": "^16.4.7",
|