@dxos/assistant 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 +49 -28
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +53 -32
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +49 -28
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/blueprint/blueprint.d.ts +3 -2
- package/dist/types/src/blueprint/blueprint.d.ts.map +1 -1
- package/dist/types/src/blueprint/machine.d.ts +10 -4
- package/dist/types/src/blueprint/machine.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts +31 -33
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +104 -100
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/research/graph.d.ts +3 -2
- package/dist/types/src/research/graph.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +6 -6
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/blueprint/ai.test.ts +1 -1
- package/src/blueprint/blueprint.test.ts +5 -5
- package/src/blueprint/logger.ts +6 -6
- package/src/blueprint/machine.ts +23 -18
- package/src/blueprint/test-data.ts +4 -4
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +2 -2
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +2 -1
- package/src/extraction/quotes.ts +2 -1
- package/src/research/graph.ts +3 -5
- package/src/research/research.test.ts +8 -7
- package/src/research/research.ts +1 -1
- package/src/session/session.test.ts +10 -10
- package/src/session/session.ts +4 -3
- package/src/summarization/summarization.test.ts +17 -12
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Obj } from '@dxos/echo';
|
|
6
6
|
import { DataType } from '@dxos/schema';
|
|
7
7
|
|
|
8
8
|
// TODO(burdon): Convert to queue.
|
|
9
9
|
export const TEST_EMAILS: DataType.Message[] = [
|
|
10
|
-
|
|
10
|
+
Obj.make(DataType.Message, {
|
|
11
11
|
properties: {
|
|
12
12
|
subject: 'Introduction email',
|
|
13
13
|
},
|
|
@@ -22,7 +22,7 @@ export const TEST_EMAILS: DataType.Message[] = [
|
|
|
22
22
|
],
|
|
23
23
|
created: new Date().toISOString(),
|
|
24
24
|
}),
|
|
25
|
-
|
|
25
|
+
Obj.make(DataType.Message, {
|
|
26
26
|
properties: {
|
|
27
27
|
subject: 'Question about integration',
|
|
28
28
|
},
|
|
@@ -37,7 +37,7 @@ export const TEST_EMAILS: DataType.Message[] = [
|
|
|
37
37
|
],
|
|
38
38
|
created: new Date().toISOString(),
|
|
39
39
|
}),
|
|
40
|
-
|
|
40
|
+
Obj.make(DataType.Message, {
|
|
41
41
|
properties: {
|
|
42
42
|
subject: 'MAKE MONEY FAST!!!',
|
|
43
43
|
},
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { describe, test, beforeAll } from 'vitest';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { EdgeAiServiceClient } from '@dxos/ai';
|
|
8
8
|
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
9
9
|
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
@@ -21,7 +21,7 @@ describe.skip('LLM EntityExtraction', () => {
|
|
|
21
21
|
executor = new FunctionExecutor(
|
|
22
22
|
new ServiceContainer().setServices({
|
|
23
23
|
ai: {
|
|
24
|
-
client: new
|
|
24
|
+
client: new EdgeAiServiceClient({
|
|
25
25
|
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
26
26
|
defaultGenerationOptions: {
|
|
27
27
|
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Message } from '@dxos/ai';
|
|
6
|
+
import { Obj } from '@dxos/echo';
|
|
6
7
|
import { create } from '@dxos/echo-schema';
|
|
7
8
|
import { AiService, defineFunction, type FunctionDefinition } from '@dxos/functions';
|
|
8
9
|
import { DataType } from '@dxos/schema';
|
|
@@ -27,7 +28,7 @@ export const extractionAnthropicFn: FunctionDefinition<ExtractionInput, Extracti
|
|
|
27
28
|
client: ai.client,
|
|
28
29
|
systemPrompt: PROMPT,
|
|
29
30
|
history: [
|
|
30
|
-
|
|
31
|
+
Obj.make(Message, {
|
|
31
32
|
role: 'user',
|
|
32
33
|
content: [
|
|
33
34
|
{
|
package/src/extraction/quotes.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import { Schema } from 'effect';
|
|
6
6
|
|
|
7
|
+
import { Query, Filter } from '@dxos/echo';
|
|
7
8
|
import { type EchoDatabase } from '@dxos/echo-db';
|
|
8
|
-
import {
|
|
9
|
+
import { ObjectId } from '@dxos/echo-schema';
|
|
9
10
|
import { DXN } from '@dxos/keys';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
|
package/src/research/graph.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Schema, identity, Option, SchemaAST } from 'effect';
|
|
|
6
6
|
|
|
7
7
|
import { createTool, ToolResult } from '@dxos/ai';
|
|
8
8
|
import type { Obj, Relation } from '@dxos/echo';
|
|
9
|
+
import { Query, Filter } from '@dxos/echo';
|
|
9
10
|
import { type EchoDatabase, type Queue } from '@dxos/echo-db';
|
|
10
11
|
import { isEncodedReference } from '@dxos/echo-protocol';
|
|
11
12
|
import {
|
|
@@ -13,13 +14,10 @@ import {
|
|
|
13
14
|
getSchemaTypename,
|
|
14
15
|
getTypeAnnotation,
|
|
15
16
|
getTypeIdentifierAnnotation,
|
|
16
|
-
type AnyEchoObject,
|
|
17
17
|
create,
|
|
18
|
-
Filter,
|
|
19
18
|
getEntityKind,
|
|
20
19
|
getSchemaDXN,
|
|
21
20
|
ObjectId,
|
|
22
|
-
Query,
|
|
23
21
|
ReferenceAnnotationId,
|
|
24
22
|
type BaseObject,
|
|
25
23
|
RelationSourceDXNId,
|
|
@@ -325,7 +323,7 @@ export const createGraphWriterTool = ({
|
|
|
325
323
|
db: EchoDatabase;
|
|
326
324
|
queue?: Queue;
|
|
327
325
|
schema: Schema.Schema.AnyNoContext[];
|
|
328
|
-
onDone?: (data:
|
|
326
|
+
onDone?: (data: Obj.Any[]) => Promise<any>;
|
|
329
327
|
}) => {
|
|
330
328
|
return createTool('graph', {
|
|
331
329
|
name: 'writer',
|
|
@@ -333,7 +331,7 @@ export const createGraphWriterTool = ({
|
|
|
333
331
|
schema: createExtractionSchema(schema),
|
|
334
332
|
execute: async (input) => {
|
|
335
333
|
const data = await sanitizeObjects(schema, input as any, db, queue);
|
|
336
|
-
return ToolResult.Success(await onDone(data as
|
|
334
|
+
return ToolResult.Success(await onDone(data as Obj.Any[]));
|
|
337
335
|
},
|
|
338
336
|
});
|
|
339
337
|
};
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import { inspect } from 'node:util';
|
|
6
6
|
import { beforeAll, describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { EdgeAiServiceClient, OllamaAiServiceClient, structuredOutputParser } from '@dxos/ai';
|
|
9
9
|
import { AI_SERVICE_ENDPOINT, EXA_API_KEY } from '@dxos/ai/testing';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
10
11
|
import { type EchoDatabase } from '@dxos/echo-db';
|
|
11
12
|
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
12
13
|
import { getSchemaDXN } from '@dxos/echo-schema';
|
|
13
14
|
import { ConfiguredCredentialsService, FunctionExecutor, ServiceContainer, TracingService } from '@dxos/functions';
|
|
14
|
-
import { live } from '@dxos/live-object';
|
|
15
15
|
import { DataType, DataTypes } from '@dxos/schema';
|
|
16
16
|
|
|
17
17
|
import { createExtractionSchema, getSanitizedSchemaName } from './graph';
|
|
@@ -28,21 +28,22 @@ describe.skip('Research', () => {
|
|
|
28
28
|
beforeAll(async () => {
|
|
29
29
|
// TODO(dmaretskyi): Helper to scaffold this from a config.
|
|
30
30
|
builder = await new EchoTestBuilder().open();
|
|
31
|
-
|
|
32
|
-
db =
|
|
31
|
+
|
|
32
|
+
db = (await builder.createDatabase({ indexing: { vector: true } })).db;
|
|
33
33
|
db.graph.schemaRegistry.addSchema(DataTypes);
|
|
34
|
+
|
|
34
35
|
executor = new FunctionExecutor(
|
|
35
36
|
new ServiceContainer().setServices({
|
|
36
37
|
ai: {
|
|
37
38
|
client: REMOTE_AI
|
|
38
|
-
? new
|
|
39
|
+
? new EdgeAiServiceClient({
|
|
39
40
|
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
40
41
|
defaultGenerationOptions: {
|
|
41
42
|
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
42
43
|
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
43
44
|
},
|
|
44
45
|
})
|
|
45
|
-
: new
|
|
46
|
+
: new OllamaAiServiceClient({
|
|
46
47
|
overrides: {
|
|
47
48
|
model: 'llama3.1:8b',
|
|
48
49
|
},
|
|
@@ -57,7 +58,7 @@ describe.skip('Research', () => {
|
|
|
57
58
|
|
|
58
59
|
test('should generate a research report', { timeout: 300_000 }, async () => {
|
|
59
60
|
db.add(
|
|
60
|
-
|
|
61
|
+
Obj.make(DataType.Organization, {
|
|
61
62
|
name: 'Notion',
|
|
62
63
|
website: 'https://www.notion.com',
|
|
63
64
|
}),
|
package/src/research/research.ts
CHANGED
|
@@ -41,7 +41,7 @@ export const researchFn = defineFunction({
|
|
|
41
41
|
const ai = context.getService(AiService);
|
|
42
42
|
const credentials = context.getService(CredentialsService);
|
|
43
43
|
const { db } = context.getService(DatabaseService);
|
|
44
|
-
// const queues = context.getService(
|
|
44
|
+
// const queues = context.getService(QueueService);
|
|
45
45
|
const tracing = context.getService(TracingService);
|
|
46
46
|
|
|
47
47
|
tracing.write(create(AgentStatusReport, { message: 'Researching...' }));
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { Schema } from 'effect';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { EdgeAiServiceClient, ConsolePrinter, createTool, ToolResult } from '@dxos/ai';
|
|
9
9
|
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
10
10
|
import { ArtifactId, defineArtifact } from '@dxos/artifact';
|
|
11
|
-
import { Type } from '@dxos/echo';
|
|
12
|
-
import {
|
|
11
|
+
import { Type, Obj } from '@dxos/echo';
|
|
12
|
+
import { ObjectId } from '@dxos/echo-schema';
|
|
13
13
|
import { DXN } from '@dxos/keys';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
|
|
@@ -33,8 +33,8 @@ type CalendarEvent = Schema.Schema.Type<typeof CalendarEventSchema>;
|
|
|
33
33
|
// TODO(burdon): Flaky.
|
|
34
34
|
describe.skip('AISession with Ollama', () => {
|
|
35
35
|
test('create calendar itinerary', { timeout: 60_000 }, async () => {
|
|
36
|
-
const aiClient = new
|
|
37
|
-
// const aiClient = new
|
|
36
|
+
const aiClient = new EdgeAiServiceClient({ endpoint: AI_SERVICE_ENDPOINT.REMOTE });
|
|
37
|
+
// const aiClient = new OllamaAiServiceClient({
|
|
38
38
|
// overrides: { model: 'llama3.1:8b' },
|
|
39
39
|
// });
|
|
40
40
|
const session = new AISession({ operationModel: 'configured' });
|
|
@@ -156,31 +156,31 @@ describe.skip('AISession with Ollama', () => {
|
|
|
156
156
|
|
|
157
157
|
// Travel to rome, florence, livorno, siena, madrid for conferences
|
|
158
158
|
const CALENDAR_EVENTS: CalendarEvent[] = [
|
|
159
|
-
|
|
159
|
+
Obj.make(CalendarEventSchema, {
|
|
160
160
|
title: 'Exploring Ancient Ruins in Rome',
|
|
161
161
|
startTime: '2024-01-01T10:00:00Z',
|
|
162
162
|
endTime: '2024-01-01T11:00:00Z',
|
|
163
163
|
description: 'Tech conference at the historic Colosseum with networking opportunities',
|
|
164
164
|
}),
|
|
165
|
-
|
|
165
|
+
Obj.make(CalendarEventSchema, {
|
|
166
166
|
title: 'Renaissance Tech Summit in Florence',
|
|
167
167
|
startTime: '2024-01-01T11:00:00Z',
|
|
168
168
|
endTime: '2024-01-01T12:00:00Z',
|
|
169
169
|
description: 'Discussing AI innovations surrounded by Renaissance art',
|
|
170
170
|
}),
|
|
171
|
-
|
|
171
|
+
Obj.make(CalendarEventSchema, {
|
|
172
172
|
title: 'Travel to Livorno',
|
|
173
173
|
startTime: '2024-01-01T12:00:00Z',
|
|
174
174
|
endTime: '2024-01-01T13:00:00Z',
|
|
175
175
|
description: 'Travel to Livorno',
|
|
176
176
|
}),
|
|
177
|
-
|
|
177
|
+
Obj.make(CalendarEventSchema, {
|
|
178
178
|
title: 'Travel to Siena',
|
|
179
179
|
startTime: '2024-01-01T13:00:00Z',
|
|
180
180
|
endTime: '2024-01-01T14:00:00Z',
|
|
181
181
|
description: 'Travel to Siena',
|
|
182
182
|
}),
|
|
183
|
-
|
|
183
|
+
Obj.make(CalendarEventSchema, {
|
|
184
184
|
title: 'Travel to Madrid',
|
|
185
185
|
startTime: '2024-01-01T14:00:00Z',
|
|
186
186
|
endTime: '2024-01-01T15:00:00Z',
|
package/src/session/session.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
runTools,
|
|
11
11
|
type AgentStatus,
|
|
12
12
|
structuredOutputParser,
|
|
13
|
-
type
|
|
13
|
+
type AiServiceClient,
|
|
14
14
|
type GenerationStream,
|
|
15
15
|
type GenerateRequest,
|
|
16
16
|
Message,
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from '@dxos/ai';
|
|
23
23
|
import { type ArtifactDefinition } from '@dxos/artifact';
|
|
24
24
|
import { Event, synchronized } from '@dxos/async';
|
|
25
|
+
import { Obj } from '@dxos/echo';
|
|
25
26
|
import { ObjectVersion } from '@dxos/echo-db';
|
|
26
27
|
import { create, type ObjectId } from '@dxos/echo-schema';
|
|
27
28
|
import { invariant } from '@dxos/invariant';
|
|
@@ -57,7 +58,7 @@ export type ArtifactDiffResolver = (artifacts: { id: ObjectId; lastVersion: Obje
|
|
|
57
58
|
>;
|
|
58
59
|
|
|
59
60
|
export type SessionRunOptions = {
|
|
60
|
-
client:
|
|
61
|
+
client: AiServiceClient;
|
|
61
62
|
|
|
62
63
|
artifacts: ArtifactDefinition[];
|
|
63
64
|
|
|
@@ -310,7 +311,7 @@ export class AISession {
|
|
|
310
311
|
}
|
|
311
312
|
}
|
|
312
313
|
|
|
313
|
-
return
|
|
314
|
+
return Obj.make(Message, {
|
|
314
315
|
role: 'user',
|
|
315
316
|
content: [...prelude, { type: 'text', text: prompt }],
|
|
316
317
|
});
|
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
import { pipe, Schema } from 'effect';
|
|
6
6
|
import { beforeAll, describe, test } from 'vitest';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
EdgeAiServiceClient,
|
|
10
|
+
Message,
|
|
11
|
+
MixedStreamParser,
|
|
12
|
+
OllamaAiServiceClient,
|
|
13
|
+
type TextContentBlock,
|
|
14
|
+
} from '@dxos/ai';
|
|
9
15
|
import { AI_SERVICE_ENDPOINT } from '@dxos/ai/testing';
|
|
16
|
+
import { Obj } from '@dxos/echo';
|
|
10
17
|
import type { EchoDatabase } from '@dxos/echo-db';
|
|
11
18
|
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
12
|
-
import { create } from '@dxos/echo-schema';
|
|
13
19
|
import { AiService, defineFunction, FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
14
|
-
import { live } from '@dxos/live-object';
|
|
15
20
|
import { DataType } from '@dxos/schema';
|
|
16
21
|
import { createTestData } from '@dxos/schema/testing';
|
|
17
22
|
|
|
@@ -47,7 +52,7 @@ const summarizationFn = defineFunction({
|
|
|
47
52
|
The Transcript Summarizer outputs only the summary text.
|
|
48
53
|
`,
|
|
49
54
|
history: [
|
|
50
|
-
|
|
55
|
+
Obj.make(Message, {
|
|
51
56
|
role: 'user',
|
|
52
57
|
content: [
|
|
53
58
|
{
|
|
@@ -75,7 +80,7 @@ const summarizationFn = defineFunction({
|
|
|
75
80
|
],
|
|
76
81
|
}),
|
|
77
82
|
);
|
|
78
|
-
return
|
|
83
|
+
return Obj.make(DataType.Text, {
|
|
79
84
|
content: pipe(result[0]?.content[0], (c) => (c?.type === 'text' ? c.text : '')),
|
|
80
85
|
});
|
|
81
86
|
},
|
|
@@ -112,7 +117,7 @@ const refinementFn = defineFunction({
|
|
|
112
117
|
The Transcript Summary Refiner outputs only the summary text.
|
|
113
118
|
`,
|
|
114
119
|
history: [
|
|
115
|
-
|
|
120
|
+
Obj.make(Message, {
|
|
116
121
|
role: 'user',
|
|
117
122
|
content: summaries.map(
|
|
118
123
|
(summary) =>
|
|
@@ -130,7 +135,7 @@ const refinementFn = defineFunction({
|
|
|
130
135
|
}),
|
|
131
136
|
);
|
|
132
137
|
return {
|
|
133
|
-
summary:
|
|
138
|
+
summary: Obj.make(DataType.Text, {
|
|
134
139
|
content: pipe(result[0]?.content[0], (c) => (c?.type === 'text' ? c.text : '')),
|
|
135
140
|
}),
|
|
136
141
|
};
|
|
@@ -151,14 +156,14 @@ describe.skip('Summarization', () => {
|
|
|
151
156
|
new ServiceContainer().setServices({
|
|
152
157
|
ai: {
|
|
153
158
|
client: REMOTE_AI
|
|
154
|
-
? new
|
|
159
|
+
? new EdgeAiServiceClient({
|
|
155
160
|
endpoint: AI_SERVICE_ENDPOINT.REMOTE,
|
|
156
161
|
defaultGenerationOptions: {
|
|
157
162
|
// model: '@anthropic/claude-sonnet-4-20250514',
|
|
158
163
|
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
159
164
|
},
|
|
160
165
|
})
|
|
161
|
-
: new
|
|
166
|
+
: new OllamaAiServiceClient({
|
|
162
167
|
overrides: {
|
|
163
168
|
model: 'llama3.1:8b',
|
|
164
169
|
},
|
|
@@ -174,7 +179,7 @@ describe.skip('Summarization', () => {
|
|
|
174
179
|
test('keeps transcript outline', { timeout: 1000_000 }, async () => {
|
|
175
180
|
const { transcriptMessages } = createTestData();
|
|
176
181
|
|
|
177
|
-
const summary =
|
|
182
|
+
const summary = Obj.make(DataType.Text, {
|
|
178
183
|
content: '',
|
|
179
184
|
});
|
|
180
185
|
|
|
@@ -187,7 +192,7 @@ describe.skip('Summarization', () => {
|
|
|
187
192
|
transcript: blocks,
|
|
188
193
|
});
|
|
189
194
|
summary.content = result.content;
|
|
190
|
-
summaries.push(
|
|
195
|
+
summaries.push(Obj.make(DataType.Text, { content: result.content }));
|
|
191
196
|
|
|
192
197
|
console.log(blocks.at(-1));
|
|
193
198
|
console.log();
|
|
@@ -202,7 +207,7 @@ describe.skip('Summarization', () => {
|
|
|
202
207
|
summaries: history,
|
|
203
208
|
});
|
|
204
209
|
summary.content = result.summary.content;
|
|
205
|
-
summaries.push(
|
|
210
|
+
summaries.push(Obj.make(DataType.Text, { content: result.summary.content }));
|
|
206
211
|
|
|
207
212
|
console.log('REFINED');
|
|
208
213
|
console.log();
|