@dxos/assistant 0.7.4 → 0.7.5-labs.071a3e2
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-AXUUNA7O.mjs +565 -0
- package/dist/lib/browser/chunk-AXUUNA7O.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1212 -47
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +15 -9
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/chunk-QPHGQINW.cjs +577 -0
- package/dist/lib/node/chunk-QPHGQINW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +1212 -54
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +21 -14
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/chunk-GOVFOBIB.mjs +567 -0
- package/dist/lib/node-esm/chunk-GOVFOBIB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1212 -47
- 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 +15 -9
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/client.d.ts +16 -32
- package/dist/types/src/ai-service/client.d.ts.map +1 -1
- package/dist/types/src/ai-service/index.d.ts +4 -1
- package/dist/types/src/ai-service/index.d.ts.map +1 -1
- package/dist/types/src/ai-service/parser.d.ts +136 -0
- package/dist/types/src/ai-service/parser.d.ts.map +1 -0
- package/dist/types/src/ai-service/stream.d.ts +39 -0
- package/dist/types/src/ai-service/stream.d.ts.map +1 -0
- package/dist/types/src/ai-service/stream.test.d.ts +2 -0
- package/dist/types/src/ai-service/stream.test.d.ts.map +1 -0
- package/dist/types/src/ai-service/testing.d.ts +7 -0
- package/dist/types/src/ai-service/testing.d.ts.map +1 -0
- package/dist/types/src/ai-service/transform.d.ts +27 -0
- package/dist/types/src/ai-service/transform.d.ts.map +1 -0
- package/dist/types/src/ai-service/types.d.ts +150 -0
- package/dist/types/src/ai-service/types.d.ts.map +1 -0
- package/dist/types/src/ai-service/util/index.d.ts +2 -0
- package/dist/types/src/ai-service/util/index.d.ts.map +1 -0
- package/dist/types/src/ai-service/{sse.d.ts → util/sse.d.ts} +5 -0
- package/dist/types/src/ai-service/util/sse.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.d.ts +61 -6
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/index.d.ts +0 -1
- package/dist/types/src/conversation/index.d.ts.map +1 -1
- package/dist/types/src/conversation/types.d.ts +44 -13
- package/dist/types/src/conversation/types.d.ts.map +1 -1
- package/dist/types/src/cypher/combinators.d.ts.map +1 -1
- package/dist/types/src/cypher/parjs.d.ts +1 -1
- package/dist/types/src/cypher/parjs.d.ts.map +1 -1
- package/dist/types/src/cypher/schema.d.ts.map +1 -1
- package/dist/types/src/testing/artifacts.test.d.ts +1 -0
- package/dist/types/src/testing/artifacts.test.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +2 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/defs.d.ts +5 -0
- package/dist/types/src/testing/defs.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -0
- 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/query-promts.d.ts +1 -1
- package/dist/types/src/testing/query-promts.d.ts.map +1 -1
- package/dist/types/src/testing/test-data.d.ts +1 -1
- package/dist/types/src/testing/test-data.d.ts.map +1 -1
- package/dist/types/src/testing/test-schema.d.ts +4 -4
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -18
- package/src/ai-service/client.test.ts +69 -54
- package/src/ai-service/client.ts +29 -184
- package/src/ai-service/index.ts +4 -1
- package/src/ai-service/parser.ts +338 -0
- package/src/ai-service/stream.test.ts +101 -0
- package/src/ai-service/stream.ts +116 -0
- package/src/ai-service/testing.ts +93 -0
- package/src/ai-service/transform.ts +121 -0
- package/src/ai-service/types.ts +107 -0
- package/src/ai-service/util/index.ts +5 -0
- package/src/ai-service/{sse.ts → util/sse.ts} +5 -0
- package/src/bin/chat.ts +10 -11
- package/src/conversation/conversation.test.ts +16 -17
- package/src/conversation/conversation.ts +126 -20
- package/src/conversation/index.ts +0 -1
- package/src/conversation/types.ts +55 -16
- package/src/cypher/combinators.test.ts +4 -4
- package/src/cypher/combinators.ts +0 -1
- package/src/cypher/execution-plan.test.ts +5 -3
- package/src/cypher/parjs-shims.d.ts +4 -0
- package/src/cypher/parjs.ts +2 -2
- package/src/cypher/query-executor.test.ts +1 -1
- package/src/cypher/schema.ts +6 -2
- package/src/index.ts +1 -1
- package/src/testing/artifacts.test.ts +182 -0
- package/src/testing/data.ts +13 -0
- package/src/testing/defs.ts +8 -0
- package/src/testing/index.ts +1 -0
- package/src/testing/logger.ts +3 -2
- package/src/testing/query-promts.ts +3 -3
- package/src/testing/query.test.ts +11 -10
- package/src/testing/test-data.ts +8 -2
- package/vendor/parjs-browser.mjs +4 -0
- package/vendor/parjs-default.mjs +8 -0
- package/dist/lib/browser/chunk-AKP45LQH.mjs +0 -1394
- package/dist/lib/browser/chunk-AKP45LQH.mjs.map +0 -7
- package/dist/lib/node/chunk-G6CGWEMO.cjs +0 -1418
- package/dist/lib/node/chunk-G6CGWEMO.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPUPEFB.mjs +0 -1396
- package/dist/lib/node-esm/chunk-WUPUPEFB.mjs.map +0 -7
- package/dist/types/src/ai-service/schema.d.ts +0 -296
- package/dist/types/src/ai-service/schema.d.ts.map +0 -1
- package/dist/types/src/ai-service/sse.d.ts.map +0 -1
- package/dist/types/src/sanity.test.d.ts +0 -2
- package/dist/types/src/sanity.test.d.ts.map +0 -1
- package/src/ai-service/schema.ts +0 -260
- package/src/sanity.test.ts +0 -9
package/src/testing/index.ts
CHANGED
package/src/testing/logger.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type { ImageSource, MessageContentBlock } from '
|
|
5
|
+
import type { ImageSource, MessageContentBlock } from '@dxos/artifact';
|
|
6
|
+
|
|
6
7
|
import type { ConversationEvent } from '../conversation';
|
|
7
8
|
|
|
8
9
|
export const createLogger = ({
|
|
@@ -34,7 +35,7 @@ export const createLogger = ({
|
|
|
34
35
|
if (content.id && content.source) {
|
|
35
36
|
images[content.id] = content.source;
|
|
36
37
|
}
|
|
37
|
-
process.stdout.write(`[Image id=${content.id}
|
|
38
|
+
process.stdout.write(`[Image id=${content.id} mediaType=${content.source?.mediaType}]`);
|
|
38
39
|
break;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { Schema as S } from '@effect/schema';
|
|
6
6
|
|
|
7
|
+
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
7
8
|
import { toJsonSchema } from '@dxos/echo-schema';
|
|
8
9
|
import { log } from '@dxos/log';
|
|
9
10
|
|
|
10
|
-
import { defineTool, LLMToolResult } from '../conversation';
|
|
11
11
|
import { executeQuery, formatJsonSchemaForLLM, type DataSource } from '../cypher';
|
|
12
12
|
import { trim } from '../util';
|
|
13
13
|
|
|
@@ -47,10 +47,10 @@ export const createCypherTool = (dataSource: DataSource, schemaTypes: S.Schema.A
|
|
|
47
47
|
log('cypher query', { query });
|
|
48
48
|
const results = await executeQuery(dataSource, query);
|
|
49
49
|
log('query complete', { results });
|
|
50
|
-
return
|
|
50
|
+
return ToolResult.Success(results);
|
|
51
51
|
} catch (e: any) {
|
|
52
52
|
log.catch(e);
|
|
53
|
-
return
|
|
53
|
+
return ToolResult.Error(e.message);
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
});
|
|
@@ -4,22 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
import { test } from 'vitest';
|
|
6
6
|
|
|
7
|
+
import { createUserMessage } from '@dxos/artifact';
|
|
8
|
+
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
9
|
+
import { ObjectId } from '@dxos/echo-schema';
|
|
7
10
|
import { SpaceId } from '@dxos/keys';
|
|
8
11
|
import { log } from '@dxos/log';
|
|
9
|
-
import { EchoTestBuilder } from '@dxos/echo-db/testing';
|
|
10
12
|
|
|
13
|
+
import { AI_SERVICE_ENDPOINT } from './defs';
|
|
11
14
|
import { createLogger } from './logger';
|
|
12
15
|
import { createCypherTool, createSystemPrompt } from './query-promts';
|
|
13
16
|
import { createTestData, seedTestData } from './test-data';
|
|
14
17
|
import { Contact, Org, Project, Task } from './test-schema';
|
|
15
|
-
import { AIServiceClientImpl
|
|
16
|
-
import { runLLM
|
|
17
|
-
import { EchoDataSource } from '../cypher
|
|
18
|
-
|
|
19
|
-
const ENDPOINT = 'http://localhost:8787';
|
|
18
|
+
import { AIServiceClientImpl } from '../ai-service';
|
|
19
|
+
import { runLLM } from '../conversation';
|
|
20
|
+
import { EchoDataSource } from '../cypher';
|
|
20
21
|
|
|
21
22
|
const client = new AIServiceClientImpl({
|
|
22
|
-
endpoint:
|
|
23
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
test.skip('cypher query', async () => {
|
|
@@ -31,7 +32,7 @@ test.skip('cypher query', async () => {
|
|
|
31
32
|
const spaceId = SpaceId.random();
|
|
32
33
|
const threadId = ObjectId.random();
|
|
33
34
|
|
|
34
|
-
await client.
|
|
35
|
+
await client.appendMessages([
|
|
35
36
|
createUserMessage(
|
|
36
37
|
spaceId,
|
|
37
38
|
threadId,
|
|
@@ -52,7 +53,7 @@ test.skip('cypher query', async () => {
|
|
|
52
53
|
log.info('DONE', { result: result.result });
|
|
53
54
|
});
|
|
54
55
|
|
|
55
|
-
test.
|
|
56
|
+
test.skip('query ECHO', async () => {
|
|
56
57
|
await using builder = await new EchoTestBuilder().open();
|
|
57
58
|
const { db, graph } = await builder.createDatabase();
|
|
58
59
|
|
|
@@ -68,7 +69,7 @@ test.only('query ECHO', async () => {
|
|
|
68
69
|
const spaceId = SpaceId.random();
|
|
69
70
|
const threadId = ObjectId.random();
|
|
70
71
|
|
|
71
|
-
await client.
|
|
72
|
+
await client.appendMessages([
|
|
72
73
|
createUserMessage(
|
|
73
74
|
spaceId,
|
|
74
75
|
threadId,
|
package/src/testing/test-data.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { type Schema as S } from '@effect/schema';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
+
import type { EchoDatabase } from '@dxos/echo-db';
|
|
8
9
|
import { JSON_SCHEMA_ECHO_REF_ID, ObjectId, toJsonSchema, type JsonSchemaType, type Ref } from '@dxos/echo-schema';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
11
|
import { create, makeRef } from '@dxos/live-object';
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
formatNodeLabel,
|
|
18
19
|
} from '../cypher';
|
|
19
20
|
import { Contact, Org, Project, Task } from '../testing';
|
|
20
|
-
import type { EchoDatabase } from '@dxos/echo-db';
|
|
21
21
|
|
|
22
22
|
export const seedTestData = (db: EchoDatabase) => {
|
|
23
23
|
const contactRich = db.add(
|
|
@@ -336,7 +336,13 @@ export class MockDataSource implements DataSource {
|
|
|
336
336
|
source,
|
|
337
337
|
target,
|
|
338
338
|
});
|
|
339
|
-
} else if (
|
|
339
|
+
} else if (
|
|
340
|
+
propSchema.type === 'array' &&
|
|
341
|
+
propSchema.items &&
|
|
342
|
+
typeof propSchema.items === 'object' &&
|
|
343
|
+
'$id' in propSchema.items &&
|
|
344
|
+
propSchema.items.$id === JSON_SCHEMA_ECHO_REF_ID
|
|
345
|
+
) {
|
|
340
346
|
const label = formatInferredRelationshipLabel(typenameDxn, name);
|
|
341
347
|
|
|
342
348
|
const source = this.nodes.find((node) => node.id === object.id);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
|
|
3
|
+
// TODO(dmaretskyi): Must be like this or it breaks vitest.
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
const parjs = require('parjs');
|
|
6
|
+
const parjsCombinators = require('parjs/combinators');
|
|
7
|
+
|
|
8
|
+
export { parjsCombinators, parjs };
|