@dxos/plugin-transcription 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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/TranscriptContainer-6EHKWVS4.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs +18 -0
- package/dist/lib/browser/blueprint-definition-FTRNMLJZ.mjs.map +7 -0
- package/dist/lib/browser/blueprints/index.mjs +9 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs +35 -0
- package/dist/lib/browser/chunk-HOOPZ7EM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7DR6HZEF.mjs → chunk-ICM7JRCO.mjs} +64 -98
- package/dist/lib/browser/chunk-ICM7JRCO.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/chunk-Q5OC3WVG.mjs +72 -0
- package/dist/lib/browser/chunk-Q5OC3WVG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-535OJKFO.mjs → chunk-SYGEFDWO.mjs} +2 -2
- package/dist/lib/browser/{chunk-WH36ENNE.mjs → chunk-TKFU53OZ.mjs} +19 -25
- package/dist/lib/browser/chunk-TKFU53OZ.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-UAAJYVLZ.mjs → chunk-ZZF7ICVM.mjs} +31 -31
- package/dist/lib/browser/chunk-ZZF7ICVM.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +59 -72
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs +22 -0
- package/dist/lib/browser/operation-resolver-ZUWTU7C5.mjs.map +7 -0
- package/dist/lib/browser/react-surface-ZXH5267I.mjs +34 -0
- package/dist/lib/browser/react-surface-ZXH5267I.mjs.map +7 -0
- package/dist/lib/browser/{transcriber-LWOLYQHC.mjs → transcriber-EZZTUCPE.mjs} +17 -13
- package/dist/lib/browser/transcriber-EZZTUCPE.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -5
- package/dist/lib/node-esm/{TranscriptContainer-GRLDCESB.mjs → TranscriptContainer-5YT5W73I.mjs} +5 -4
- package/dist/lib/node-esm/TranscriptContainer-5YT5W73I.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs +19 -0
- package/dist/lib/node-esm/blueprint-definition-IOX35YUX.mjs.map +7 -0
- package/dist/lib/node-esm/blueprints/index.mjs +10 -0
- package/dist/lib/node-esm/blueprints/index.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs +73 -0
- package/dist/lib/node-esm/chunk-4BFY6P2D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K4AZOB5Y.mjs → chunk-BX2AB7S7.mjs} +64 -98
- package/dist/lib/node-esm/chunk-BX2AB7S7.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-Z3LTZ3ID.mjs → chunk-CWP22IHV.mjs} +31 -31
- package/dist/lib/node-esm/chunk-CWP22IHV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YFN4FJFK.mjs → chunk-EPC27WWV.mjs} +19 -25
- package/dist/lib/node-esm/chunk-EPC27WWV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Q6WD7L2J.mjs → chunk-GVAVEVZ6.mjs} +2 -2
- 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/chunk-NVM2QUMX.mjs +37 -0
- package/dist/lib/node-esm/chunk-NVM2QUMX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +59 -72
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs +23 -0
- package/dist/lib/node-esm/operation-resolver-Z72B4H2Q.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs +35 -0
- package/dist/lib/node-esm/react-surface-6GUBZX2V.mjs.map +7 -0
- package/dist/lib/node-esm/{transcriber-UGB7ECX6.mjs → transcriber-RGW3YYT4.mjs} +17 -13
- package/dist/lib/node-esm/transcriber-RGW3YYT4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -5
- package/dist/types/src/TranscriptionPlugin.d.ts +2 -1
- package/dist/types/src/TranscriptionPlugin.d.ts.map +1 -1
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts +21 -0
- package/dist/types/src/blueprints/transcription-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +9 -0
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +5 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts +3 -0
- package/dist/types/src/capabilities/transcriber/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts +9 -0
- package/dist/types/src/capabilities/transcriber/transcriber.d.ts.map +1 -0
- package/dist/types/src/components/Transcript/Transcript.d.ts +5 -8
- package/dist/types/src/components/Transcript/Transcript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts +4 -3
- package/dist/types/src/components/Transcript/Transcript.stories.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts +9 -9
- package/dist/types/src/components/Transcript/deprecated/OldTranscript.d.ts.map +1 -1
- package/dist/types/src/components/Transcript/transcript-extension.d.ts +2 -2
- package/dist/types/src/components/Transcript/transcript-extension.d.ts.map +1 -1
- package/dist/types/src/components/TranscriptContainer.d.ts +4 -6
- package/dist/types/src/components/TranscriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts +3 -3
- package/dist/types/src/components/stories/FileTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts +3 -3
- package/dist/types/src/components/stories/MicrophoneTranscription.stories.d.ts.map +1 -1
- package/dist/types/src/components/stories/TranscriptionStory.d.ts +2 -2
- package/dist/types/src/components/stories/TranscriptionStory.d.ts.map +1 -1
- package/dist/types/src/functions/open.d.ts +1 -1
- package/dist/types/src/functions/summarize.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts +1 -1
- package/dist/types/src/hooks/useQueueModelAdapter.d.ts.map +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts +1 -1
- package/dist/types/src/hooks/useTranscriber.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/message-normalizer.d.ts +5 -5
- package/dist/types/src/segments-normalization/message-normalizer.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/normalization.d.ts +502 -457
- package/dist/types/src/segments-normalization/normalization.d.ts.map +1 -1
- package/dist/types/src/segments-normalization/utils.d.ts +2 -2
- package/dist/types/src/segments-normalization/utils.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +9 -9
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/transcriber/media-stream-recorder.d.ts +2 -2
- package/dist/types/src/transcriber/media-stream-recorder.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcriber.d.ts +4 -4
- package/dist/types/src/transcriber/transcriber.d.ts.map +1 -1
- package/dist/types/src/transcriber/transcription-manager.d.ts +9 -6
- package/dist/types/src/transcriber/transcription-manager.d.ts.map +1 -1
- package/dist/types/src/types/TranscriptAction.d.ts +22 -20
- package/dist/types/src/types/TranscriptAction.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +18 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/render-byline.d.ts +4 -0
- package/dist/types/src/util/render-byline.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +83 -69
- package/src/TranscriptionPlugin.tsx +34 -58
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/transcription-blueprint.ts +25 -0
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +23 -0
- package/src/capabilities/blueprint-definition/index.ts +7 -0
- package/src/capabilities/index.ts +4 -8
- package/src/capabilities/operation-handler/index.ts +7 -0
- package/src/capabilities/operation-handler/operation-handler.ts +25 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +25 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +27 -0
- package/src/capabilities/transcriber/index.ts +7 -0
- package/src/capabilities/transcriber/transcriber.ts +85 -0
- package/src/components/Transcript/Transcript.stories.tsx +38 -37
- package/src/components/Transcript/Transcript.tsx +11 -38
- package/src/components/Transcript/deprecated/OldTranscript.tsx +2 -2
- package/src/components/Transcript/transcript-extension.ts +10 -6
- package/src/components/TranscriptContainer.tsx +15 -17
- package/src/components/stories/FileTranscription.stories.tsx +27 -31
- package/src/components/stories/KeyWordRecognition.stories.tsx +4 -4
- package/src/components/stories/MicrophoneTranscription.stories.tsx +47 -50
- package/src/components/stories/TranscriptionStory.tsx +7 -11
- package/src/functions/open.ts +6 -6
- package/src/hooks/useQueueModelAdapter.ts +1 -1
- package/src/hooks/useTranscriber.ts +8 -3
- package/src/hooks/useVoiceInput.ts +2 -2
- package/src/index.ts +1 -1
- package/src/meta.ts +2 -2
- package/src/model/model.test.ts +20 -14
- package/src/segments-normalization/message-normalizer.ts +18 -13
- package/src/segments-normalization/normalization.test.ts +5 -10
- package/src/segments-normalization/normalization.ts +6 -6
- package/src/segments-normalization/utils.ts +2 -2
- package/src/testing/testing.ts +28 -18
- package/src/transcriber/media-stream-recorder.ts +3 -3
- package/src/transcriber/transcriber.browser.test.ts +4 -4
- package/src/transcriber/transcriber.ts +6 -6
- package/src/transcriber/transcription-manager.ts +21 -15
- package/src/types/TranscriptAction.ts +21 -13
- package/src/{capabilities → types}/capabilities.ts +8 -8
- package/src/types/index.ts +2 -1
- package/src/util/index.ts +1 -0
- package/src/util/render-byline.ts +33 -0
- package/dist/lib/browser/TranscriptContainer-2GSL2XB5.mjs +0 -11
- package/dist/lib/browser/blueprint-definition-UAAJYVLZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs +0 -16
- package/dist/lib/browser/chunk-3MKZ2MNQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-7DR6HZEF.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBUIO677.mjs +0 -29
- package/dist/lib/browser/chunk-VBUIO677.mjs.map +0 -7
- package/dist/lib/browser/chunk-W7WKZTM4.mjs +0 -63
- package/dist/lib/browser/chunk-W7WKZTM4.mjs.map +0 -7
- package/dist/lib/browser/chunk-WH36ENNE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs +0 -25
- package/dist/lib/browser/intent-resolver-ZTKTEAQX.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KA32A72I.mjs +0 -34
- package/dist/lib/browser/react-surface-KA32A72I.mjs.map +0 -7
- package/dist/lib/browser/transcriber-LWOLYQHC.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-Z3LTZ3ID.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K4AZOB5Y.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OLMSTF3M.mjs +0 -64
- package/dist/lib/node-esm/chunk-OLMSTF3M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs +0 -17
- package/dist/lib/node-esm/chunk-SWUVPFKR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YFN4FJFK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs +0 -30
- package/dist/lib/node-esm/chunk-YVNQN2J6.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs +0 -26
- package/dist/lib/node-esm/intent-resolver-55WH2GY6.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-GU7LW2JO.mjs +0 -35
- package/dist/lib/node-esm/react-surface-GU7LW2JO.mjs.map +0 -7
- package/dist/lib/node-esm/transcriber-UGB7ECX6.mjs.map +0 -7
- package/dist/types/src/capabilities/blueprint-definition.d.ts +0 -5
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -17
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/transcriber.d.ts +0 -8
- package/dist/types/src/capabilities/transcriber.d.ts.map +0 -1
- package/dist/types/src/types/Transcript.d.ts +0 -30
- package/dist/types/src/types/Transcript.d.ts.map +0 -1
- package/src/capabilities/blueprint-definition.ts +0 -31
- package/src/capabilities/intent-resolver.ts +0 -18
- package/src/capabilities/react-surface.tsx +0 -22
- package/src/capabilities/transcriber.ts +0 -77
- package/src/types/Transcript.ts +0 -44
- /package/dist/lib/browser/{TranscriptContainer-2GSL2XB5.mjs.map → TranscriptContainer-6EHKWVS4.mjs.map} +0 -0
- /package/dist/lib/{node-esm/TranscriptContainer-GRLDCESB.mjs.map → browser/blueprints/index.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-535OJKFO.mjs.map → chunk-SYGEFDWO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-Q6WD7L2J.mjs.map → chunk-GVAVEVZ6.mjs.map} +0 -0
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { Common } from '@dxos/app-framework';
|
|
9
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
11
|
import {
|
|
11
12
|
type ExtractionFunction,
|
|
@@ -14,28 +15,26 @@ import {
|
|
|
14
15
|
getNer,
|
|
15
16
|
processTranscriptMessage,
|
|
16
17
|
} from '@dxos/assistant/extraction';
|
|
17
|
-
import { Filter,
|
|
18
|
+
import { Filter, type Obj } from '@dxos/echo';
|
|
18
19
|
import { createQueueDXN } from '@dxos/echo/internal';
|
|
19
20
|
import { MemoryQueue } from '@dxos/echo-db';
|
|
20
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
21
|
+
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
21
22
|
import { invariant } from '@dxos/invariant';
|
|
22
23
|
import { log } from '@dxos/log';
|
|
23
24
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
24
25
|
import { PreviewPlugin } from '@dxos/plugin-preview';
|
|
25
|
-
import {
|
|
26
|
-
import { StorybookLayoutPlugin } from '@dxos/plugin-storybook-layout';
|
|
27
|
-
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
26
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
28
27
|
import { IndexKind, useSpace } from '@dxos/react-client/echo';
|
|
29
28
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
29
|
+
import { TestSchema } from '@dxos/schema/testing';
|
|
30
|
+
import { Message, Organization, Person } from '@dxos/types';
|
|
31
|
+
import { seedTestData } from '@dxos/types/testing';
|
|
33
32
|
|
|
34
33
|
import { useAudioTrack, useQueueModelAdapter, useTranscriber } from '../../hooks';
|
|
35
34
|
import { TestItem } from '../../testing';
|
|
36
|
-
import { type
|
|
35
|
+
import { type MediaStreamRecorderProps, type TranscriberProps } from '../../transcriber';
|
|
37
36
|
import { TranscriptionPlugin } from '../../TranscriptionPlugin';
|
|
38
|
-
import { renderByline } from '
|
|
37
|
+
import { renderByline } from '../../util';
|
|
39
38
|
|
|
40
39
|
import { TranscriptionStory } from './TranscriptionStory';
|
|
41
40
|
import { useIsSpeaking } from './useIsSpeaking';
|
|
@@ -51,8 +50,8 @@ const RECORDER_CONFIG = {
|
|
|
51
50
|
|
|
52
51
|
type StoryProps = {
|
|
53
52
|
detectSpeaking?: boolean;
|
|
54
|
-
transcriberConfig:
|
|
55
|
-
recorderConfig:
|
|
53
|
+
transcriberConfig: TranscriberProps['config'];
|
|
54
|
+
recorderConfig: MediaStreamRecorderProps['config'];
|
|
56
55
|
audioConstraints?: MediaTrackConstraints;
|
|
57
56
|
entityExtraction: 'none' | 'ner' | 'llm';
|
|
58
57
|
};
|
|
@@ -75,7 +74,7 @@ const DefaultStory = ({
|
|
|
75
74
|
// Queue.
|
|
76
75
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
77
76
|
const queueDxn = useMemo(() => createQueueDXN(), []);
|
|
78
|
-
const queue = useMemo(() => new MemoryQueue<
|
|
77
|
+
const queue = useMemo(() => new MemoryQueue<Message.Message>(queueDxn), [queueDxn]);
|
|
79
78
|
const model = useQueueModelAdapter(renderByline([]), queue);
|
|
80
79
|
const space = useSpace();
|
|
81
80
|
|
|
@@ -94,7 +93,7 @@ const DefaultStory = ({
|
|
|
94
93
|
|
|
95
94
|
let executor: FunctionExecutor | undefined;
|
|
96
95
|
let extractionFunction: ExtractionFunction | undefined;
|
|
97
|
-
let objects: Promise<
|
|
96
|
+
let objects: Promise<Obj.Unknown[]> | undefined;
|
|
98
97
|
|
|
99
98
|
if (entityExtraction === 'ner') {
|
|
100
99
|
// Init model loading. Takes time.
|
|
@@ -105,13 +104,12 @@ const DefaultStory = ({
|
|
|
105
104
|
objects = space.db
|
|
106
105
|
.query(
|
|
107
106
|
Filter.or(
|
|
108
|
-
Filter.type(
|
|
109
|
-
Filter.type(
|
|
110
|
-
Filter.type(
|
|
107
|
+
Filter.type(Person.Person),
|
|
108
|
+
Filter.type(Organization.Organization),
|
|
109
|
+
Filter.type(TestSchema.DocumentType),
|
|
111
110
|
),
|
|
112
111
|
)
|
|
113
|
-
.run()
|
|
114
|
-
.then((result) => result.objects);
|
|
112
|
+
.run();
|
|
115
113
|
}
|
|
116
114
|
if (entityExtraction !== 'none') {
|
|
117
115
|
executor = new FunctionExecutor(
|
|
@@ -130,9 +128,9 @@ const DefaultStory = ({
|
|
|
130
128
|
}, [entityExtraction, space]);
|
|
131
129
|
|
|
132
130
|
// Transcriber.
|
|
133
|
-
const handleSegments = useCallback<
|
|
131
|
+
const handleSegments = useCallback<TranscriberProps['onSegments']>(
|
|
134
132
|
async (blocks) => {
|
|
135
|
-
const message =
|
|
133
|
+
const message = Message.make({
|
|
136
134
|
sender: { name: 'You' },
|
|
137
135
|
created: new Date().toISOString(),
|
|
138
136
|
blocks,
|
|
@@ -196,42 +194,41 @@ const meta = {
|
|
|
196
194
|
render: DefaultStory,
|
|
197
195
|
decorators: [
|
|
198
196
|
withTheme,
|
|
199
|
-
withLayout({
|
|
197
|
+
withLayout({ layout: 'column' }),
|
|
200
198
|
withPluginManager({
|
|
201
199
|
plugins: [
|
|
200
|
+
...corePlugins(),
|
|
201
|
+
StorybookPlugin({}),
|
|
202
202
|
ClientPlugin({
|
|
203
|
-
types: [TestItem,
|
|
204
|
-
onClientInitialized:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
203
|
+
types: [TestItem, Person.Person, Organization.Organization, TestSchema.DocumentType],
|
|
204
|
+
onClientInitialized: ({ client }) =>
|
|
205
|
+
Effect.gen(function* () {
|
|
206
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
207
|
+
yield* Effect.promise(() => client.spaces.waitUntilReady());
|
|
208
|
+
yield* Effect.promise(() => client.spaces.default.waitUntilReady());
|
|
209
|
+
// TODO(mykola): Make API easier to use.
|
|
210
|
+
// TODO(mykola): Delete after enabling vector indexing by default.
|
|
211
|
+
// Enable vector indexing.
|
|
212
|
+
yield* Effect.promise(() =>
|
|
213
|
+
client.services.services.QueryService!.setConfig({
|
|
214
|
+
enabled: true,
|
|
215
|
+
indexes: [
|
|
216
|
+
//
|
|
217
|
+
{ kind: IndexKind.Kind.SCHEMA_MATCH },
|
|
218
|
+
{ kind: IndexKind.Kind.GRAPH },
|
|
219
|
+
{ kind: IndexKind.Kind.VECTOR },
|
|
220
|
+
],
|
|
221
|
+
}),
|
|
222
|
+
);
|
|
223
|
+
yield* Effect.promise(() => client.services.services.QueryService!.reindex());
|
|
224
|
+
yield* Effect.promise(() => seedTestData(client.spaces.default));
|
|
225
|
+
}),
|
|
223
226
|
}),
|
|
224
|
-
SpacePlugin({}),
|
|
225
|
-
IntentPlugin(),
|
|
226
|
-
SettingsPlugin(),
|
|
227
227
|
|
|
228
|
-
// UI
|
|
229
|
-
ThemePlugin({ tx: defaultTx }),
|
|
230
228
|
PreviewPlugin(),
|
|
231
229
|
TranscriptionPlugin(),
|
|
232
|
-
StorybookLayoutPlugin({}),
|
|
233
230
|
],
|
|
234
|
-
fireEvents: [
|
|
231
|
+
fireEvents: [Common.ActivationEvent.SetupAppGraph],
|
|
235
232
|
}),
|
|
236
233
|
],
|
|
237
234
|
} satisfies Meta<typeof DefaultStory>;
|
|
@@ -6,25 +6,21 @@ import '@dxos-theme';
|
|
|
6
6
|
|
|
7
7
|
import React, { type Dispatch, type FC, type RefObject, type SetStateAction } from 'react';
|
|
8
8
|
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { ScrollContainer } from '@dxos/react-ui-components';
|
|
12
|
-
import { type DataType } from '@dxos/schema';
|
|
9
|
+
import { IconButton, ScrollContainer, Toolbar } from '@dxos/react-ui';
|
|
10
|
+
import { type Message } from '@dxos/types';
|
|
13
11
|
|
|
14
12
|
import { type SerializationModel } from '../../model';
|
|
15
13
|
import { TranscriptView } from '../Transcript';
|
|
16
14
|
|
|
17
15
|
export const TranscriptionStory: FC<{
|
|
18
|
-
model: SerializationModel<
|
|
16
|
+
model: SerializationModel<Message.Message>;
|
|
19
17
|
disabled?: boolean;
|
|
20
18
|
running: boolean;
|
|
21
19
|
onRunningChange: Dispatch<SetStateAction<boolean>>;
|
|
22
20
|
audioRef?: RefObject<HTMLAudioElement | null>;
|
|
23
21
|
}> = ({ model, running, onRunningChange, audioRef, disabled }) => {
|
|
24
|
-
const space = useSpace();
|
|
25
|
-
|
|
26
22
|
return (
|
|
27
|
-
<div className='flex flex-col
|
|
23
|
+
<div className='flex flex-col is-[30rem]'>
|
|
28
24
|
{audioRef && <audio ref={audioRef} autoPlay />}
|
|
29
25
|
<Toolbar.Root>
|
|
30
26
|
<IconButton
|
|
@@ -36,9 +32,9 @@ export const TranscriptionStory: FC<{
|
|
|
36
32
|
/>
|
|
37
33
|
</Toolbar.Root>
|
|
38
34
|
<ScrollContainer.Root pin>
|
|
39
|
-
<ScrollContainer.
|
|
40
|
-
<TranscriptView
|
|
41
|
-
</ScrollContainer.
|
|
35
|
+
<ScrollContainer.Viewport>
|
|
36
|
+
<TranscriptView model={model} />
|
|
37
|
+
</ScrollContainer.Viewport>
|
|
42
38
|
</ScrollContainer.Root>
|
|
43
39
|
</div>
|
|
44
40
|
);
|
package/src/functions/open.ts
CHANGED
|
@@ -7,11 +7,11 @@ import * as Schema from 'effect/Schema';
|
|
|
7
7
|
|
|
8
8
|
import { ArtifactId } from '@dxos/assistant';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { Database } from '@dxos/echo';
|
|
11
|
+
import { QueueService, defineFunction } from '@dxos/functions';
|
|
12
|
+
import { Message, Transcript } from '@dxos/types';
|
|
12
13
|
|
|
13
|
-
import { renderByline } from '../
|
|
14
|
-
import { Transcript } from '../types';
|
|
14
|
+
import { renderByline } from '../util';
|
|
15
15
|
|
|
16
16
|
export default defineFunction({
|
|
17
17
|
key: 'dxos.org/function/transcription/open',
|
|
@@ -26,12 +26,12 @@ export default defineFunction({
|
|
|
26
26
|
content: Schema.String,
|
|
27
27
|
}),
|
|
28
28
|
handler: Effect.fn(function* ({ data: { id } }) {
|
|
29
|
-
const transcript = yield*
|
|
29
|
+
const transcript = yield* Database.Service.resolve(ArtifactId.toDXN(id), Transcript.Transcript);
|
|
30
30
|
const { dxn } = yield* Effect.promise(() => transcript.queue.load());
|
|
31
31
|
const queue = yield* QueueService.getQueue(dxn);
|
|
32
32
|
yield* Effect.promise(() => queue?.queryObjects());
|
|
33
33
|
const content = queue?.objects
|
|
34
|
-
.filter((message) => Obj.instanceOf(
|
|
34
|
+
.filter((message) => Obj.instanceOf(Message.Message, message))
|
|
35
35
|
.flatMap((message, index) => renderByline([])(message, index))
|
|
36
36
|
.join('\n\n');
|
|
37
37
|
return { content };
|
|
@@ -12,7 +12,7 @@ import { type ChunkRenderer, SerializationModel } from '../model';
|
|
|
12
12
|
/**
|
|
13
13
|
* Model adapter for a queue.
|
|
14
14
|
*/
|
|
15
|
-
export const useQueueModelAdapter = <T extends Obj.
|
|
15
|
+
export const useQueueModelAdapter = <T extends Obj.Unknown>(
|
|
16
16
|
renderer: ChunkRenderer<T>,
|
|
17
17
|
queue: Queue<T> | undefined,
|
|
18
18
|
initialChunks: T[] = [],
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useCapabilities } from '@dxos/app-framework';
|
|
7
|
+
import { useCapabilities } from '@dxos/app-framework/react';
|
|
8
8
|
|
|
9
|
-
import { TranscriptionCapabilities } from '../capabilities';
|
|
10
9
|
import { type Transcriber } from '../transcriber';
|
|
10
|
+
import { TranscriptionCapabilities } from '../types';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Records audio while user is speaking and transcribes it after user is done speaking.
|
|
@@ -26,7 +26,12 @@ export const useTranscriber = ({
|
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return getTranscriber({
|
|
29
|
+
return getTranscriber({
|
|
30
|
+
audioStreamTrack,
|
|
31
|
+
recorderConfig,
|
|
32
|
+
transcriberConfig,
|
|
33
|
+
onSegments,
|
|
34
|
+
});
|
|
30
35
|
}, [getTranscriber, audioStreamTrack, recorderConfig, transcriberConfig, onSegments]);
|
|
31
36
|
|
|
32
37
|
useEffect(() => {
|
|
@@ -9,7 +9,7 @@ import { Context } from '@dxos/context';
|
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { useSoundEffect } from '@dxos/react-ui-sfx';
|
|
11
11
|
|
|
12
|
-
import { type
|
|
12
|
+
import { type TranscriberProps } from '../transcriber';
|
|
13
13
|
|
|
14
14
|
import { useAudioTrack } from './useAudioTrack';
|
|
15
15
|
import { useTranscriber } from './useTranscriber';
|
|
@@ -26,7 +26,7 @@ export const useVoiceInput = ({ active, onUpdate }: UseVoiceInputProps) => {
|
|
|
26
26
|
const soundStart = useSoundEffect('StartRecording');
|
|
27
27
|
const soundStop = useSoundEffect('StopRecording');
|
|
28
28
|
|
|
29
|
-
const handleSegments = useCallback<
|
|
29
|
+
const handleSegments = useCallback<TranscriberProps['onSegments']>(async (segments) => {
|
|
30
30
|
const text = segments.map((str) => str.text.trim().replace(/[^\w\s]/g, '')).join(' ');
|
|
31
31
|
onUpdate(text);
|
|
32
32
|
}, []);
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/transcription',
|
|
10
10
|
name: 'Transcription',
|
|
11
11
|
description: trim`
|
package/src/model/model.test.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { describe, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
9
|
import type { ObjectId } from '@dxos/keys';
|
|
10
|
-
import {
|
|
10
|
+
import { Message } from '@dxos/types';
|
|
11
11
|
|
|
12
12
|
import { type ChunkRenderer, DocumentAdapter, SerializationModel } from './model';
|
|
13
13
|
|
|
14
|
-
const blockToMarkdown: ChunkRenderer<
|
|
15
|
-
message:
|
|
14
|
+
const blockToMarkdown: ChunkRenderer<Message.Message> = (
|
|
15
|
+
message: Message.Message,
|
|
16
16
|
index: number,
|
|
17
17
|
debug = true,
|
|
18
18
|
): string[] => {
|
|
@@ -27,12 +27,12 @@ const createDate = () => new Date().toISOString();
|
|
|
27
27
|
|
|
28
28
|
describe('SerializationModel', () => {
|
|
29
29
|
test('basic', ({ expect }) => {
|
|
30
|
-
const model = new SerializationModel<
|
|
30
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
31
31
|
expect(model.chunks.length).to.eq(0);
|
|
32
32
|
expect(model.doc.toString()).to.eq('');
|
|
33
33
|
|
|
34
34
|
// Create message.
|
|
35
|
-
const message = Obj.make(
|
|
35
|
+
const message = Obj.make(Message.Message, {
|
|
36
36
|
created: createDate(),
|
|
37
37
|
sender: { name: 'Alice' },
|
|
38
38
|
blocks: [
|
|
@@ -51,7 +51,9 @@ describe('SerializationModel', () => {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Update message.
|
|
54
|
-
|
|
54
|
+
Obj.change(message, (m) => {
|
|
55
|
+
m.blocks.push({ _tag: 'transcript', started: createDate(), text: 'Hello again!' });
|
|
56
|
+
});
|
|
55
57
|
model.updateChunk(message);
|
|
56
58
|
{
|
|
57
59
|
const text = model.doc.toString();
|
|
@@ -62,14 +64,14 @@ describe('SerializationModel', () => {
|
|
|
62
64
|
|
|
63
65
|
test('sync - append', ({ expect }) => {
|
|
64
66
|
const view = new EditorView({ extensions: [], doc: '' });
|
|
65
|
-
const model = new SerializationModel<
|
|
67
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
66
68
|
const adapter = new DocumentAdapter(view);
|
|
67
69
|
expect(adapter.lineCount()).to.eq(0);
|
|
68
70
|
expect(view.state.doc.toString()).to.eq('');
|
|
69
71
|
|
|
70
72
|
// Append message.
|
|
71
73
|
{
|
|
72
|
-
const message = Obj.make(
|
|
74
|
+
const message = Obj.make(Message.Message, {
|
|
73
75
|
created: createDate(),
|
|
74
76
|
sender: { name: 'Alice' },
|
|
75
77
|
blocks: [
|
|
@@ -87,7 +89,7 @@ describe('SerializationModel', () => {
|
|
|
87
89
|
|
|
88
90
|
// Append message.
|
|
89
91
|
{
|
|
90
|
-
const message = Obj.make(
|
|
92
|
+
const message = Obj.make(Message.Message, {
|
|
91
93
|
created: createDate(),
|
|
92
94
|
sender: { name: 'Bob' },
|
|
93
95
|
blocks: [
|
|
@@ -106,7 +108,7 @@ describe('SerializationModel', () => {
|
|
|
106
108
|
|
|
107
109
|
test('sync - append, update, delete', ({ expect }) => {
|
|
108
110
|
const view = new EditorView({ extensions: [], doc: '' });
|
|
109
|
-
const model = new SerializationModel<
|
|
111
|
+
const model = new SerializationModel<Message.Message>(blockToMarkdown);
|
|
110
112
|
const adapter = new DocumentAdapter(view);
|
|
111
113
|
expect(adapter.lineCount()).to.eq(0);
|
|
112
114
|
|
|
@@ -114,7 +116,7 @@ describe('SerializationModel', () => {
|
|
|
114
116
|
|
|
115
117
|
// Append message.
|
|
116
118
|
{
|
|
117
|
-
const message = Obj.make(
|
|
119
|
+
const message = Obj.make(Message.Message, {
|
|
118
120
|
created: createDate(),
|
|
119
121
|
sender: { name: 'Alice' },
|
|
120
122
|
blocks: [
|
|
@@ -131,13 +133,17 @@ describe('SerializationModel', () => {
|
|
|
131
133
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello world!\n\n');
|
|
132
134
|
|
|
133
135
|
// Update message (add block).
|
|
134
|
-
|
|
136
|
+
Obj.change(message, (m) => {
|
|
137
|
+
m.blocks.push({ _tag: 'transcript', started: createDate(), text: 'Hello again!' });
|
|
138
|
+
});
|
|
135
139
|
model.updateChunk(message);
|
|
136
140
|
model.sync(adapter);
|
|
137
141
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello world!\nHello again!\n\n');
|
|
138
142
|
|
|
139
143
|
// Update message (remove block).
|
|
140
|
-
|
|
144
|
+
Obj.change(message, (m) => {
|
|
145
|
+
m.blocks.splice(0, 1);
|
|
146
|
+
});
|
|
141
147
|
model.updateChunk(message);
|
|
142
148
|
model.sync(adapter);
|
|
143
149
|
expect(view.state.doc.toString()).to.eq('###### Alice\nHello again!\n\n');
|
|
@@ -147,7 +153,7 @@ describe('SerializationModel', () => {
|
|
|
147
153
|
|
|
148
154
|
// Append message.
|
|
149
155
|
{
|
|
150
|
-
const message = Obj.make(
|
|
156
|
+
const message = Obj.make(Message.Message, {
|
|
151
157
|
created: createDate(),
|
|
152
158
|
sender: { name: 'Bob' },
|
|
153
159
|
blocks: [{ _tag: 'transcript', started: createDate(), text: 'Hello again!' }],
|
|
@@ -6,24 +6,22 @@
|
|
|
6
6
|
// Copyright 2025 DXOS.org
|
|
7
7
|
//
|
|
8
8
|
|
|
9
|
-
import { effect } from '@preact/signals-core';
|
|
10
|
-
|
|
11
9
|
import { DeferredTask, asyncTimeout } from '@dxos/async';
|
|
12
10
|
import { LifecycleState, Resource } from '@dxos/context';
|
|
13
11
|
import { type Queue } from '@dxos/echo-db';
|
|
14
|
-
import { type FunctionExecutor } from '@dxos/functions';
|
|
12
|
+
import { type FunctionExecutor } from '@dxos/functions-runtime';
|
|
15
13
|
import { log } from '@dxos/log';
|
|
16
|
-
import { type
|
|
14
|
+
import { type Message } from '@dxos/types';
|
|
17
15
|
|
|
18
|
-
import { type MessageWithRangeId, sentenceNormalization } from './normalization';
|
|
16
|
+
import { type MessageWithRangeId, type NormalizationOutput, sentenceNormalization } from './normalization';
|
|
19
17
|
import { getActorId } from './utils';
|
|
20
18
|
|
|
21
19
|
const PROCESSING_TIMEOUT = 20_000; // ms
|
|
22
20
|
const MAX_RANGE_ID_COUNT = 10;
|
|
23
21
|
|
|
24
|
-
export type
|
|
22
|
+
export type SegmentsNormalizerProps = {
|
|
25
23
|
functionExecutor: FunctionExecutor;
|
|
26
|
-
queue: Queue<
|
|
24
|
+
queue: Queue<Message.Message>;
|
|
27
25
|
startingCursor: QueueCursor;
|
|
28
26
|
};
|
|
29
27
|
|
|
@@ -36,13 +34,13 @@ export type QueueCursor = {
|
|
|
36
34
|
// TODO(mykola): .
|
|
37
35
|
export class MessageNormalizer extends Resource {
|
|
38
36
|
private readonly _functionExecutor: FunctionExecutor;
|
|
39
|
-
private _queue: Queue<
|
|
37
|
+
private _queue: Queue<Message.Message>;
|
|
40
38
|
private _cursor: QueueCursor;
|
|
41
39
|
private _messagesToProcess: MessageWithRangeId[] = [];
|
|
42
40
|
private _normalizationTask?: DeferredTask;
|
|
43
41
|
private _lastProcessedMessageIds?: string[];
|
|
44
42
|
|
|
45
|
-
constructor({ functionExecutor, queue, startingCursor }:
|
|
43
|
+
constructor({ functionExecutor, queue, startingCursor }: SegmentsNormalizerProps) {
|
|
46
44
|
super();
|
|
47
45
|
this._functionExecutor = functionExecutor;
|
|
48
46
|
this._queue = queue;
|
|
@@ -51,7 +49,8 @@ export class MessageNormalizer extends Resource {
|
|
|
51
49
|
|
|
52
50
|
protected override async _open(): Promise<void> {
|
|
53
51
|
this._normalizationTask = new DeferredTask(this._ctx, () => this._processMessages());
|
|
54
|
-
|
|
52
|
+
|
|
53
|
+
const updateMessages = () => {
|
|
55
54
|
if (this._lifecycleState !== LifecycleState.OPEN) {
|
|
56
55
|
return;
|
|
57
56
|
}
|
|
@@ -62,8 +61,14 @@ export class MessageNormalizer extends Resource {
|
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
this._normalizationTask!.schedule();
|
|
65
|
-
}
|
|
66
|
-
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Initial update.
|
|
67
|
+
updateMessages();
|
|
68
|
+
|
|
69
|
+
// Subscribe to queue changes.
|
|
70
|
+
const unsubscribe = this._queue.subscribe(updateMessages);
|
|
71
|
+
this._ctx.onDispose(unsubscribe);
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
// Need to unpack strings from blocks from messages run them through the function and then pack them back into blocks into messages.
|
|
@@ -81,7 +86,7 @@ export class MessageNormalizer extends Resource {
|
|
|
81
86
|
|
|
82
87
|
try {
|
|
83
88
|
// TODO(mykola): Executor should support timeout.
|
|
84
|
-
const response = await asyncTimeout(
|
|
89
|
+
const response: NormalizationOutput = await asyncTimeout(
|
|
85
90
|
this._functionExecutor.invoke(sentenceNormalization, { messages }),
|
|
86
91
|
PROCESSING_TIMEOUT,
|
|
87
92
|
);
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { effect } from '@preact/signals-core';
|
|
6
5
|
import { describe, test } from 'vitest';
|
|
7
6
|
|
|
8
7
|
import { scheduleTaskInterval } from '@dxos/async';
|
|
@@ -10,15 +9,15 @@ import { Context } from '@dxos/context';
|
|
|
10
9
|
import { Obj } from '@dxos/echo';
|
|
11
10
|
import { createQueueDXN } from '@dxos/echo/internal';
|
|
12
11
|
import { MemoryQueue } from '@dxos/echo-db';
|
|
13
|
-
import { FunctionExecutor, ServiceContainer } from '@dxos/functions';
|
|
12
|
+
import { FunctionExecutor, ServiceContainer } from '@dxos/functions-runtime';
|
|
14
13
|
import { log } from '@dxos/log';
|
|
15
|
-
import {
|
|
14
|
+
import { type Actor, Message } from '@dxos/types';
|
|
16
15
|
|
|
17
16
|
import { MessageNormalizer } from './message-normalizer';
|
|
18
17
|
import { type MessageWithRangeId, sentenceNormalization } from './normalization';
|
|
19
18
|
import { getActorId } from './utils';
|
|
20
19
|
|
|
21
|
-
const sender:
|
|
20
|
+
const sender: Actor.Actor = {
|
|
22
21
|
identityDid: 'did:key:123',
|
|
23
22
|
};
|
|
24
23
|
|
|
@@ -48,7 +47,7 @@ const messages: MessageWithRangeId[] = [
|
|
|
48
47
|
// No punctuation.
|
|
49
48
|
'in classical physics objects have well-defined properties such as position speed and momentum',
|
|
50
49
|
].map((string, index) =>
|
|
51
|
-
Obj.make(
|
|
50
|
+
Obj.make(Message.Message, {
|
|
52
51
|
created: new Date(Date.now() + 1_000 * index).toISOString(),
|
|
53
52
|
sender,
|
|
54
53
|
blocks: [{ _tag: 'transcript', started: new Date(Date.now() + 1_000 * index).toISOString(), text: string }],
|
|
@@ -108,7 +107,7 @@ describe.skip('SentenceNormalization', () => {
|
|
|
108
107
|
test.only('queue', { timeout: 120_000 }, async () => {
|
|
109
108
|
// Create queue.
|
|
110
109
|
// TODO(dmaretskyi): Use space.queues.create() instead.
|
|
111
|
-
const queue = new MemoryQueue<
|
|
110
|
+
const queue = new MemoryQueue<Message.Message>(createQueueDXN());
|
|
112
111
|
const ctx = new Context();
|
|
113
112
|
let idx = 0;
|
|
114
113
|
scheduleTaskInterval(
|
|
@@ -133,10 +132,6 @@ describe.skip('SentenceNormalization', () => {
|
|
|
133
132
|
|
|
134
133
|
// Start normalizer.
|
|
135
134
|
await normalizer.open();
|
|
136
|
-
effect(() => {
|
|
137
|
-
log.info('normalizer');
|
|
138
|
-
log.info(JSON.stringify(queue.objects, null, 2));
|
|
139
|
-
});
|
|
140
135
|
|
|
141
136
|
await new Promise(() => {});
|
|
142
137
|
});
|
|
@@ -13,13 +13,13 @@ import { Obj } from '@dxos/echo';
|
|
|
13
13
|
import { defineFunction } from '@dxos/functions';
|
|
14
14
|
import { ObjectId } from '@dxos/keys';
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
|
-
import {
|
|
16
|
+
import { Message } from '@dxos/types';
|
|
17
17
|
import { trim } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
const MessageWithRangeId = Schema.extend(
|
|
20
|
-
|
|
20
|
+
Message.Message,
|
|
21
21
|
Schema.Struct({
|
|
22
|
-
// TODO(mykola): Move to meta in
|
|
22
|
+
// TODO(mykola): Move to meta in Message. Use `Message.Message` instead.
|
|
23
23
|
rangeId: Schema.optional(Schema.Array(Schema.String)).annotations({
|
|
24
24
|
description: 'The IDs of the messages that contain the sentences.',
|
|
25
25
|
}),
|
|
@@ -29,7 +29,7 @@ const MessageWithRangeId = Schema.extend(
|
|
|
29
29
|
export interface MessageWithRangeId extends Schema.Schema.Type<typeof MessageWithRangeId> {}
|
|
30
30
|
|
|
31
31
|
export const NormalizationInput = Schema.Struct({
|
|
32
|
-
// TODO(mykola): Move to meta in
|
|
32
|
+
// TODO(mykola): Move to meta in Message. Use `Message.Message` instead.
|
|
33
33
|
messages: Schema.Array(MessageWithRangeId).annotations({
|
|
34
34
|
description: 'Messages to normalize into sentences.',
|
|
35
35
|
}),
|
|
@@ -61,7 +61,7 @@ export const sentenceNormalization = defineFunction<NormalizationInput, Normaliz
|
|
|
61
61
|
tools: [],
|
|
62
62
|
artifacts: [],
|
|
63
63
|
history: [
|
|
64
|
-
Obj.make(
|
|
64
|
+
Obj.make(Message.Message, {
|
|
65
65
|
created: new Date().toISOString(),
|
|
66
66
|
sender: {
|
|
67
67
|
role: 'user',
|
|
@@ -89,7 +89,7 @@ const prompt = trim`
|
|
|
89
89
|
|
|
90
90
|
# Input Format:
|
|
91
91
|
- The input is an array of messages that contain transcription blocks.
|
|
92
|
-
- Each message is a
|
|
92
|
+
- Each message is a Message.Message, as described in the output format.
|
|
93
93
|
|
|
94
94
|
# Output Format:
|
|
95
95
|
- You have been provided with the tool that defines the output format; make sure to query it.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Actor } from '@dxos/types';
|
|
6
6
|
|
|
7
|
-
export const getActorId = (actor:
|
|
7
|
+
export const getActorId = (actor: Actor.Actor) => {
|
|
8
8
|
return actor.identityDid || actor.identityKey || actor.email || actor.name || '';
|
|
9
9
|
};
|