@dxos/react-ui-canvas-compute 0.8.3-main.7f5a14c → 0.8.3
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/lib/browser/index.mjs +16 -45
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +14 -43
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +16 -45
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +5 -14
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +4 -19
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/package.json +39 -39
- package/src/compute.stories.tsx +55 -17
- package/src/graph/controller.ts +17 -62
- package/src/shapes/GptRealtime.tsx +2 -2
- package/src/testing/circuits.ts +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-canvas-compute",
|
|
3
|
-
"version": "0.8.3
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "A compute graph extension for the canvas editor component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,34 +25,34 @@
|
|
|
25
25
|
"@effect/platform": "0.80.12",
|
|
26
26
|
"@preact-signals/safe-react": "^0.9.0",
|
|
27
27
|
"chess.js": "^1.0.0",
|
|
28
|
-
"@dxos/ai": "0.8.3
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/assistant": "0.8.3
|
|
31
|
-
"@dxos/async": "0.8.3
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/context": "0.8.3
|
|
35
|
-
"@dxos/debug": "0.8.3
|
|
36
|
-
"@dxos/echo-schema": "0.8.3
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/graph": "0.8.3
|
|
40
|
-
"@dxos/keys": "0.8.3
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-
|
|
45
|
-
"@dxos/react-edge-client": "0.8.3
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/react-ui-editor": "0.8.3
|
|
49
|
-
"@dxos/react-ui-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/react-ui-
|
|
53
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.3
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/
|
|
28
|
+
"@dxos/ai": "0.8.3",
|
|
29
|
+
"@dxos/artifact": "0.8.3",
|
|
30
|
+
"@dxos/assistant": "0.8.3",
|
|
31
|
+
"@dxos/async": "0.8.3",
|
|
32
|
+
"@dxos/app-framework": "0.8.3",
|
|
33
|
+
"@dxos/conductor": "0.8.3",
|
|
34
|
+
"@dxos/context": "0.8.3",
|
|
35
|
+
"@dxos/debug": "0.8.3",
|
|
36
|
+
"@dxos/echo-schema": "0.8.3",
|
|
37
|
+
"@dxos/edge-client": "0.8.3",
|
|
38
|
+
"@dxos/invariant": "0.8.3",
|
|
39
|
+
"@dxos/graph": "0.8.3",
|
|
40
|
+
"@dxos/keys": "0.8.3",
|
|
41
|
+
"@dxos/live-object": "0.8.3",
|
|
42
|
+
"@dxos/log": "0.8.3",
|
|
43
|
+
"@dxos/react-client": "0.8.3",
|
|
44
|
+
"@dxos/react-ui-attention": "0.8.3",
|
|
45
|
+
"@dxos/react-edge-client": "0.8.3",
|
|
46
|
+
"@dxos/react-ui-canvas": "0.8.3",
|
|
47
|
+
"@dxos/functions": "0.8.3",
|
|
48
|
+
"@dxos/react-ui-canvas-editor": "0.8.3",
|
|
49
|
+
"@dxos/react-ui-editor": "0.8.3",
|
|
50
|
+
"@dxos/react-ui-form": "0.8.3",
|
|
51
|
+
"@dxos/react-ui-stack": "0.8.3",
|
|
52
|
+
"@dxos/react-ui-sfx": "0.8.3",
|
|
53
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.3",
|
|
54
|
+
"@dxos/schema": "0.8.3",
|
|
55
|
+
"@dxos/util": "0.8.3"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@effect/ai": "0.8.0",
|
|
@@ -65,21 +65,21 @@
|
|
|
65
65
|
"react": "~18.2.0",
|
|
66
66
|
"react-dom": "~18.2.0",
|
|
67
67
|
"vite": "5.4.7",
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/artifact-testing": "0.8.3
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/echo-signals": "0.8.3
|
|
72
|
-
"@dxos/random": "0.8.3
|
|
73
|
-
"@dxos/react-ui": "0.8.3
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
68
|
+
"@dxos/app-framework": "0.8.3",
|
|
69
|
+
"@dxos/artifact-testing": "0.8.3",
|
|
70
|
+
"@dxos/compute": "0.8.3",
|
|
71
|
+
"@dxos/echo-signals": "0.8.3",
|
|
72
|
+
"@dxos/random": "0.8.3",
|
|
73
|
+
"@dxos/react-ui": "0.8.3",
|
|
74
|
+
"@dxos/storybook-utils": "0.8.3",
|
|
75
|
+
"@dxos/react-ui-theme": "0.8.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"effect": "3.13.3",
|
|
79
79
|
"react": "~18.2.0",
|
|
80
80
|
"react-dom": "~18.2.0",
|
|
81
|
-
"@dxos/react-ui
|
|
82
|
-
"@dxos/react-ui": "0.8.3
|
|
81
|
+
"@dxos/react-ui": "0.8.3",
|
|
82
|
+
"@dxos/react-ui-theme": "0.8.3"
|
|
83
83
|
},
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
package/src/compute.stories.tsx
CHANGED
|
@@ -7,14 +7,22 @@ import '@dxos-theme';
|
|
|
7
7
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
8
8
|
import React, { type PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
|
+
import { EdgeAiServiceClient } from '@dxos/ai';
|
|
10
11
|
import { createTestOllamaClient } from '@dxos/ai/testing';
|
|
11
12
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import { capabilities,
|
|
13
|
-
import {
|
|
13
|
+
import { capabilities, localServiceEndpoints } from '@dxos/artifact-testing';
|
|
14
|
+
import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
|
|
15
|
+
import { AiService, ServiceContainer } from '@dxos/functions';
|
|
14
16
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
17
|
import { Select, Toolbar } from '@dxos/react-ui';
|
|
16
18
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
17
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
CanvasGraphModel,
|
|
21
|
+
Editor,
|
|
22
|
+
type EditorController,
|
|
23
|
+
type EditorRootProps,
|
|
24
|
+
ShapeRegistry,
|
|
25
|
+
} from '@dxos/react-ui-canvas-editor';
|
|
18
26
|
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
19
27
|
import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
|
|
20
28
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -193,7 +201,7 @@ export const Default: Story = {
|
|
|
193
201
|
snapToGrid: false,
|
|
194
202
|
sidebar: 'selected',
|
|
195
203
|
registry: new ShapeRegistry(computeShapes),
|
|
196
|
-
...createComputeGraphController(),
|
|
204
|
+
...createComputeGraphController(CanvasGraphModel.create<ComputeShape>(), new ServiceContainer()),
|
|
197
205
|
},
|
|
198
206
|
};
|
|
199
207
|
|
|
@@ -204,7 +212,7 @@ export const Beacon: Story = {
|
|
|
204
212
|
snapToGrid: false,
|
|
205
213
|
sidebar: 'selected',
|
|
206
214
|
registry: new ShapeRegistry(computeShapes),
|
|
207
|
-
...createComputeGraphController(createBasicCircuit()),
|
|
215
|
+
...createComputeGraphController(createBasicCircuit(), new ServiceContainer()),
|
|
208
216
|
},
|
|
209
217
|
};
|
|
210
218
|
|
|
@@ -215,7 +223,7 @@ export const Transform: Story = {
|
|
|
215
223
|
snapToGrid: false,
|
|
216
224
|
sidebar: 'selected',
|
|
217
225
|
registry: new ShapeRegistry(computeShapes),
|
|
218
|
-
...createComputeGraphController(createTransformCircuit()),
|
|
226
|
+
...createComputeGraphController(createTransformCircuit(), new ServiceContainer()),
|
|
219
227
|
},
|
|
220
228
|
};
|
|
221
229
|
|
|
@@ -226,7 +234,7 @@ export const Logic: Story = {
|
|
|
226
234
|
snapToGrid: false,
|
|
227
235
|
sidebar: 'compute',
|
|
228
236
|
registry: new ShapeRegistry(computeShapes),
|
|
229
|
-
...createComputeGraphController(createLogicCircuit()),
|
|
237
|
+
...createComputeGraphController(createLogicCircuit(), new ServiceContainer()),
|
|
230
238
|
},
|
|
231
239
|
};
|
|
232
240
|
|
|
@@ -237,7 +245,7 @@ export const Control: Story = {
|
|
|
237
245
|
snapToGrid: false,
|
|
238
246
|
sidebar: 'compute',
|
|
239
247
|
registry: new ShapeRegistry(computeShapes),
|
|
240
|
-
...createComputeGraphController(createControlCircuit()),
|
|
248
|
+
...createComputeGraphController(createControlCircuit(), new ServiceContainer()),
|
|
241
249
|
},
|
|
242
250
|
};
|
|
243
251
|
|
|
@@ -257,7 +265,12 @@ export const Template: Story = {
|
|
|
257
265
|
snapToGrid: false,
|
|
258
266
|
// sidebar: 'controller',
|
|
259
267
|
registry: new ShapeRegistry(computeShapes),
|
|
260
|
-
...createComputeGraphController(
|
|
268
|
+
...createComputeGraphController(
|
|
269
|
+
createTemplateCircuit(),
|
|
270
|
+
new ServiceContainer().setServices({
|
|
271
|
+
ai: AiService.make(new EdgeAiServiceClient({ endpoint: localServiceEndpoints.ai })),
|
|
272
|
+
}),
|
|
273
|
+
),
|
|
261
274
|
},
|
|
262
275
|
};
|
|
263
276
|
|
|
@@ -269,7 +282,12 @@ export const GPT: Story = {
|
|
|
269
282
|
// sidebar: 'json',
|
|
270
283
|
sidebar: 'controller',
|
|
271
284
|
registry: new ShapeRegistry(computeShapes),
|
|
272
|
-
...createComputeGraphController(
|
|
285
|
+
...createComputeGraphController(
|
|
286
|
+
createGptCircuit({ history: true }),
|
|
287
|
+
new ServiceContainer().setServices({
|
|
288
|
+
ai: AiService.make(new EdgeAiServiceClient({ endpoint: localServiceEndpoints.ai })),
|
|
289
|
+
}),
|
|
290
|
+
),
|
|
273
291
|
},
|
|
274
292
|
};
|
|
275
293
|
|
|
@@ -282,7 +300,9 @@ export const Plugins: Story = {
|
|
|
282
300
|
registry: new ShapeRegistry(computeShapes),
|
|
283
301
|
...createComputeGraphController(
|
|
284
302
|
createGptCircuit({ history: true, image: true, artifact: true }),
|
|
285
|
-
|
|
303
|
+
new ServiceContainer().setServices({
|
|
304
|
+
ai: AiService.make(new EdgeAiServiceClient({ endpoint: localServiceEndpoints.ai })),
|
|
305
|
+
}),
|
|
286
306
|
),
|
|
287
307
|
},
|
|
288
308
|
};
|
|
@@ -294,7 +314,12 @@ export const Artifact: Story = {
|
|
|
294
314
|
snapToGrid: false,
|
|
295
315
|
// sidebar: 'json',
|
|
296
316
|
registry: new ShapeRegistry(computeShapes),
|
|
297
|
-
...createComputeGraphController(
|
|
317
|
+
...createComputeGraphController(
|
|
318
|
+
createArtifactCircuit(),
|
|
319
|
+
new ServiceContainer().setServices({
|
|
320
|
+
ai: AiService.make(new EdgeAiServiceClient({ endpoint: localServiceEndpoints.ai })),
|
|
321
|
+
}),
|
|
322
|
+
),
|
|
298
323
|
},
|
|
299
324
|
};
|
|
300
325
|
|
|
@@ -306,9 +331,12 @@ export const ImageGen: Story = {
|
|
|
306
331
|
// sidebar: 'json',
|
|
307
332
|
sidebar: 'controller',
|
|
308
333
|
registry: new ShapeRegistry(computeShapes),
|
|
309
|
-
...createComputeGraphController(
|
|
310
|
-
|
|
311
|
-
|
|
334
|
+
...createComputeGraphController(
|
|
335
|
+
createGptCircuit({ image: true, artifact: true }),
|
|
336
|
+
new ServiceContainer().setServices({
|
|
337
|
+
ai: AiService.make(createTestOllamaClient()),
|
|
338
|
+
}),
|
|
339
|
+
),
|
|
312
340
|
},
|
|
313
341
|
};
|
|
314
342
|
|
|
@@ -319,7 +347,12 @@ export const Audio: Story = {
|
|
|
319
347
|
snapToGrid: false,
|
|
320
348
|
sidebar: 'controller',
|
|
321
349
|
registry: new ShapeRegistry(computeShapes),
|
|
322
|
-
...createComputeGraphController(
|
|
350
|
+
...createComputeGraphController(
|
|
351
|
+
createAudioCircuit(),
|
|
352
|
+
new ServiceContainer().setServices({
|
|
353
|
+
ai: AiService.make(createTestOllamaClient()),
|
|
354
|
+
}),
|
|
355
|
+
),
|
|
323
356
|
},
|
|
324
357
|
};
|
|
325
358
|
|
|
@@ -329,6 +362,11 @@ export const Voice: Story = {
|
|
|
329
362
|
snapToGrid: false,
|
|
330
363
|
sidebar: 'controller',
|
|
331
364
|
registry: new ShapeRegistry(computeShapes),
|
|
332
|
-
...createComputeGraphController(
|
|
365
|
+
...createComputeGraphController(
|
|
366
|
+
createGPTRealtimeCircuit(),
|
|
367
|
+
new ServiceContainer().setServices({
|
|
368
|
+
ai: AiService.make(createTestOllamaClient()),
|
|
369
|
+
}),
|
|
370
|
+
),
|
|
333
371
|
},
|
|
334
372
|
};
|
package/src/graph/controller.ts
CHANGED
|
@@ -2,34 +2,26 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { type Context, Effect, Either, Exit, Layer, Scope } from 'effect';
|
|
5
|
+
import { type Context, Effect, Either, Exit, Scope } from 'effect';
|
|
7
6
|
|
|
8
7
|
import { type ImageContentBlock } from '@dxos/ai';
|
|
9
8
|
import { Event, synchronized } from '@dxos/async';
|
|
10
9
|
import {
|
|
11
|
-
isNotExecuted,
|
|
12
|
-
makeValueBag,
|
|
13
10
|
type ComputeEdge,
|
|
14
11
|
type ComputeEvent,
|
|
15
12
|
type ComputeGraphModel,
|
|
16
13
|
type ComputeMeta,
|
|
17
14
|
type ComputeNode,
|
|
18
|
-
type
|
|
19
|
-
EventLogger,
|
|
15
|
+
type EventLogger,
|
|
20
16
|
type GptInput,
|
|
21
17
|
type GptOutput,
|
|
22
|
-
GptService,
|
|
23
|
-
GraphExecutor,
|
|
24
|
-
MockGpt,
|
|
25
|
-
QueueService,
|
|
26
|
-
SpaceService,
|
|
27
|
-
type ValueBag,
|
|
28
18
|
type GraphDiagnostic,
|
|
29
|
-
|
|
19
|
+
GraphExecutor,
|
|
20
|
+
isNotExecuted,
|
|
21
|
+
ValueBag,
|
|
30
22
|
} from '@dxos/conductor';
|
|
31
23
|
import { Resource } from '@dxos/context';
|
|
32
|
-
import type {
|
|
24
|
+
import type { ServiceContainer } from '@dxos/functions';
|
|
33
25
|
import { log } from '@dxos/log';
|
|
34
26
|
import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
|
|
35
27
|
|
|
@@ -70,13 +62,6 @@ export type RuntimeValue =
|
|
|
70
62
|
error: string;
|
|
71
63
|
};
|
|
72
64
|
|
|
73
|
-
export type Services = {
|
|
74
|
-
gpt: Context.Tag.Service<GptService>;
|
|
75
|
-
edgeClient?: EdgeClient;
|
|
76
|
-
edgeHttpClient?: EdgeHttpClient;
|
|
77
|
-
spaceService?: Context.Tag.Service<SpaceService>;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
65
|
type ComputeOutputEvent = {
|
|
81
66
|
nodeId: string;
|
|
82
67
|
property: string;
|
|
@@ -88,10 +73,12 @@ type ComputeOutputEvent = {
|
|
|
88
73
|
*/
|
|
89
74
|
const AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];
|
|
90
75
|
|
|
91
|
-
export const createComputeGraphController = (
|
|
76
|
+
export const createComputeGraphController = (
|
|
77
|
+
graph: CanvasGraphModel<ComputeShape>,
|
|
78
|
+
serviceContainer: ServiceContainer,
|
|
79
|
+
) => {
|
|
92
80
|
const computeGraph = createComputeGraph(graph);
|
|
93
|
-
const controller = new ComputeGraphController(computeGraph);
|
|
94
|
-
controller.setServices(services ?? {});
|
|
81
|
+
const controller = new ComputeGraphController(serviceContainer, computeGraph);
|
|
95
82
|
return { controller, graph };
|
|
96
83
|
};
|
|
97
84
|
|
|
@@ -105,8 +92,6 @@ export class ComputeGraphController extends Resource {
|
|
|
105
92
|
|
|
106
93
|
private _diagnostics: GraphDiagnostic[] = [];
|
|
107
94
|
|
|
108
|
-
private _services: Partial<Services> = {};
|
|
109
|
-
|
|
110
95
|
/**
|
|
111
96
|
* Canvas force-sets outputs of those nodes.
|
|
112
97
|
*/
|
|
@@ -128,6 +113,7 @@ export class ComputeGraphController extends Resource {
|
|
|
128
113
|
public readonly events = new Event<ComputeEvent>();
|
|
129
114
|
|
|
130
115
|
constructor(
|
|
116
|
+
private readonly _serviceContainer: ServiceContainer,
|
|
131
117
|
/** Persistent compute graph. */
|
|
132
118
|
private readonly _graph: ComputeGraphModel,
|
|
133
119
|
) {
|
|
@@ -145,11 +131,6 @@ export class ComputeGraphController extends Resource {
|
|
|
145
131
|
};
|
|
146
132
|
}
|
|
147
133
|
|
|
148
|
-
setServices(services: Partial<Services>): void {
|
|
149
|
-
log.info('setServices', { services });
|
|
150
|
-
Object.assign(this._services, services);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
134
|
get graph() {
|
|
154
135
|
return this._graph;
|
|
155
136
|
}
|
|
@@ -237,10 +218,10 @@ export class ComputeGraphController extends Resource {
|
|
|
237
218
|
await executor.load(this._graph);
|
|
238
219
|
|
|
239
220
|
for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {
|
|
240
|
-
executor.setOutputs(nodeId, Effect.succeed(
|
|
221
|
+
executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));
|
|
241
222
|
}
|
|
242
223
|
|
|
243
|
-
const
|
|
224
|
+
const serviceLayer = this._serviceContainer.createLayer();
|
|
244
225
|
await Effect.runPromise(
|
|
245
226
|
Effect.gen(this, function* () {
|
|
246
227
|
const scope = yield* Scope.make();
|
|
@@ -254,7 +235,7 @@ export class ComputeGraphController extends Resource {
|
|
|
254
235
|
Scope.extend(scope),
|
|
255
236
|
|
|
256
237
|
Effect.flatMap(computeValueBag),
|
|
257
|
-
Effect.provide(
|
|
238
|
+
Effect.provide(serviceLayer),
|
|
258
239
|
Effect.withSpan('test'),
|
|
259
240
|
Effect.tap((values) => {
|
|
260
241
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -288,7 +269,7 @@ export class ComputeGraphController extends Resource {
|
|
|
288
269
|
await executor.load(this._graph);
|
|
289
270
|
|
|
290
271
|
for (const [nodeId, outputs] of Object.entries(this._forcedOutputs)) {
|
|
291
|
-
executor.setOutputs(nodeId, Effect.succeed(
|
|
272
|
+
executor.setOutputs(nodeId, Effect.succeed(ValueBag.make(outputs)));
|
|
292
273
|
}
|
|
293
274
|
|
|
294
275
|
// TODO(dmaretskyi): Stop hardcoding.
|
|
@@ -298,7 +279,6 @@ export class ComputeGraphController extends Resource {
|
|
|
298
279
|
: this._graph.nodes.filter((node) => node.type != null && AUTO_TRIGGER_NODES.includes(node.type));
|
|
299
280
|
const allAffectedNodes = [...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))];
|
|
300
281
|
|
|
301
|
-
const services = this._createServiceLayer();
|
|
302
282
|
await Effect.runPromise(
|
|
303
283
|
Effect.gen(this, function* () {
|
|
304
284
|
const scope = yield* Scope.make();
|
|
@@ -315,7 +295,7 @@ export class ComputeGraphController extends Resource {
|
|
|
315
295
|
Effect.withSpan('runGraph'),
|
|
316
296
|
Scope.extend(scope),
|
|
317
297
|
Effect.flatMap(computeValueBag),
|
|
318
|
-
Effect.provide(
|
|
298
|
+
Effect.provide(this._serviceContainer.createLayer()),
|
|
319
299
|
Effect.withSpan('test'),
|
|
320
300
|
Effect.tap((values) => {
|
|
321
301
|
for (const [key, value] of Object.entries(values)) {
|
|
@@ -342,27 +322,6 @@ export class ComputeGraphController extends Resource {
|
|
|
342
322
|
this.update.emit();
|
|
343
323
|
}
|
|
344
324
|
|
|
345
|
-
private _createServiceLayer(): Layer.Layer<Exclude<ComputeRequirements, Scope.Scope>> {
|
|
346
|
-
const services = { ...DEFAULT_SERVICES, ...this._services };
|
|
347
|
-
const logLayer = Layer.succeed(EventLogger, this._createLogger());
|
|
348
|
-
const gptLayer = Layer.succeed(GptService, services.gpt!);
|
|
349
|
-
const queueLayer =
|
|
350
|
-
services.edgeHttpClient != null ? QueueService.fromClient(services.edgeHttpClient) : QueueService.notAvailable;
|
|
351
|
-
|
|
352
|
-
const spaceLayer =
|
|
353
|
-
services.spaceService != null ? Layer.succeed(SpaceService, services.spaceService) : SpaceService.empty;
|
|
354
|
-
|
|
355
|
-
const functionCallServiceLayer =
|
|
356
|
-
services.edgeHttpClient != null && services.spaceService != null
|
|
357
|
-
? Layer.succeed(
|
|
358
|
-
FunctionCallService,
|
|
359
|
-
FunctionCallService.fromClient(services.edgeHttpClient.baseUrl, services.spaceService.spaceId),
|
|
360
|
-
)
|
|
361
|
-
: Layer.succeed(FunctionCallService, FunctionCallService.mock());
|
|
362
|
-
|
|
363
|
-
return Layer.mergeAll(logLayer, gptLayer, queueLayer, spaceLayer, functionCallServiceLayer, FetchHttpClient.layer);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
325
|
private _createLogger(): Context.Tag.Service<EventLogger> {
|
|
367
326
|
return {
|
|
368
327
|
log: (event) => {
|
|
@@ -402,10 +361,6 @@ export class ComputeGraphController extends Resource {
|
|
|
402
361
|
}
|
|
403
362
|
}
|
|
404
363
|
|
|
405
|
-
const DEFAULT_SERVICES: Services = {
|
|
406
|
-
gpt: new MockGpt(),
|
|
407
|
-
};
|
|
408
|
-
|
|
409
364
|
/**
|
|
410
365
|
* Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.
|
|
411
366
|
*/
|
|
@@ -61,11 +61,11 @@ export const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeS
|
|
|
61
61
|
await peerConnection.setLocalDescription(offer);
|
|
62
62
|
|
|
63
63
|
// Send offer to backend and get answer
|
|
64
|
-
const
|
|
64
|
+
const AiServiceUrl = new URL(
|
|
65
65
|
'/rtc-connect',
|
|
66
66
|
config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL,
|
|
67
67
|
);
|
|
68
|
-
const response = await fetch(
|
|
68
|
+
const response = await fetch(AiServiceUrl, {
|
|
69
69
|
method: 'POST',
|
|
70
70
|
body: offer.sdp,
|
|
71
71
|
headers: {
|
package/src/testing/circuits.ts
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { createSystemPrompt } from '@dxos/artifact';
|
|
6
6
|
import { ObjectId } from '@dxos/echo-schema';
|
|
7
|
+
import type { ServiceContainer } from '@dxos/functions';
|
|
7
8
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
8
9
|
import { type Dimension, type Point } from '@dxos/react-ui-canvas';
|
|
9
|
-
import {
|
|
10
|
+
import { CanvasGraphModel, createNote, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
|
|
10
11
|
|
|
11
|
-
import { ComputeGraphController
|
|
12
|
+
import { ComputeGraphController } from '../graph';
|
|
12
13
|
import { createComputeGraph } from '../hooks';
|
|
13
14
|
import {
|
|
14
15
|
type ComputeShape,
|
|
@@ -30,20 +31,19 @@ import {
|
|
|
30
31
|
createQueue,
|
|
31
32
|
createRandom,
|
|
32
33
|
createScope,
|
|
33
|
-
createSwitch,
|
|
34
34
|
createSurface,
|
|
35
|
-
|
|
36
|
-
createText,
|
|
35
|
+
createSwitch,
|
|
37
36
|
createTemplate,
|
|
37
|
+
createText,
|
|
38
|
+
createTextToImage,
|
|
38
39
|
} from '../shapes';
|
|
39
40
|
|
|
40
41
|
export const createComputeGraphController = (
|
|
41
|
-
graph
|
|
42
|
-
|
|
42
|
+
graph: CanvasGraphModel<ComputeShape>,
|
|
43
|
+
serviceContainer: ServiceContainer,
|
|
43
44
|
) => {
|
|
44
45
|
const computeGraph = createComputeGraph(graph);
|
|
45
|
-
const controller = new ComputeGraphController(computeGraph);
|
|
46
|
-
controller.setServices(services ?? {});
|
|
46
|
+
const controller = new ComputeGraphController(serviceContainer, computeGraph);
|
|
47
47
|
return { controller, graph };
|
|
48
48
|
};
|
|
49
49
|
|