@dxos/assistant 0.8.4-main.84f28bd → 0.8.4-main.9735255
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-7CDDG6LL.mjs +578 -0
- package/dist/lib/browser/chunk-7CDDG6LL.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/extraction/index.mjs +225 -0
- package/dist/lib/browser/extraction/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +723 -1892
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +32 -0
- package/dist/lib/browser/testing/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs +579 -0
- package/dist/lib/node-esm/chunk-CC7ER6Q3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/extraction/index.mjs +226 -0
- package/dist/lib/node-esm/extraction/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +723 -1893
- 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 +33 -0
- package/dist/lib/node-esm/testing/index.mjs.map +7 -0
- package/dist/types/src/conversation/context.d.ts +129 -0
- package/dist/types/src/conversation/context.d.ts.map +1 -0
- package/dist/types/src/conversation/context.test.d.ts +2 -0
- package/dist/types/src/conversation/context.test.d.ts.map +1 -0
- package/dist/types/src/conversation/conversation.d.ts +29 -32
- package/dist/types/src/conversation/conversation.d.ts.map +1 -1
- package/dist/types/src/conversation/conversation.test.d.ts +2 -0
- package/dist/types/src/conversation/conversation.test.d.ts.map +1 -0
- package/dist/types/src/conversation/index.d.ts +1 -0
- package/dist/types/src/conversation/index.d.ts.map +1 -1
- package/dist/types/src/diff.d.ts +15 -0
- package/dist/types/src/diff.d.ts.map +1 -0
- package/dist/types/src/diff.test.d.ts +2 -0
- package/dist/types/src/diff.test.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +67 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/execution-graph.d.ts +85 -0
- package/dist/types/src/execution-graph.d.ts.map +1 -0
- package/dist/types/src/execution-graph.test.d.ts +2 -0
- package/dist/types/src/execution-graph.test.d.ts.map +1 -0
- package/dist/types/src/extraction/extraction-llm-function/extraction-llm-function.d.ts +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 +279 -140
- package/dist/types/src/extraction/extraction-ner-function/extraction-ner-function.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts +1 -1
- package/dist/types/src/extraction/extraction-ner-function/named-entity-recognition.d.ts.map +1 -1
- package/dist/types/src/extraction/extraction.d.ts +345 -212
- package/dist/types/src/extraction/extraction.d.ts.map +1 -1
- package/dist/types/src/extraction/quotes.d.ts +3 -3
- package/dist/types/src/extraction/quotes.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +2 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/services.d.ts +20 -0
- package/dist/types/src/functions/services.d.ts.map +1 -0
- package/dist/types/src/functions.test.d.ts +2 -0
- package/dist/types/src/functions.test.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -5
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/session/GenericToolkit.d.ts +85 -0
- package/dist/types/src/session/GenericToolkit.d.ts.map +1 -0
- package/dist/types/src/session/artifact-diff.d.ts +27 -0
- package/dist/types/src/session/artifact-diff.d.ts.map +1 -0
- package/dist/types/src/session/error-handling.d.ts +4 -0
- package/dist/types/src/session/error-handling.d.ts.map +1 -0
- package/dist/types/src/session/format.d.ts +12 -0
- package/dist/types/src/session/format.d.ts.map +1 -0
- package/dist/types/src/session/format.test.d.ts +2 -0
- package/dist/types/src/session/format.test.d.ts.map +1 -0
- package/dist/types/src/session/index.d.ts +4 -0
- package/dist/types/src/session/index.d.ts.map +1 -1
- package/dist/types/src/session/observer.d.ts +23 -0
- package/dist/types/src/session/observer.d.ts.map +1 -0
- package/dist/types/src/session/session.d.ts +41 -268
- package/dist/types/src/session/session.d.ts.map +1 -1
- package/dist/types/src/session/toolkit.d.ts +14 -0
- package/dist/types/src/session/toolkit.d.ts.map +1 -0
- package/dist/types/src/session/version-pin.d.ts +5 -5
- package/dist/types/src/session/version-pin.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +2 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/templates/system.d.ts +18 -0
- package/dist/types/src/templates/system.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +1 -2
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/layer.d.ts +21 -0
- package/dist/types/src/testing/layer.d.ts.map +1 -0
- package/dist/types/src/types/artifact.d.ts +28 -0
- package/dist/types/src/types/artifact.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -27
- package/src/conversation/context.test.ts +46 -0
- package/src/conversation/context.ts +303 -0
- package/src/conversation/conversation.test.ts +65 -0
- package/src/conversation/conversation.ts +98 -76
- package/src/conversation/index.ts +1 -0
- package/src/diff.test.ts +43 -0
- package/src/diff.ts +84 -0
- package/src/errors.ts +15 -0
- package/src/execution-graph.test.ts +740 -0
- package/src/execution-graph.ts +509 -0
- package/src/extraction/extraction-llm-function/extraction-llm-function.test.ts +14 -25
- package/src/extraction/extraction-llm-function/extraction-llm-function.ts +48 -52
- package/src/extraction/extraction-ner-function/extraction-ner-function.test.ts +22 -21
- package/src/extraction/extraction-ner-function/extraction-ner-function.ts +43 -41
- package/src/extraction/extraction-ner-function/named-entity-recognition.test.ts +12 -6
- package/src/extraction/extraction-ner-function/named-entity-recognition.ts +3 -1
- package/src/extraction/extraction.ts +10 -9
- package/src/extraction/quotes.test.ts +3 -3
- package/src/extraction/quotes.ts +6 -7
- package/src/functions/index.ts +5 -0
- package/src/functions/services.ts +180 -0
- package/src/functions.conversations.json +1 -0
- package/src/functions.test.ts +74 -0
- package/src/index.ts +5 -5
- package/src/session/GenericToolkit.ts +131 -0
- package/src/session/artifact-diff.ts +41 -0
- package/src/session/error-handling.ts +41 -0
- package/src/session/format.test.ts +124 -0
- package/src/session/format.ts +143 -0
- package/src/session/index.ts +5 -0
- package/src/session/observer.ts +61 -0
- package/src/session/session.conversations.json +1 -0
- package/src/session/session.test.ts +83 -215
- package/src/session/session.ts +181 -529
- package/src/session/toolkit.ts +39 -0
- package/src/session/version-pin.ts +12 -12
- package/src/templates/index.ts +5 -0
- package/src/templates/instructions/format.tpl +61 -0
- package/src/templates/instructions/system.tpl +48 -0
- package/src/templates/system.ts +41 -0
- package/src/testing/index.ts +2 -8
- package/src/testing/layer.ts +78 -0
- package/src/types/artifact.ts +82 -0
- package/src/types/index.ts +5 -0
- package/src/typings.d.ts +5 -0
- package/dist/types/bin/chat.d.ts +0 -2
- package/dist/types/bin/chat.d.ts.map +0 -1
- package/dist/types/src/blueprint/blueprint.d.ts +0 -41
- package/dist/types/src/blueprint/blueprint.d.ts.map +0 -1
- package/dist/types/src/blueprint/index.d.ts +0 -3
- package/dist/types/src/blueprint/index.d.ts.map +0 -1
- package/dist/types/src/blueprint/registry.d.ts +0 -7
- package/dist/types/src/blueprint/registry.d.ts.map +0 -1
- package/dist/types/src/context/binder.d.ts +0 -34
- package/dist/types/src/context/binder.d.ts.map +0 -1
- package/dist/types/src/context/binding.d.ts +0 -38
- package/dist/types/src/context/binding.d.ts.map +0 -1
- package/dist/types/src/context/index.d.ts +0 -3
- package/dist/types/src/context/index.d.ts.map +0 -1
- package/dist/types/src/research/exa.d.ts +0 -7
- package/dist/types/src/research/exa.d.ts.map +0 -1
- package/dist/types/src/research/graph.d.ts +0 -41
- package/dist/types/src/research/graph.d.ts.map +0 -1
- package/dist/types/src/research/graph.test.d.ts +0 -2
- package/dist/types/src/research/graph.test.d.ts.map +0 -1
- package/dist/types/src/research/index.d.ts +0 -4
- package/dist/types/src/research/index.d.ts.map +0 -1
- package/dist/types/src/research/research.d.ts +0 -10
- package/dist/types/src/research/research.d.ts.map +0 -1
- package/dist/types/src/research/research.test.d.ts +0 -2
- package/dist/types/src/research/research.test.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/summarization/summarization.test.d.ts +0 -2
- package/dist/types/src/summarization/summarization.test.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337321991.d.ts +0 -38
- package/dist/types/src/testing/exa-search-1748337321991.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337331526.d.ts +0 -37
- package/dist/types/src/testing/exa-search-1748337331526.d.ts.map +0 -1
- package/dist/types/src/testing/exa-search-1748337344119.d.ts +0 -58
- package/dist/types/src/testing/exa-search-1748337344119.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -3
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/blueprint/blueprint.ts +0 -75
- package/src/blueprint/index.ts +0 -6
- package/src/blueprint/registry.ts +0 -15
- package/src/context/binder.ts +0 -101
- package/src/context/binding.ts +0 -31
- package/src/context/index.ts +0 -6
- package/src/research/exa.ts +0 -100
- package/src/research/graph.test.ts +0 -15
- package/src/research/graph.ts +0 -337
- package/src/research/index.ts +0 -7
- package/src/research/instructions-research.tpl +0 -97
- package/src/research/research.test.ts +0 -190
- package/src/research/research.ts +0 -90
- package/src/session/version-pin.test.ts +0 -26
- package/src/summarization/summarization.test.ts +0 -221
- package/src/testing/exa-search-1748337321991.ts +0 -131
- package/src/testing/exa-search-1748337331526.ts +0 -144
- package/src/testing/exa-search-1748337344119.ts +0 -133
- package/src/typedefs.d.ts +0 -8
- package/src/types.ts +0 -8
- /package/src/extraction/extraction-llm-function/{instructions.tpl → transcription-instructions.tpl} +0 -0
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
5
|
+
import * as Tool from '@effect/ai/Tool';
|
|
6
|
+
import * as Toolkit from '@effect/ai/Toolkit';
|
|
7
|
+
import { describe, it } from '@effect/vitest';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Layer from 'effect/Layer';
|
|
10
|
+
import * as Schema from 'effect/Schema';
|
|
11
|
+
|
|
12
|
+
import { Obj, Type } from '@dxos/echo';
|
|
13
|
+
import { TestHelpers } from '@dxos/effect/testing';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
|
|
16
|
-
import {
|
|
16
|
+
import { AssistantTestLayer } from '../testing';
|
|
17
|
+
|
|
18
|
+
import { AiSession } from './session';
|
|
17
19
|
|
|
18
20
|
// Define a calendar event artifact schema.
|
|
19
21
|
const CalendarEventSchema = Schema.Struct({
|
|
@@ -22,7 +24,7 @@ const CalendarEventSchema = Schema.Struct({
|
|
|
22
24
|
endTime: Schema.String,
|
|
23
25
|
description: Schema.String,
|
|
24
26
|
}).pipe(
|
|
25
|
-
Type.
|
|
27
|
+
Type.object({
|
|
26
28
|
typename: 'example.com/type/CalendarEvent',
|
|
27
29
|
version: '0.1.0',
|
|
28
30
|
}),
|
|
@@ -30,178 +32,84 @@ const CalendarEventSchema = Schema.Struct({
|
|
|
30
32
|
|
|
31
33
|
type CalendarEvent = Schema.Schema.Type<typeof CalendarEventSchema>;
|
|
32
34
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// });
|
|
40
|
-
const session = new AISession({ operationModel: 'configured' });
|
|
41
|
-
|
|
42
|
-
const printer = new ConsolePrinter();
|
|
43
|
-
session.message.on((message) => printer.printMessage(message));
|
|
44
|
-
session.userMessage.on((message) => printer.printMessage(message));
|
|
45
|
-
session.block.on((block) => printer.printContentBlock(block));
|
|
46
|
-
|
|
47
|
-
// session.update.on((update) => {
|
|
48
|
-
// log('update', { update });
|
|
49
|
-
// });
|
|
50
|
-
|
|
51
|
-
const calculatorTool = createTool('test', {
|
|
52
|
-
name: 'calculator',
|
|
53
|
-
description: 'Adds to numbers',
|
|
54
|
-
schema: Schema.Struct({
|
|
55
|
-
operand1: Schema.Number,
|
|
56
|
-
operand2: Schema.Number,
|
|
35
|
+
const TestToolkit = Toolkit.make(
|
|
36
|
+
Tool.make('Calculator', {
|
|
37
|
+
description: 'Basic calculator tool',
|
|
38
|
+
parameters: {
|
|
39
|
+
input: Schema.String.annotations({
|
|
40
|
+
description: 'The calculation to perform.',
|
|
57
41
|
}),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
client: aiClient,
|
|
66
|
-
tools: [calculatorTool.id],
|
|
67
|
-
artifacts: [],
|
|
68
|
-
requiredArtifactIds: [],
|
|
69
|
-
history: [],
|
|
70
|
-
generationOptions: {
|
|
71
|
-
model: '@anthropic/claude-3-5-haiku-20241022',
|
|
72
|
-
},
|
|
73
|
-
prompt: 'What is 10 + 20?',
|
|
74
|
-
toolResolver: new ToolRegistry([calculatorTool]),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
log('result', { response });
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('create calendar itinerary', { timeout: 60_000 }, async () => {
|
|
81
|
-
const aiClient = new EdgeAiServiceClient({ endpoint: AI_SERVICE_ENDPOINT.REMOTE });
|
|
82
|
-
// const aiClient = new OllamaAiServiceClient({
|
|
83
|
-
// overrides: { model: 'llama3.1:8b' },
|
|
84
|
-
// });
|
|
85
|
-
const session = new AISession({ operationModel: 'configured' });
|
|
86
|
-
|
|
87
|
-
const objects = new Set<string>();
|
|
88
|
-
|
|
89
|
-
// Define calendar artifact.
|
|
90
|
-
const calendarArtifact = defineArtifact({
|
|
91
|
-
id: 'artifact:dxos.org/plugin/calendar',
|
|
92
|
-
name: 'Calendar',
|
|
93
|
-
instructions: 'Use this to create and query calendar events.',
|
|
94
|
-
schema: CalendarEventSchema,
|
|
95
|
-
tools: [
|
|
96
|
-
createTool('calendar', {
|
|
97
|
-
name: 'query',
|
|
98
|
-
description: 'Query the calendar for events',
|
|
99
|
-
schema: Schema.Struct({}),
|
|
100
|
-
execute: async () => {
|
|
101
|
-
return ToolResult.Success(CALENDAR_EVENTS);
|
|
102
|
-
},
|
|
103
|
-
}),
|
|
104
|
-
],
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const tableArtifact = defineArtifact({
|
|
108
|
-
id: 'artifact:dxos.org/plugin/table',
|
|
109
|
-
name: 'Table',
|
|
110
|
-
instructions: 'Use this to create and manage tables. Each table has a unique id.',
|
|
111
|
-
schema: Schema.Struct({}),
|
|
112
|
-
tools: [
|
|
113
|
-
createTool('table', {
|
|
114
|
-
name: 'create',
|
|
115
|
-
description: 'Create a table',
|
|
116
|
-
schema: Schema.Struct({
|
|
117
|
-
data: Schema.Array(Schema.Any).annotations({ description: 'Array of data payloads to add as rows' }),
|
|
118
|
-
}),
|
|
119
|
-
execute: async ({ data }) => {
|
|
120
|
-
log('create table', { data });
|
|
121
|
-
const id = DXN.fromLocalObjectId(ObjectId.random()).toString();
|
|
122
|
-
objects.add(id);
|
|
123
|
-
// TODO(dmaretskyi): consider xml for refs instead of @dxn:echo:@:XXXXX
|
|
124
|
-
return ToolResult.Success(`table @${id}`);
|
|
125
|
-
},
|
|
126
|
-
}),
|
|
127
|
-
],
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
const mapArtifact = defineArtifact({
|
|
131
|
-
id: 'artifact:dxos.org/plugin/map',
|
|
132
|
-
name: 'Map',
|
|
133
|
-
instructions:
|
|
134
|
-
'Use this to create and manage maps. Maps source data from tables. Table id is required to create a map.',
|
|
135
|
-
schema: Schema.Struct({}),
|
|
136
|
-
tools: [
|
|
137
|
-
createTool('map', {
|
|
138
|
-
name: 'create',
|
|
139
|
-
description: 'Create a map',
|
|
140
|
-
schema: Schema.Struct({
|
|
141
|
-
source: ArtifactId.annotations({
|
|
142
|
-
description: 'The table that will be used as the source of the map',
|
|
143
|
-
}),
|
|
144
|
-
}),
|
|
145
|
-
execute: async ({ source }) => {
|
|
146
|
-
// TODO(dmaretskyi): Use effect-schema decode instead of manual parsing.
|
|
147
|
-
const sourceId = ArtifactId.toDXN(source);
|
|
148
|
-
if (!objects.has(sourceId.toString())) {
|
|
149
|
-
return ToolResult.Error(`table id=${source} not found`);
|
|
150
|
-
}
|
|
151
|
-
log('create map', { sourceId });
|
|
152
|
-
const id = DXN.fromLocalObjectId(ObjectId.random()).toString();
|
|
153
|
-
objects.add(id);
|
|
154
|
-
// TODO(dmaretskyi): consider xml for refs instead of @dxn:echo:@:XXXXX
|
|
155
|
-
return ToolResult.Success(`map @${id}`);
|
|
156
|
-
},
|
|
157
|
-
}),
|
|
158
|
-
],
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const scriptArtifact = defineArtifact({
|
|
162
|
-
id: 'artifact:dxos.org/plugin/script',
|
|
163
|
-
name: 'Script',
|
|
164
|
-
instructions: 'Use this to create and manage scripts',
|
|
165
|
-
schema: Schema.Struct({}),
|
|
166
|
-
tools: [],
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// session.streamEvent.on((event) => {
|
|
170
|
-
// printStreamEvent(event);
|
|
171
|
-
// });
|
|
42
|
+
},
|
|
43
|
+
success: Schema.Struct({
|
|
44
|
+
result: Schema.Number,
|
|
45
|
+
}),
|
|
46
|
+
failure: Schema.Never,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
172
49
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
50
|
+
// Tool handlers.
|
|
51
|
+
const toolkitLayer = TestToolkit.toLayer({
|
|
52
|
+
Calculator: ({ input }) =>
|
|
53
|
+
Effect.gen(function* () {
|
|
54
|
+
const result = (() => {
|
|
55
|
+
// Restrict to basic arithmetic operations for safety.
|
|
56
|
+
const sanitizedInput = input.replace(/[^0-9+\-*/().\s]/g, '');
|
|
57
|
+
log.info('calculate', { sanitizedInput });
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval
|
|
60
|
+
return Function(`"use strict"; return (${sanitizedInput})`)();
|
|
61
|
+
})();
|
|
62
|
+
|
|
63
|
+
return { result };
|
|
64
|
+
}),
|
|
65
|
+
});
|
|
177
66
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
67
|
+
const TestLayer = Layer.mergeAll(
|
|
68
|
+
AssistantTestLayer({
|
|
69
|
+
types: [CalendarEventSchema],
|
|
70
|
+
}),
|
|
71
|
+
toolkitLayer,
|
|
72
|
+
);
|
|
181
73
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
74
|
+
describe('AiSession', () => {
|
|
75
|
+
it.effect(
|
|
76
|
+
'no tools',
|
|
77
|
+
Effect.fnUntraced(
|
|
78
|
+
function* (_) {
|
|
79
|
+
const session = new AiSession({ operationModel: 'configured' });
|
|
80
|
+
const response = yield* session.run({
|
|
81
|
+
prompt: 'Hello world!',
|
|
82
|
+
history: [],
|
|
83
|
+
});
|
|
84
|
+
log.info('response', { response });
|
|
191
85
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
86
|
+
Effect.provide(TestLayer),
|
|
87
|
+
TestHelpers.provideTestContext,
|
|
88
|
+
),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
it.effect(
|
|
92
|
+
'calculator',
|
|
93
|
+
Effect.fnUntraced(
|
|
94
|
+
function* (_) {
|
|
95
|
+
const session = new AiSession({ operationModel: 'configured' });
|
|
96
|
+
const toolkit = yield* TestToolkit;
|
|
97
|
+
const response = yield* session.run({
|
|
98
|
+
toolkit,
|
|
99
|
+
prompt: 'What is 10 + 30?',
|
|
100
|
+
history: [],
|
|
101
|
+
});
|
|
102
|
+
log.info('response', { response });
|
|
103
|
+
},
|
|
104
|
+
Effect.provide(TestLayer),
|
|
105
|
+
TestHelpers.provideTestContext,
|
|
106
|
+
),
|
|
107
|
+
);
|
|
201
108
|
});
|
|
202
109
|
|
|
203
110
|
// Travel to rome, florence, livorno, siena, madrid for conferences
|
|
204
|
-
|
|
111
|
+
|
|
112
|
+
const _CALENDAR_EVENTS: CalendarEvent[] = [
|
|
205
113
|
Obj.make(CalendarEventSchema, {
|
|
206
114
|
title: 'Exploring Ancient Ruins in Rome',
|
|
207
115
|
startTime: '2024-01-01T10:00:00Z',
|
|
@@ -233,43 +141,3 @@ const CALENDAR_EVENTS: CalendarEvent[] = [
|
|
|
233
141
|
description: 'Travel to Madrid',
|
|
234
142
|
}),
|
|
235
143
|
];
|
|
236
|
-
|
|
237
|
-
// const printStreamEvent = (event: GenerationStreamEvent) => {
|
|
238
|
-
// switch (event.type) {
|
|
239
|
-
// case 'message_start': {
|
|
240
|
-
// process.stdout.write(`${event.message.role.toUpperCase()}\n\n`);
|
|
241
|
-
// for (const content of event.message.content) {
|
|
242
|
-
// printContentBlock(content);
|
|
243
|
-
// }
|
|
244
|
-
// break;
|
|
245
|
-
// }
|
|
246
|
-
// case 'content_block_start': {
|
|
247
|
-
// printContentBlock(event.content);
|
|
248
|
-
// break;
|
|
249
|
-
// }
|
|
250
|
-
// case 'content_block_delta': {
|
|
251
|
-
// switch (event.delta.type) {
|
|
252
|
-
// case 'text_delta': {
|
|
253
|
-
// process.stdout.write(event.delta.text);
|
|
254
|
-
// break;
|
|
255
|
-
// }
|
|
256
|
-
// case 'input_json_delta': {
|
|
257
|
-
// process.stdout.write(event.delta.partial_json);
|
|
258
|
-
// break;
|
|
259
|
-
// }
|
|
260
|
-
// }
|
|
261
|
-
// break;
|
|
262
|
-
// }
|
|
263
|
-
// case 'content_block_stop': {
|
|
264
|
-
// process.stdout.write('\n');
|
|
265
|
-
// break;
|
|
266
|
-
// }
|
|
267
|
-
// case 'message_delta': {
|
|
268
|
-
// break;
|
|
269
|
-
// }
|
|
270
|
-
// case 'message_stop': {
|
|
271
|
-
// process.stdout.write('\n\n');
|
|
272
|
-
// break;
|
|
273
|
-
// }
|
|
274
|
-
// }
|
|
275
|
-
// };
|