@dxos/assistant 0.8.2-main.2f9c567 → 0.8.2-main.36232bc
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-OLO6SVOL.mjs → chunk-DEIGOD4U.mjs} +21 -21
- package/dist/lib/browser/chunk-DEIGOD4U.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +14 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +80 -76
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-CI5Q7FBG.cjs → chunk-7VH7NMIM.cjs} +6 -6
- package/dist/lib/node/chunk-7VH7NMIM.cjs.map +7 -0
- package/dist/lib/node/index.cjs +34 -34
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +69 -64
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/node-esm/{chunk-Y3SYOFFJ.mjs → chunk-7JI4MDGL.mjs} +21 -21
- package/dist/lib/node-esm/chunk-7JI4MDGL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +14 -14
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +80 -76
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/ai-service/types.d.ts +133 -133
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/conversation/types.d.ts +9 -9
- package/dist/types/src/conversation/types.d.ts.map +1 -1
- package/dist/types/src/cypher/echo-data-source.d.ts.map +1 -1
- package/dist/types/src/session/session.d.ts +3 -3
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/testing/query-promts.d.ts +3 -3
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +4 -4
- 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/package.json +14 -15
- package/src/ai-service/client.test.ts +5 -5
- package/src/ai-service/ollama-client.ts +7 -7
- package/src/ai-service/types.ts +14 -14
- package/src/conversation/conversation.test.ts +3 -3
- package/src/conversation/types.ts +10 -10
- package/src/cypher/echo-data-source.ts +5 -7
- package/src/session/session.test.ts +16 -22
- package/src/session/session.ts +15 -15
- package/src/testing/artifacts.test.ts +22 -22
- package/src/testing/query-promts.ts +5 -5
- package/src/testing/test-data.ts +50 -57
- package/src/testing/test-schema.ts +28 -27
- package/dist/lib/browser/chunk-OLO6SVOL.mjs.map +0 -7
- package/dist/lib/node/chunk-CI5Q7FBG.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y3SYOFFJ.mjs.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
1
|
+
import { Schema as S } from 'effect';
|
|
2
2
|
import { Message, type ArtifactDefinition, type Tool } from '@dxos/artifact';
|
|
3
3
|
import { Event } from '@dxos/async';
|
|
4
4
|
import { ObjectVersion } from '@dxos/echo-db';
|
|
@@ -226,8 +226,8 @@ export declare class AISession {
|
|
|
226
226
|
private _createPlanningTool;
|
|
227
227
|
abort(): void;
|
|
228
228
|
}
|
|
229
|
-
declare const AIServiecOverloadedError_base:
|
|
230
|
-
readonly _tag:
|
|
229
|
+
declare const AIServiecOverloadedError_base: S.TaggedErrorClass<AIServiecOverloadedError, "AIServiecOverloadedError", {
|
|
230
|
+
readonly _tag: S.tag<"AIServiecOverloadedError">;
|
|
231
231
|
}>;
|
|
232
232
|
export declare class AIServiecOverloadedError extends AIServiecOverloadedError_base {
|
|
233
233
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/session/session.ts"],"names":[],"mappings":"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ypherTool: (dataSource: DataSource, schemaTypes?:
|
|
4
|
-
export declare const createSystemPrompt: (schemaTypes:
|
|
3
|
+
export declare const createCypherTool: (dataSource: DataSource, schemaTypes?: S.Schema.Any[]) => import("@dxos/artifact").Tool;
|
|
4
|
+
export declare const createSystemPrompt: (schemaTypes: S.Schema.Any[]) => string;
|
|
5
5
|
//# sourceMappingURL=query-promts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-promts.d.ts","sourceRoot":"","sources":["../../../../src/testing/query-promts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"query-promts.d.ts","sourceRoot":"","sources":["../../../../src/testing/query-promts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAMrC,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAGlF,eAAO,MAAM,gBAAgB,eAAgB,UAAU,gBAAe,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,kCA0ChF,CAAC;AAEL,eAAO,MAAM,kBAAkB,gBAAiB,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,WAiB7D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Schema } from 'effect';
|
|
1
|
+
import { type Schema as S } from 'effect';
|
|
2
2
|
import type { EchoDatabase } from '@dxos/echo-db';
|
|
3
3
|
import { type JsonSchemaType } from '@dxos/echo-schema';
|
|
4
4
|
import { type DataSource, type Node, type Relationship } from '../cypher';
|
|
@@ -6,14 +6,14 @@ export declare const seedTestData: (db: EchoDatabase) => void;
|
|
|
6
6
|
export declare const createTestData: () => MockDataSource;
|
|
7
7
|
export declare class MockDataSource implements DataSource {
|
|
8
8
|
objects: Record<string, {
|
|
9
|
-
schema:
|
|
9
|
+
schema: S.Schema.All;
|
|
10
10
|
typeDxn: string;
|
|
11
11
|
id: string;
|
|
12
12
|
data: unknown;
|
|
13
13
|
}>;
|
|
14
14
|
schema: Record<string, {
|
|
15
15
|
json: JsonSchemaType;
|
|
16
|
-
instance:
|
|
16
|
+
instance: S.Schema.All;
|
|
17
17
|
}>;
|
|
18
18
|
nodes: Node[];
|
|
19
19
|
relationships: Relationship[];
|
|
@@ -23,7 +23,7 @@ export declare class MockDataSource implements DataSource {
|
|
|
23
23
|
getRelationships({ label }: {
|
|
24
24
|
label?: string;
|
|
25
25
|
}): Promise<Relationship[]>;
|
|
26
|
-
add<S extends
|
|
26
|
+
add<S extends S.Schema.All>(schema: S, data: S.Schema.Type<S>): S.Schema.Type<S>;
|
|
27
27
|
computeGraph(): void;
|
|
28
28
|
}
|
|
29
29
|
//# sourceMappingURL=test-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-data.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-data.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"test-data.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-data.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAmD,KAAK,cAAc,EAAY,MAAM,mBAAmB,CAAC;AAInH,OAAO,EACL,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,YAAY,EAGlB,MAAM,WAAW,CAAC;AAGnB,eAAO,MAAM,YAAY,OAAQ,YAAY,SAoH5C,CAAC;AAGF,eAAO,MAAM,cAAc,QAAO,cAuGjC,CAAC;AAEF,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,EAAE,MAAM,CACb,MAAM,EACN;QACE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,OAAO,CAAC;KACf,CACF,CAAM;IAEP,MAAM,EAAE,MAAM,CACZ,MAAM,EACN;QACE,IAAI,EAAE,cAAc,CAAC;QACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;KACxB,CACF,CAAM;IAEP,KAAK,EAAE,IAAI,EAAE,CAAM;IACnB,aAAa,EAAE,YAAY,EAAE,CAAM;IAE7B,QAAQ,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC,gBAAgB,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;IAIpD,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAsB7D,YAAY;CA0Eb"}
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { Schema } from 'effect';
|
|
2
|
-
|
|
3
|
-
export declare const Contact:
|
|
4
|
-
id:
|
|
5
|
-
name:
|
|
6
|
-
email:
|
|
1
|
+
import { Schema as S } from 'effect';
|
|
2
|
+
export declare const ObjectId: S.SchemaClass<string, string, never>;
|
|
3
|
+
export declare const Contact: S.mutable<S.Struct<{
|
|
4
|
+
id: S.SchemaClass<string, string, never>;
|
|
5
|
+
name: S.SchemaClass<string, string, never>;
|
|
6
|
+
email: S.optional<typeof S.String>;
|
|
7
7
|
}>>;
|
|
8
|
-
export interface Contact extends
|
|
8
|
+
export interface Contact extends S.Schema.Type<typeof Contact> {
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
description: Schema.optional<typeof Schema.String>;
|
|
10
|
+
export declare const Project: S.mutable<S.Struct<{
|
|
11
|
+
id: S.SchemaClass<string, string, never>;
|
|
12
|
+
name: S.SchemaClass<string, string, never>;
|
|
13
|
+
description: S.optional<typeof S.String>;
|
|
15
14
|
}>>;
|
|
16
|
-
export interface Project extends
|
|
15
|
+
export interface Project extends S.Schema.Type<typeof Project> {
|
|
17
16
|
}
|
|
18
|
-
export declare const Task:
|
|
19
|
-
id:
|
|
20
|
-
name:
|
|
21
|
-
description:
|
|
17
|
+
export declare const Task: S.mutable<S.Struct<{
|
|
18
|
+
id: S.SchemaClass<string, string, never>;
|
|
19
|
+
name: S.SchemaClass<string, string, never>;
|
|
20
|
+
description: S.optional<typeof S.String>;
|
|
22
21
|
project: import("@dxos/echo-schema").Ref$<{
|
|
23
22
|
name: string;
|
|
24
23
|
description?: string | undefined;
|
|
@@ -30,23 +29,22 @@ export declare const Task: Schema.mutable<Schema.Struct<{
|
|
|
30
29
|
email?: string | undefined;
|
|
31
30
|
}>;
|
|
32
31
|
}>>;
|
|
33
|
-
export interface Task extends
|
|
32
|
+
export interface Task extends S.Schema.Type<typeof Task> {
|
|
34
33
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
projects: Schema.Array$<import("@dxos/echo-schema").Ref$<{
|
|
34
|
+
export declare const Organization: S.mutable<S.Struct<{
|
|
35
|
+
id: S.SchemaClass<string, string, never>;
|
|
36
|
+
name: S.SchemaClass<string, string, never>;
|
|
37
|
+
projects: S.Array$<import("@dxos/echo-schema").Ref$<{
|
|
40
38
|
name: string;
|
|
41
39
|
description?: string | undefined;
|
|
42
40
|
id: string;
|
|
43
41
|
}>>;
|
|
44
|
-
employees:
|
|
42
|
+
employees: S.Array$<import("@dxos/echo-schema").Ref$<{
|
|
45
43
|
name: string;
|
|
46
44
|
id: string;
|
|
47
45
|
email?: string | undefined;
|
|
48
46
|
}>>;
|
|
49
47
|
}>>;
|
|
50
|
-
export interface Organization extends
|
|
48
|
+
export interface Organization extends S.Schema.Type<typeof Organization> {
|
|
51
49
|
}
|
|
52
50
|
//# sourceMappingURL=test-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-schema.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"test-schema.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAQrC,eAAO,MAAM,QAAQ,sCAAyE,CAAC;AAE/F,eAAO,MAAM,OAAO;;;;GAahB,CAAC;AACL,MAAM,WAAW,OAAQ,SAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC;CAAG;AAEjE,eAAO,MAAM,OAAO;;;;GAahB,CAAC;AACL,MAAM,WAAW,OAAQ,SAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,OAAO,CAAC;CAAG;AAEjE,eAAO,MAAM,IAAI;;;;;;;;;;;;;;GAeb,CAAC;AACL,MAAM,WAAW,IAAK,SAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC;CAAG;AAE3D,eAAO,MAAM,YAAY;;;;;;;;;;;;;GAcrB,CAAC;AACL,MAAM,WAAW,YAAa,SAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC;CAAG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/assistant",
|
|
3
|
-
"version": "0.8.2-main.
|
|
3
|
+
"version": "0.8.2-main.36232bc",
|
|
4
4
|
"description": "Natural language interface to DXOS",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -40,23 +40,22 @@
|
|
|
40
40
|
"parjs": "^1.3.9",
|
|
41
41
|
"parsimmon": "^1.18.1",
|
|
42
42
|
"ulidx": "^2.3.0",
|
|
43
|
-
"@dxos/artifact": "0.8.2-main.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/debug": "0.8.2-main.
|
|
47
|
-
"@dxos/echo": "0.8.2-main.
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/log": "0.8.2-main.
|
|
53
|
-
"@dxos/node-std": "0.8.2-main.
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/util": "0.8.2-main.2f9c567"
|
|
43
|
+
"@dxos/artifact": "0.8.2-main.36232bc",
|
|
44
|
+
"@dxos/async": "0.8.2-main.36232bc",
|
|
45
|
+
"@dxos/context": "0.8.2-main.36232bc",
|
|
46
|
+
"@dxos/debug": "0.8.2-main.36232bc",
|
|
47
|
+
"@dxos/echo-schema": "0.8.2-main.36232bc",
|
|
48
|
+
"@dxos/invariant": "0.8.2-main.36232bc",
|
|
49
|
+
"@dxos/keys": "0.8.2-main.36232bc",
|
|
50
|
+
"@dxos/echo-db": "0.8.2-main.36232bc",
|
|
51
|
+
"@dxos/live-object": "0.8.2-main.36232bc",
|
|
52
|
+
"@dxos/log": "0.8.2-main.36232bc",
|
|
53
|
+
"@dxos/node-std": "0.8.2-main.36232bc",
|
|
54
|
+
"@dxos/util": "0.8.2-main.36232bc"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@types/parsimmon": "^1.10.9",
|
|
59
|
-
"effect": "3.
|
|
58
|
+
"effect": "3.13.3",
|
|
60
59
|
"inquirer": "^12.0.0"
|
|
61
60
|
},
|
|
62
61
|
"peerDependencies": {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
import { test, describe } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { defineTool, Message, ToolResult, type Tool } from '@dxos/artifact';
|
|
@@ -58,8 +58,8 @@ describe.skip('AI Service Client', () => {
|
|
|
58
58
|
name: 'custodian',
|
|
59
59
|
description: 'Custodian can tell you the password if you say the magic word',
|
|
60
60
|
parameters: toJsonSchema(
|
|
61
|
-
|
|
62
|
-
magicWord:
|
|
61
|
+
S.Struct({
|
|
62
|
+
magicWord: S.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
|
|
63
63
|
}),
|
|
64
64
|
),
|
|
65
65
|
};
|
|
@@ -194,8 +194,8 @@ describe.skip('Ollama Client', () => {
|
|
|
194
194
|
defineTool('test', {
|
|
195
195
|
name: 'encrypt',
|
|
196
196
|
description: 'Encrypt a message',
|
|
197
|
-
schema:
|
|
198
|
-
message:
|
|
197
|
+
schema: S.Struct({
|
|
198
|
+
message: S.String.annotations({ description: 'The message to encrypt' }),
|
|
199
199
|
}),
|
|
200
200
|
execute: async ({ message }) => ToolResult.Success(message.split('').reverse().join('')),
|
|
201
201
|
}),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { type MessageContentBlock, defineTool, type Tool, ToolResult } from '@dxos/artifact';
|
|
8
8
|
import { ObjectId } from '@dxos/echo-schema';
|
|
@@ -388,8 +388,8 @@ const WELL_KNOWN_TOOLS: Record<string, Tool> = {
|
|
|
388
388
|
[ToolTypes.TextToImage]: defineTool('system', {
|
|
389
389
|
name: 'text-to-image',
|
|
390
390
|
description: 'Generate an image from a text prompt',
|
|
391
|
-
schema:
|
|
392
|
-
prompt:
|
|
391
|
+
schema: S.Struct({
|
|
392
|
+
prompt: S.String.annotations({ description: 'The text prompt describing the image to generate' }),
|
|
393
393
|
}),
|
|
394
394
|
execute: async ({ prompt }) => {
|
|
395
395
|
const image = await fetch(SAMPLE_IMAGE_URL).then(async (res) => Buffer.from(await res.arrayBuffer()));
|
|
@@ -467,15 +467,15 @@ class OllamaDecoderStream extends TransformStream<string, OllamaResponseData> {
|
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
-
class ModelDoesNotSupportToolsError extends
|
|
470
|
+
class ModelDoesNotSupportToolsError extends S.TaggedError<ModelDoesNotSupportToolsError>()(
|
|
471
471
|
'ModelDoesNotSupportToolsError',
|
|
472
472
|
{
|
|
473
|
-
model:
|
|
473
|
+
model: S.String,
|
|
474
474
|
},
|
|
475
475
|
) {}
|
|
476
476
|
|
|
477
|
-
class ModelNotFoundError extends
|
|
478
|
-
model:
|
|
477
|
+
class ModelNotFoundError extends S.TaggedError<ModelNotFoundError>()('ModelNotFoundError', {
|
|
478
|
+
model: S.String,
|
|
479
479
|
}) {}
|
|
480
480
|
|
|
481
481
|
const parseOllamaError = (error: string): Error => {
|
package/src/ai-service/types.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { Tool, Message, type MessageContentBlock } from '@dxos/artifact';
|
|
8
8
|
import { type ObjectId } from '@dxos/echo-schema';
|
|
@@ -11,9 +11,9 @@ import { DEFAULT_EDGE_MODELS, DEFAULT_OLLAMA_MODELS } from './defs';
|
|
|
11
11
|
|
|
12
12
|
export const createArtifactElement = (id: ObjectId) => `<artifact id=${id} />`;
|
|
13
13
|
|
|
14
|
-
export const LLMModel =
|
|
14
|
+
export const LLMModel = S.Literal(...DEFAULT_EDGE_MODELS, ...DEFAULT_OLLAMA_MODELS);
|
|
15
15
|
|
|
16
|
-
export type LLMModel =
|
|
16
|
+
export type LLMModel = S.Schema.Type<typeof LLMModel>;
|
|
17
17
|
|
|
18
18
|
export const ToolTypes = Object.freeze({
|
|
19
19
|
// TODO(dmaretskyi): Not implemented yet.
|
|
@@ -24,47 +24,47 @@ export const ToolTypes = Object.freeze({
|
|
|
24
24
|
/**
|
|
25
25
|
* Client GPT request.
|
|
26
26
|
*/
|
|
27
|
-
export const GenerateRequest =
|
|
27
|
+
export const GenerateRequest = S.Struct({
|
|
28
28
|
/**
|
|
29
29
|
* Preferred model or system default.
|
|
30
30
|
*/
|
|
31
|
-
model:
|
|
31
|
+
model: S.optional(LLMModel),
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Tools available for the LLM.
|
|
35
35
|
*/
|
|
36
|
-
tools:
|
|
36
|
+
tools: S.optional(S.Array(Tool).pipe(S.mutable)),
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* System instructions to the LLM.
|
|
40
40
|
*/
|
|
41
|
-
systemPrompt:
|
|
41
|
+
systemPrompt: S.optional(S.String),
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* History of messages to include in the context window.
|
|
45
45
|
*/
|
|
46
46
|
// TODO(burdon): Rename messages.
|
|
47
|
-
history:
|
|
47
|
+
history: S.optional(S.Array(Message)),
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Current request.
|
|
51
51
|
*/
|
|
52
|
-
prompt:
|
|
52
|
+
prompt: S.optional(Message),
|
|
53
53
|
});
|
|
54
|
-
export type GenerateRequest =
|
|
54
|
+
export type GenerateRequest = S.Schema.Type<typeof GenerateRequest>;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Non-streaming response.
|
|
58
58
|
*/
|
|
59
|
-
export const GenerateResponse =
|
|
60
|
-
messages:
|
|
59
|
+
export const GenerateResponse = S.Struct({
|
|
60
|
+
messages: S.Array(Message),
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Number of tokens used in the response.
|
|
64
64
|
*/
|
|
65
|
-
tokenCount:
|
|
65
|
+
tokenCount: S.optional(S.Number),
|
|
66
66
|
});
|
|
67
|
-
export type GenerateResponse =
|
|
67
|
+
export type GenerateResponse = S.Schema.Type<typeof GenerateResponse>;
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* Server-Sent Events (SSE) stream from the AI service.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
import { describe, test } from 'vitest';
|
|
7
7
|
|
|
8
8
|
import { createUserMessage, defineTool, ToolResult } from '@dxos/artifact';
|
|
@@ -40,8 +40,8 @@ describe.skip('Conversation tests', () => {
|
|
|
40
40
|
const custodian = defineTool('testing', {
|
|
41
41
|
name: 'custodian',
|
|
42
42
|
description: 'Custodian can tell you the password if you say the magic word',
|
|
43
|
-
schema:
|
|
44
|
-
magicWord:
|
|
43
|
+
schema: S.Struct({
|
|
44
|
+
magicWord: S.String.annotations({ description: 'The magic word. Should be exactly "pretty please"' }),
|
|
45
45
|
}),
|
|
46
46
|
execute: async ({ magicWord }) => {
|
|
47
47
|
if (magicWord === 'pretty please') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
|
|
7
7
|
import { type Message, type MessageContentBlock } from '@dxos/artifact';
|
|
8
8
|
import { toJsonSchema, JsonSchemaType, ObjectId } from '@dxos/echo-schema';
|
|
@@ -17,11 +17,11 @@ export const createUserMessage = (text: string): Message => ({
|
|
|
17
17
|
/**
|
|
18
18
|
* @deprecated Use {@link LLMTool} instead.
|
|
19
19
|
*/
|
|
20
|
-
export const ToolDefinition =
|
|
21
|
-
name:
|
|
22
|
-
description:
|
|
20
|
+
export const ToolDefinition = S.Struct({
|
|
21
|
+
name: S.String,
|
|
22
|
+
description: S.String,
|
|
23
23
|
parameters: JsonSchemaType,
|
|
24
|
-
execute:
|
|
24
|
+
execute: S.Any,
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -83,14 +83,14 @@ export const ToolResult = Object.freeze({
|
|
|
83
83
|
Break: (result: unknown): ToolResult => ({ kind: 'break', result }),
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
-
export type DefineToolParams<Params extends
|
|
86
|
+
export type DefineToolParams<Params extends S.Schema.AnyNoContext> = {
|
|
87
87
|
name: string;
|
|
88
88
|
description: string;
|
|
89
89
|
schema: Params;
|
|
90
|
-
execute: (params:
|
|
90
|
+
execute: (params: S.Schema.Type<Params>, context: ToolExecutionContext) => Promise<ToolResult>;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
-
export const defineTool = <Params extends
|
|
93
|
+
export const defineTool = <Params extends S.Schema.AnyNoContext>({
|
|
94
94
|
name,
|
|
95
95
|
description,
|
|
96
96
|
schema,
|
|
@@ -101,7 +101,7 @@ export const defineTool = <Params extends Schema.Schema.AnyNoContext>({
|
|
|
101
101
|
description,
|
|
102
102
|
parameters: toFunctionParameterSchema(schema),
|
|
103
103
|
execute: (params, context) => {
|
|
104
|
-
const sanitized =
|
|
104
|
+
const sanitized = S.decodeSync(schema)(params);
|
|
105
105
|
return execute(sanitized, context);
|
|
106
106
|
},
|
|
107
107
|
};
|
|
@@ -110,7 +110,7 @@ export const defineTool = <Params extends Schema.Schema.AnyNoContext>({
|
|
|
110
110
|
/**
|
|
111
111
|
* Adapts schems to be able to pass to AI providers.
|
|
112
112
|
*/
|
|
113
|
-
const toFunctionParameterSchema = (schema:
|
|
113
|
+
const toFunctionParameterSchema = (schema: S.Schema.All) => {
|
|
114
114
|
const jsonSchema = toJsonSchema(schema);
|
|
115
115
|
log('tool schema', { jsonSchema });
|
|
116
116
|
delete jsonSchema.anyOf;
|
|
@@ -2,11 +2,9 @@
|
|
|
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 { getSchema, getSchemaTypename, StoredSchema, toJsonSchema } from '@dxos/echo-schema';
|
|
6
|
+
import { type EchoDatabase, Filter, type ReactiveEchoObject } from '@dxos/echo-db';
|
|
7
|
+
import { getSchema, getSchemaTypename, type S, StoredSchema, toJsonSchema } from '@dxos/echo-schema';
|
|
10
8
|
import { log } from '@dxos/log';
|
|
11
9
|
|
|
12
10
|
import type { DataSource, Node, Relationship } from './query-executor';
|
|
@@ -64,7 +62,7 @@ export class EchoDataSource implements DataSource {
|
|
|
64
62
|
).flat();
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
private async _getAllSchema(): Promise<
|
|
65
|
+
private async _getAllSchema(): Promise<S.Schema.AnyNoContext[]> {
|
|
68
66
|
return [
|
|
69
67
|
...(await this._db.schemaRegistry.query().run()),
|
|
70
68
|
// TODO(dmaretskyi): Remove once we can serialize recursive schema.
|
|
@@ -72,7 +70,7 @@ export class EchoDataSource implements DataSource {
|
|
|
72
70
|
].filter((schema) => getSchemaTypename(schema) !== StoredSchema.typename);
|
|
73
71
|
}
|
|
74
72
|
|
|
75
|
-
private _objectToNode(object:
|
|
73
|
+
private _objectToNode(object: ReactiveEchoObject<any>): Node {
|
|
76
74
|
const { id, ...properties } = object;
|
|
77
75
|
return {
|
|
78
76
|
id,
|
|
@@ -82,7 +80,7 @@ export class EchoDataSource implements DataSource {
|
|
|
82
80
|
};
|
|
83
81
|
}
|
|
84
82
|
|
|
85
|
-
private async _projectRefRelationship(object:
|
|
83
|
+
private async _projectRefRelationship(object: ReactiveEchoObject<any>, prop: string): Promise<Relationship[]> {
|
|
86
84
|
if (!object[prop]) {
|
|
87
85
|
return [];
|
|
88
86
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
5
|
+
import { Schema as S } from 'effect';
|
|
6
6
|
import { inspect } from 'node:util';
|
|
7
7
|
import { describe, test } from 'vitest';
|
|
8
8
|
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
type MessageContentBlock,
|
|
16
16
|
} from '@dxos/artifact';
|
|
17
17
|
import { AIServiceEdgeClient } from '@dxos/assistant';
|
|
18
|
-
import {
|
|
19
|
-
import { create, ObjectId } from '@dxos/echo-schema';
|
|
18
|
+
import { create, EchoObject, ObjectId } from '@dxos/echo-schema';
|
|
20
19
|
import { DXN } from '@dxos/keys';
|
|
21
20
|
import { log } from '@dxos/log';
|
|
22
21
|
|
|
@@ -24,19 +23,14 @@ import { AISession } from './session';
|
|
|
24
23
|
import { AI_SERVICE_ENDPOINT } from '../testing';
|
|
25
24
|
|
|
26
25
|
// Define a calendar event artifact schema.
|
|
27
|
-
const CalendarEventSchema =
|
|
28
|
-
title:
|
|
29
|
-
startTime:
|
|
30
|
-
endTime:
|
|
31
|
-
description:
|
|
32
|
-
}).pipe(
|
|
33
|
-
Type.def({
|
|
34
|
-
typename: 'example.com/type/CalendarEvent',
|
|
35
|
-
version: '0.1.0',
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
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' }));
|
|
38
32
|
|
|
39
|
-
type CalendarEvent =
|
|
33
|
+
type CalendarEvent = S.Schema.Type<typeof CalendarEventSchema>;
|
|
40
34
|
|
|
41
35
|
// TODO(burdon): Flaky.
|
|
42
36
|
describe.skip('AISession with Ollama', () => {
|
|
@@ -59,7 +53,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
59
53
|
defineTool('calendar', {
|
|
60
54
|
name: 'query',
|
|
61
55
|
description: 'Query the calendar for events',
|
|
62
|
-
schema:
|
|
56
|
+
schema: S.Struct({}),
|
|
63
57
|
execute: async () => {
|
|
64
58
|
return ToolResult.Success(CALENDAR_EVENTS);
|
|
65
59
|
},
|
|
@@ -71,13 +65,13 @@ describe.skip('AISession with Ollama', () => {
|
|
|
71
65
|
id: 'artifact:dxos.org/plugin/table',
|
|
72
66
|
name: 'Table',
|
|
73
67
|
instructions: 'Use this to create and manage tables. Each table has a unique id.',
|
|
74
|
-
schema:
|
|
68
|
+
schema: S.Struct({}),
|
|
75
69
|
tools: [
|
|
76
70
|
defineTool('table', {
|
|
77
71
|
name: 'create',
|
|
78
72
|
description: 'Create a table',
|
|
79
|
-
schema:
|
|
80
|
-
data:
|
|
73
|
+
schema: S.Struct({
|
|
74
|
+
data: S.Array(S.Any).annotations({ description: 'Array of data payloads to add as rows' }),
|
|
81
75
|
}),
|
|
82
76
|
execute: async ({ data }) => {
|
|
83
77
|
log('create table', { data });
|
|
@@ -95,12 +89,12 @@ describe.skip('AISession with Ollama', () => {
|
|
|
95
89
|
name: 'Map',
|
|
96
90
|
instructions:
|
|
97
91
|
'Use this to create and manage maps. Maps source data from tables. Table id is required to create a map.',
|
|
98
|
-
schema:
|
|
92
|
+
schema: S.Struct({}),
|
|
99
93
|
tools: [
|
|
100
94
|
defineTool('map', {
|
|
101
95
|
name: 'create',
|
|
102
96
|
description: 'Create a map',
|
|
103
|
-
schema:
|
|
97
|
+
schema: S.Struct({
|
|
104
98
|
source: ArtifactId.annotations({
|
|
105
99
|
description: 'The table that will be used as the source of the map',
|
|
106
100
|
}),
|
|
@@ -125,7 +119,7 @@ describe.skip('AISession with Ollama', () => {
|
|
|
125
119
|
id: 'artifact:dxos.org/plugin/script',
|
|
126
120
|
name: 'Script',
|
|
127
121
|
instructions: 'Use this to create and manage scripts',
|
|
128
|
-
schema:
|
|
122
|
+
schema: S.Struct({}),
|
|
129
123
|
tools: [],
|
|
130
124
|
});
|
|
131
125
|
|