@dxos/assistant 0.8.0 → 0.8.1-main.81238a8
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-RFTY3OMK.mjs +2276 -0
- package/dist/lib/browser/chunk-RFTY3OMK.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +33 -1236
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +17 -3
- package/dist/lib/browser/testing/index.mjs.map +4 -4
- package/dist/lib/node/chunk-4ZDZUCAS.cjs +2287 -0
- package/dist/lib/node/chunk-4ZDZUCAS.cjs.map +7 -0
- package/dist/lib/node/index.cjs +40 -1236
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +40 -29
- package/dist/lib/node/testing/index.cjs.map +4 -4
- package/dist/lib/node-esm/chunk-JUVGBQBL.mjs +2278 -0
- package/dist/lib/node-esm/chunk-JUVGBQBL.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +33 -1236
- 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 +17 -3
- package/dist/lib/node-esm/testing/index.mjs.map +4 -4
- package/dist/types/src/ai-service/defs.d.ts +8 -2
- package/dist/types/src/ai-service/defs.d.ts.map +1 -1
- package/dist/types/src/ai-service/edge-client.d.ts +19 -0
- package/dist/types/src/ai-service/edge-client.d.ts.map +1 -0
- 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/message-collector.d.ts +88 -0
- package/dist/types/src/ai-service/message-collector.d.ts.map +1 -0
- package/dist/types/src/ai-service/ollama-client.d.ts +39 -0
- package/dist/types/src/ai-service/ollama-client.d.ts.map +1 -0
- package/dist/types/src/ai-service/parser.d.ts +11 -9
- package/dist/types/src/ai-service/parser.d.ts.map +1 -1
- package/dist/types/src/ai-service/service.d.ts +9 -0
- package/dist/types/src/ai-service/service.d.ts.map +1 -0
- package/dist/types/src/ai-service/stream.d.ts +2 -1
- package/dist/types/src/ai-service/stream.d.ts.map +1 -1
- package/dist/types/src/ai-service/testing/mock.d.ts +2 -2
- package/dist/types/src/ai-service/testing/mock.d.ts.map +1 -1
- package/dist/types/src/ai-service/types.d.ts +91 -157
- package/dist/types/src/ai-service/types.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.d.ts +11 -9
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/types.d.ts +1 -1
- package/dist/types/src/conversation/types.d.ts.map +1 -1
- 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/ollama.d.ts +6 -0
- package/dist/types/src/testing/ollama.d.ts.map +1 -0
- 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 +1 -1
- package/dist/types/src/testing/test-schema.d.ts.map +1 -1
- package/package.json +17 -14
- package/src/ai-service/client.test.ts +100 -13
- package/src/ai-service/defs.ts +17 -2
- package/src/ai-service/{client.ts → edge-client.ts} +15 -24
- package/src/ai-service/index.ts +4 -1
- package/src/ai-service/message-collector.ts +84 -0
- package/src/ai-service/ollama-client.ts +499 -0
- package/src/ai-service/parser.ts +7 -2
- package/src/ai-service/service.ts +15 -0
- package/src/ai-service/stream.ts +5 -3
- package/src/ai-service/testing/mock.ts +7 -2
- package/src/ai-service/types.ts +3 -3
- package/src/bin/chat.ts +3 -3
- package/src/conversation/conversation.test.ts +5 -5
- package/src/conversation/conversation.ts +3 -2
- package/src/conversation/types.ts +1 -1
- package/src/testing/artifacts.test.ts +4 -4
- package/src/testing/index.ts +1 -0
- package/src/testing/object-extraction.test.ts +1 -1
- package/src/testing/ollama.ts +15 -0
- package/src/testing/query-promts.ts +1 -1
- package/src/testing/query.test.ts +4 -4
- package/src/testing/test-data.ts +1 -1
- package/src/testing/test-schema.ts +1 -1
- package/dist/lib/browser/chunk-AXUUNA7O.mjs +0 -565
- package/dist/lib/browser/chunk-AXUUNA7O.mjs.map +0 -7
- package/dist/lib/node/chunk-QPHGQINW.cjs +0 -577
- package/dist/lib/node/chunk-QPHGQINW.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-GOVFOBIB.mjs +0 -567
- package/dist/lib/node-esm/chunk-GOVFOBIB.mjs.map +0 -7
- package/dist/types/src/ai-service/client.d.ts +0 -25
- package/dist/types/src/ai-service/client.d.ts.map +0 -1
|
@@ -147,10 +147,10 @@ export const runLLM = async (params: CreateLLMConversationParams) => {
|
|
|
147
147
|
};
|
|
148
148
|
};
|
|
149
149
|
|
|
150
|
-
export const isToolUse = (message: Message) => {
|
|
150
|
+
export const isToolUse = (message: Message, { onlyToolNames }: { onlyToolNames?: string[] } = {}) => {
|
|
151
151
|
const block = message.content.at(-1);
|
|
152
152
|
invariant(block);
|
|
153
|
-
return block.type === 'tool_use';
|
|
153
|
+
return block.type === 'tool_use' && (!onlyToolNames || onlyToolNames.includes(block.name));
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
export type RunToolsOptions = {
|
|
@@ -220,6 +220,7 @@ export const runTools = async ({ message, tools, extensions }: RunToolsOptions):
|
|
|
220
220
|
content:
|
|
221
221
|
typeof toolResult.result === 'string' ? toolResult.result : JSON.stringify(toolResult.result) ?? '',
|
|
222
222
|
},
|
|
223
|
+
...(toolResult.extractContentBlocks ?? []),
|
|
223
224
|
],
|
|
224
225
|
});
|
|
225
226
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema as S } from '
|
|
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';
|
|
@@ -11,7 +11,7 @@ import { invariant } from '@dxos/invariant';
|
|
|
11
11
|
import { SpaceId } from '@dxos/keys';
|
|
12
12
|
import { log } from '@dxos/log';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { AIServiceEdgeClient, Tool } from '../ai-service';
|
|
15
15
|
import { defineTool, ToolResult } from '../conversation';
|
|
16
16
|
|
|
17
17
|
// TODO(dmaretskyi): Effect schema.
|
|
@@ -108,7 +108,7 @@ If there's
|
|
|
108
108
|
|
|
109
109
|
describe('Artifacts', () => {
|
|
110
110
|
test('shopping list', async () => {
|
|
111
|
-
const client = new
|
|
111
|
+
const client = new AIServiceEdgeClient({
|
|
112
112
|
endpoint: ENDPOINT,
|
|
113
113
|
});
|
|
114
114
|
|
|
@@ -136,7 +136,7 @@ describe('Artifacts', () => {
|
|
|
136
136
|
]);
|
|
137
137
|
|
|
138
138
|
const stream = await client.generate({
|
|
139
|
-
model:
|
|
139
|
+
model: DEFAULT_EDGE_MODEL,
|
|
140
140
|
spaceId,
|
|
141
141
|
threadId,
|
|
142
142
|
systemPrompt: 'You are a helpful assistant.',
|
|
@@ -164,7 +164,7 @@ describe('Artifacts', () => {
|
|
|
164
164
|
]);
|
|
165
165
|
|
|
166
166
|
const stream2 = await client.generate({
|
|
167
|
-
model:
|
|
167
|
+
model: DEFAULT_EDGE_MODEL,
|
|
168
168
|
spaceId,
|
|
169
169
|
threadId,
|
|
170
170
|
systemPrompt: 'You are a helpful assistant.',
|
package/src/testing/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_OLLAMA_MODEL, OllamaClient, type OllamaClientParams } from '../ai-service';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a test client with small local model and no temperature for predictable results.
|
|
9
|
+
*/
|
|
10
|
+
export const createTestOllamaClient = (options?: Pick<OllamaClientParams, 'tools'>) => {
|
|
11
|
+
return new OllamaClient({
|
|
12
|
+
tools: options?.tools,
|
|
13
|
+
overrides: { model: DEFAULT_OLLAMA_MODEL, temperature: 0 },
|
|
14
|
+
});
|
|
15
|
+
};
|
|
@@ -15,11 +15,11 @@ import { createLogger } from './logger';
|
|
|
15
15
|
import { createCypherTool, createSystemPrompt } from './query-promts';
|
|
16
16
|
import { createTestData, seedTestData } from './test-data';
|
|
17
17
|
import { Contact, Org, Project, Task } from './test-schema';
|
|
18
|
-
import {
|
|
18
|
+
import { AIServiceEdgeClient, DEFAULT_EDGE_MODEL } from '../ai-service';
|
|
19
19
|
import { runLLM } from '../conversation';
|
|
20
20
|
import { EchoDataSource } from '../cypher';
|
|
21
21
|
|
|
22
|
-
const client = new
|
|
22
|
+
const client = new AIServiceEdgeClient({
|
|
23
23
|
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
24
24
|
});
|
|
25
25
|
|
|
@@ -41,7 +41,7 @@ test.skip('cypher query', async () => {
|
|
|
41
41
|
]);
|
|
42
42
|
|
|
43
43
|
const result = await runLLM({
|
|
44
|
-
model:
|
|
44
|
+
model: DEFAULT_EDGE_MODEL,
|
|
45
45
|
tools: [cypherTool],
|
|
46
46
|
spaceId,
|
|
47
47
|
threadId,
|
|
@@ -78,7 +78,7 @@ test.skip('query ECHO', async () => {
|
|
|
78
78
|
]);
|
|
79
79
|
|
|
80
80
|
const result = await runLLM({
|
|
81
|
-
model:
|
|
81
|
+
model: DEFAULT_EDGE_MODEL,
|
|
82
82
|
tools: [cypherTool],
|
|
83
83
|
spaceId,
|
|
84
84
|
threadId,
|
package/src/testing/test-data.ts
CHANGED