@dxos/assistant 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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/{chunk-B4HAWUFW.mjs → chunk-PND5VR6D.mjs} +286 -757
- package/dist/lib/browser/chunk-PND5VR6D.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +324 -7
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +102 -139
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/{chunk-NOB7CIIC.cjs → chunk-IBOBRBDF.cjs} +303 -768
- package/dist/lib/node/chunk-IBOBRBDF.cjs.map +7 -0
- package/dist/lib/node/index.cjs +353 -36
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +93 -128
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/{chunk-SAWYU3V5.mjs → chunk-DCQJOLSR.mjs} +286 -757
- package/dist/lib/node-esm/chunk-DCQJOLSR.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +324 -7
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +102 -139
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/edge-client.d.ts +5 -4
- package/dist/types/src/ai-service/edge-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/message-collector.d.ts +6 -0
- package/dist/types/src/ai-service/message-collector.d.ts.map +1 -1
- package/dist/types/src/ai-service/ollama-client.d.ts +2 -6
- package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -1
- package/dist/types/src/ai-service/parser.d.ts +3 -0
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/service.d.ts +2 -18
- package/dist/types/src/ai-service/service.d.ts.map +1 -1
- package/dist/types/src/ai-service/stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +2 -6
- package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/test-stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/types.d.ts +101 -144
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/ai-service/util/sse.d.ts.map +1 -1
- package/dist/types/src/{experimental/conversation → conversation}/conversation.d.ts +21 -2
- package/dist/types/src/conversation/conversation.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -0
- package/dist/types/src/{experimental/conversation → conversation}/types.d.ts +12 -11
- package/dist/types/src/conversation/types.d.ts.map +1 -0
- package/dist/types/src/cypher/ast.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.d.ts.map +1 -0
- package/dist/types/src/cypher/combinators.test.d.ts.map +1 -0
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.d.ts.map +1 -0
- package/dist/types/src/cypher/execution-plan.test.d.ts.map +1 -0
- package/dist/types/src/cypher/index.d.ts.map +1 -0
- package/dist/types/src/cypher/parjs.d.ts.map +1 -0
- package/dist/types/src/cypher/parser.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.d.ts.map +1 -0
- package/dist/types/src/cypher/query-executor.test.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.d.ts.map +1 -0
- package/dist/types/src/cypher/schema.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/index.d.ts +0 -2
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +13 -33
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/logger.d.ts +1 -1
- package/dist/types/src/testing/logger.d.ts.map +1 -1
- package/dist/types/src/testing/ollama.d.ts.map +1 -1
- package/dist/types/src/testing/query-promts.d.ts +4 -4
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +5 -5
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +23 -25
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/dist/types/src/util/trim.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +14 -20
- package/src/ai-service/client.test.ts +73 -55
- package/src/ai-service/edge-client.ts +20 -13
- package/src/ai-service/ollama-client.ts +10 -17
- package/src/ai-service/parser.ts +2 -13
- package/src/ai-service/service.ts +3 -19
- package/src/ai-service/testing/mock.ts +1 -9
- package/src/ai-service/types.ts +15 -24
- package/src/bin/chat.ts +4 -4
- package/src/{experimental/conversation → conversation}/conversation.test.ts +5 -5
- package/src/{experimental/conversation → conversation}/conversation.ts +119 -4
- package/src/{experimental/conversation → conversation}/types.ts +14 -11
- package/src/{experimental/cypher → cypher}/combinators.test.ts +4 -4
- package/src/{experimental/cypher → cypher}/echo-data-source.ts +11 -11
- package/src/{experimental/cypher → cypher}/execution-plan.test.ts +1 -1
- package/src/{experimental/cypher → cypher}/query-executor.test.ts +2 -2
- package/src/{experimental/cypher → cypher}/schema.test.ts +3 -3
- package/src/{experimental/cypher → cypher}/schema.ts +1 -1
- package/src/index.ts +2 -3
- package/src/session/index.ts +0 -2
- package/src/session/session.test.ts +63 -35
- package/src/session/session.ts +151 -297
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/index.ts +0 -1
- package/src/testing/logger.ts +1 -1
- package/src/testing/query-promts.ts +6 -6
- package/src/testing/query.test.ts +21 -18
- package/src/testing/test-data.ts +72 -79
- package/src/testing/test-schema.ts +29 -28
- package/dist/lib/browser/chunk-B4HAWUFW.mjs.map +0 -7
- package/dist/lib/node/chunk-NOB7CIIC.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-SAWYU3V5.mjs.map +0 -7
- package/dist/types/src/experimental/conversation/conversation.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/conversation.test.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/index.d.ts.map +0 -1
- package/dist/types/src/experimental/conversation/types.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/ast.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/combinators.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/echo-data-source.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/execution-plan.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/index.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parjs.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/parser.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/query-executor.test.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.d.ts.map +0 -1
- package/dist/types/src/experimental/cypher/schema.test.d.ts.map +0 -1
- package/dist/types/src/experimental/index.d.ts +0 -3
- package/dist/types/src/experimental/index.d.ts.map +0 -1
- package/dist/types/src/experimental/ner/ner.test.d.ts +0 -2
- package/dist/types/src/experimental/ner/ner.test.d.ts.map +0 -1
- package/dist/types/src/experimental/research/exa.d.ts +0 -6
- package/dist/types/src/experimental/research/exa.d.ts.map +0 -1
- package/dist/types/src/experimental/research/research.test.d.ts +0 -2
- package/dist/types/src/experimental/research/research.test.d.ts.map +0 -1
- package/dist/types/src/session/tools.d.ts +0 -18
- package/dist/types/src/session/tools.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.d.ts +0 -22
- package/dist/types/src/session/version-pin.d.ts.map +0 -1
- package/dist/types/src/session/version-pin.test.d.ts +0 -2
- package/dist/types/src/session/version-pin.test.d.ts.map +0 -1
- package/dist/types/src/testing/printer.d.ts +0 -6
- package/dist/types/src/testing/printer.d.ts.map +0 -1
- package/src/experimental/index.ts +0 -6
- package/src/experimental/ner/ner.test.ts +0 -163
- package/src/experimental/research/exa.ts +0 -38
- package/src/experimental/research/instructions.tpl +0 -64
- package/src/experimental/research/research.test.ts +0 -263
- package/src/session/tools.ts +0 -117
- package/src/session/version-pin.test.ts +0 -26
- package/src/session/version-pin.ts +0 -49
- package/src/testing/printer.ts +0 -41
- package/src/typedefs.d.ts +0 -8
- /package/dist/types/src/{experimental/conversation → conversation}/conversation.test.d.ts +0 -0
- /package/dist/types/src/{experimental/conversation → conversation}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/ast.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/combinators.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/echo-data-source.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/execution-plan.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/index.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parjs.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/parser.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/query-executor.test.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.d.ts +0 -0
- /package/dist/types/src/{experimental/cypher → cypher}/schema.test.d.ts +0 -0
- /package/src/{experimental/conversation → conversation}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/ast.ts +0 -0
- /package/src/{experimental/cypher → cypher}/combinators.ts +0 -0
- /package/src/{experimental/cypher → cypher}/execution-plan.ts +0 -0
- /package/src/{experimental/cypher → cypher}/index.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs-shims.d.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parjs.ts +0 -0
- /package/src/{experimental/cypher → cypher}/parser.ts +0 -0
- /package/src/{experimental/cypher → cypher}/query-executor.ts +0 -0
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Schema } from 'effect';
|
|
6
|
-
|
|
7
5
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import { type EchoDatabase, Filter, type
|
|
9
|
-
import {
|
|
6
|
+
import { type EchoDatabase, Filter, type ReactiveEchoObject } from '@dxos/echo-db';
|
|
7
|
+
import { type S, getSchemaTypename, StoredSchema, toJsonSchema } from '@dxos/echo-schema';
|
|
8
|
+
import { getSchema } from '@dxos/live-object';
|
|
10
9
|
import { log } from '@dxos/log';
|
|
11
10
|
|
|
12
11
|
import type { DataSource, Node, Relationship } from './query-executor';
|
|
@@ -22,12 +21,13 @@ export class EchoDataSource implements DataSource {
|
|
|
22
21
|
return objects.map(this._objectToNode);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
const schema = (await this._getAllSchema()).find((
|
|
24
|
+
const schema = (await this._getAllSchema()).find((s) => getSchemaTypename(s)?.endsWith(label));
|
|
25
|
+
|
|
26
26
|
if (!schema) {
|
|
27
27
|
return [];
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const { objects } = await this._db.query(Filter.
|
|
30
|
+
const { objects } = await this._db.query(Filter.schema(schema)).run();
|
|
31
31
|
return objects.map(this._objectToNode);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -57,21 +57,21 @@ export class EchoDataSource implements DataSource {
|
|
|
57
57
|
return []; // TODO(dmaretskyi): Handle real relationships.
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const { objects } = await this._db.query(Filter.
|
|
60
|
+
const { objects } = await this._db.query(Filter.schema(relationship.schema)).run();
|
|
61
61
|
return (
|
|
62
62
|
await Promise.all(objects.map((object) => this._projectRefRelationship(object, relationship.property)))
|
|
63
63
|
).flat();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
private async _getAllSchema(): Promise<
|
|
66
|
+
private async _getAllSchema(): Promise<S.Schema.AnyNoContext[]> {
|
|
67
67
|
return [
|
|
68
68
|
...(await this._db.schemaRegistry.query().run()),
|
|
69
69
|
// TODO(dmaretskyi): Remove once we can serialize recursive schema.
|
|
70
|
-
...this._db.graph.schemaRegistry.schemas.filter((
|
|
70
|
+
...this._db.graph.schemaRegistry.schemas.filter((s) => getSchemaTypename(s)?.startsWith('example.org')),
|
|
71
71
|
].filter((schema) => getSchemaTypename(schema) !== StoredSchema.typename);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
private _objectToNode(object:
|
|
74
|
+
private _objectToNode(object: ReactiveEchoObject<any>): Node {
|
|
75
75
|
const { id, ...properties } = object;
|
|
76
76
|
return {
|
|
77
77
|
id,
|
|
@@ -81,7 +81,7 @@ export class EchoDataSource implements DataSource {
|
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private async _projectRefRelationship(object:
|
|
84
|
+
private async _projectRefRelationship(object: ReactiveEchoObject<any>, prop: string): Promise<Relationship[]> {
|
|
85
85
|
if (!object[prop]) {
|
|
86
86
|
return [];
|
|
87
87
|
}
|
|
@@ -21,7 +21,7 @@ describe('Execution Plan', () => {
|
|
|
21
21
|
test('complex query', ({ expect }) => {
|
|
22
22
|
const plan = createExecutionPlan(
|
|
23
23
|
parseCypherQuery(
|
|
24
|
-
"MATCH (org:
|
|
24
|
+
"MATCH (org:Org {name: 'DXOS'})-[:ORG_EMPLOYEES]->(c:Contact)<-[:TASK_ASSIGNEE]-(:Task)-[:TASK_PROJECT]->(p:Project {name: 'Composer'}) RETURN c.name",
|
|
25
25
|
),
|
|
26
26
|
);
|
|
27
27
|
log('', { plan });
|
|
@@ -7,7 +7,7 @@ import { test } from 'vitest';
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
|
|
9
9
|
import { executeQuery } from './query-executor';
|
|
10
|
-
import { createTestData } from '
|
|
10
|
+
import { createTestData } from '../testing';
|
|
11
11
|
|
|
12
12
|
test.skip('run', async ({ expect }) => {
|
|
13
13
|
const dataSource = createTestData();
|
|
@@ -25,7 +25,7 @@ test.skip('run', async ({ expect }) => {
|
|
|
25
25
|
const result = await executeQuery(
|
|
26
26
|
dataSource,
|
|
27
27
|
`
|
|
28
|
-
MATCH (org:
|
|
28
|
+
MATCH (org:Org {name: 'DXOS'})-[:ORG_EMPLOYEES]->(c:Contact)<-[:TASK_ASSIGNEE]-(t:Task)-[:TASK_PROJECT]->(p:Project {name: 'Composer'})
|
|
29
29
|
RETURN c.name, t.name
|
|
30
30
|
`,
|
|
31
31
|
);
|
|
@@ -7,10 +7,10 @@ import { test } from 'vitest';
|
|
|
7
7
|
import { toJsonSchema } from '@dxos/echo-schema';
|
|
8
8
|
|
|
9
9
|
import { formatJsonSchemaForLLM } from './schema';
|
|
10
|
-
import { Contact,
|
|
10
|
+
import { Contact, Org, Project, Task } from '../testing';
|
|
11
11
|
|
|
12
|
-
test('
|
|
13
|
-
const jsonSchema = [
|
|
12
|
+
test('Org-Project-Task-Contact schema', async ({ expect }) => {
|
|
13
|
+
const jsonSchema = [Org, Project, Task, Contact].map((schema) => toJsonSchema(schema));
|
|
14
14
|
const result = formatJsonSchemaForLLM(jsonSchema);
|
|
15
15
|
// log('result', { result });
|
|
16
16
|
expect(result).toHaveLength(8);
|
package/src/index.ts
CHANGED
package/src/session/index.ts
CHANGED
|
@@ -2,33 +2,35 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
|
+
import { inspect } from 'node:util';
|
|
6
7
|
import { describe, test } from 'vitest';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ArtifactId,
|
|
11
|
+
defineArtifact,
|
|
12
|
+
defineTool,
|
|
13
|
+
ToolResult,
|
|
14
|
+
type Message,
|
|
15
|
+
type MessageContentBlock,
|
|
16
|
+
} from '@dxos/artifact';
|
|
9
17
|
import { AIServiceEdgeClient } from '@dxos/assistant';
|
|
10
|
-
import {
|
|
11
|
-
import { create, ObjectId } from '@dxos/echo-schema';
|
|
18
|
+
import { createStatic, EchoObject, ObjectId } from '@dxos/echo-schema';
|
|
12
19
|
import { DXN } from '@dxos/keys';
|
|
13
20
|
import { log } from '@dxos/log';
|
|
14
21
|
|
|
15
22
|
import { AISession } from './session';
|
|
16
|
-
import { AI_SERVICE_ENDPOINT
|
|
23
|
+
import { AI_SERVICE_ENDPOINT } from '../testing';
|
|
17
24
|
|
|
18
25
|
// Define a calendar event artifact schema.
|
|
19
|
-
const CalendarEventSchema =
|
|
20
|
-
title:
|
|
21
|
-
startTime:
|
|
22
|
-
endTime:
|
|
23
|
-
description:
|
|
24
|
-
}).pipe(
|
|
25
|
-
Type.def({
|
|
26
|
-
typename: 'example.com/type/CalendarEvent',
|
|
27
|
-
version: '0.1.0',
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
26
|
+
const CalendarEventSchema = S.Struct({
|
|
27
|
+
title: S.String,
|
|
28
|
+
startTime: S.String,
|
|
29
|
+
endTime: S.String,
|
|
30
|
+
description: S.String,
|
|
31
|
+
}).pipe(EchoObject({ typename: 'example.com/type/CalendarEvent', version: '0.1.0' }));
|
|
30
32
|
|
|
31
|
-
type CalendarEvent =
|
|
33
|
+
type CalendarEvent = S.Schema.Type<typeof CalendarEventSchema>;
|
|
32
34
|
|
|
33
35
|
// TODO(burdon): Flaky.
|
|
34
36
|
describe.skip('AISession with Ollama', () => {
|
|
@@ -37,7 +39,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
37
39
|
// const aiClient = new OllamaClient({
|
|
38
40
|
// overrides: { model: 'llama3.1:8b' },
|
|
39
41
|
// });
|
|
40
|
-
const session = new AISession({ operationModel: '
|
|
42
|
+
const session = new AISession({ operationModel: 'immediate' });
|
|
41
43
|
|
|
42
44
|
const objects = new Set<string>();
|
|
43
45
|
|
|
@@ -51,7 +53,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
51
53
|
defineTool('calendar', {
|
|
52
54
|
name: 'query',
|
|
53
55
|
description: 'Query the calendar for events',
|
|
54
|
-
schema:
|
|
56
|
+
schema: S.Struct({}),
|
|
55
57
|
execute: async () => {
|
|
56
58
|
return ToolResult.Success(CALENDAR_EVENTS);
|
|
57
59
|
},
|
|
@@ -63,13 +65,13 @@ describe.skip('AISession with Ollama', () => {
|
|
|
63
65
|
id: 'artifact:dxos.org/plugin/table',
|
|
64
66
|
name: 'Table',
|
|
65
67
|
instructions: 'Use this to create and manage tables. Each table has a unique id.',
|
|
66
|
-
schema:
|
|
68
|
+
schema: S.Struct({}),
|
|
67
69
|
tools: [
|
|
68
70
|
defineTool('table', {
|
|
69
71
|
name: 'create',
|
|
70
72
|
description: 'Create a table',
|
|
71
|
-
schema:
|
|
72
|
-
data:
|
|
73
|
+
schema: S.Struct({
|
|
74
|
+
data: S.Array(S.Any).annotations({ description: 'Array of data payloads to add as rows' }),
|
|
73
75
|
}),
|
|
74
76
|
execute: async ({ data }) => {
|
|
75
77
|
log('create table', { data });
|
|
@@ -87,12 +89,12 @@ describe.skip('AISession with Ollama', () => {
|
|
|
87
89
|
name: 'Map',
|
|
88
90
|
instructions:
|
|
89
91
|
'Use this to create and manage maps. Maps source data from tables. Table id is required to create a map.',
|
|
90
|
-
schema:
|
|
92
|
+
schema: S.Struct({}),
|
|
91
93
|
tools: [
|
|
92
94
|
defineTool('map', {
|
|
93
95
|
name: 'create',
|
|
94
96
|
description: 'Create a map',
|
|
95
|
-
schema:
|
|
97
|
+
schema: S.Struct({
|
|
96
98
|
source: ArtifactId.annotations({
|
|
97
99
|
description: 'The table that will be used as the source of the map',
|
|
98
100
|
}),
|
|
@@ -117,7 +119,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
117
119
|
id: 'artifact:dxos.org/plugin/script',
|
|
118
120
|
name: 'Script',
|
|
119
121
|
instructions: 'Use this to create and manage scripts',
|
|
120
|
-
schema:
|
|
122
|
+
schema: S.Struct({}),
|
|
121
123
|
tools: [],
|
|
122
124
|
});
|
|
123
125
|
|
|
@@ -125,10 +127,9 @@ describe.skip('AISession with Ollama', () => {
|
|
|
125
127
|
// printStreamEvent(event);
|
|
126
128
|
// });
|
|
127
129
|
|
|
128
|
-
|
|
129
|
-
session.
|
|
130
|
-
session.
|
|
131
|
-
session.block.on((block) => printer.printContentBlock(block));
|
|
130
|
+
session.message.on(printMessage);
|
|
131
|
+
session.userMessage.on(printMessage);
|
|
132
|
+
session.block.on(printContentBlock);
|
|
132
133
|
|
|
133
134
|
// session.update.on((update) => {
|
|
134
135
|
// log('update', { update });
|
|
@@ -139,7 +140,6 @@ describe.skip('AISession with Ollama', () => {
|
|
|
139
140
|
client: aiClient,
|
|
140
141
|
tools: [],
|
|
141
142
|
artifacts: [calendarArtifact, tableArtifact, mapArtifact, scriptArtifact],
|
|
142
|
-
requiredArtifactIds: [calendarArtifact.id, tableArtifact.id, mapArtifact.id, scriptArtifact.id],
|
|
143
143
|
history: [],
|
|
144
144
|
generationOptions: {
|
|
145
145
|
model: '@anthropic/claude-3-5-haiku-20241022',
|
|
@@ -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
|
+
createStatic(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
|
+
createStatic(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
|
+
createStatic(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
|
+
createStatic(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
|
+
createStatic(CalendarEventSchema, {
|
|
184
184
|
title: 'Travel to Madrid',
|
|
185
185
|
startTime: '2024-01-01T14:00:00Z',
|
|
186
186
|
endTime: '2024-01-01T15:00:00Z',
|
|
@@ -188,6 +188,34 @@ const CALENDAR_EVENTS: CalendarEvent[] = [
|
|
|
188
188
|
}),
|
|
189
189
|
];
|
|
190
190
|
|
|
191
|
+
const printMessage = (message: Message) => {
|
|
192
|
+
console.log(`${message.role.toUpperCase()}\n`);
|
|
193
|
+
for (const content of message.content) {
|
|
194
|
+
printContentBlock(content);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const printContentBlock = (content: MessageContentBlock) => {
|
|
199
|
+
switch (content.type) {
|
|
200
|
+
case 'text':
|
|
201
|
+
console.log(content.text);
|
|
202
|
+
break;
|
|
203
|
+
case 'tool_use':
|
|
204
|
+
console.log(`⚙️ [Tool Use] ${content.name} ${inspect(content.input, { depth: null, colors: true })}`);
|
|
205
|
+
break;
|
|
206
|
+
case 'tool_result': {
|
|
207
|
+
let data: any;
|
|
208
|
+
try {
|
|
209
|
+
data = JSON.parse(content.content);
|
|
210
|
+
} catch {
|
|
211
|
+
data = content.content;
|
|
212
|
+
}
|
|
213
|
+
console.log(`⚙️ [Tool Result] ${content.toolUseId} ${inspect(data, { depth: null, colors: true })}`);
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
|
|
191
219
|
// const printStreamEvent = (event: GenerationStreamEvent) => {
|
|
192
220
|
// switch (event.type) {
|
|
193
221
|
// case 'message_start': {
|