@effect-uai/core 0.2.0 → 0.4.0
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/README.md +1 -1
- package/dist/{AiError-CqmYjXyx.d.mts → AiError-csR8Bhxx.d.mts} +26 -4
- package/dist/{AiError-CqmYjXyx.d.mts.map → AiError-csR8Bhxx.d.mts.map} +1 -1
- package/dist/Audio-BfCTGnH3.d.mts +61 -0
- package/dist/Audio-BfCTGnH3.d.mts.map +1 -0
- package/dist/Image-DxyXqzAM.d.mts +61 -0
- package/dist/Image-DxyXqzAM.d.mts.map +1 -0
- package/dist/{Items-D1C2686t.d.mts → Items-Hg5AsYxl.d.mts} +132 -80
- package/dist/Items-Hg5AsYxl.d.mts.map +1 -0
- package/dist/Media-D_CpcM1Z.d.mts +57 -0
- package/dist/Media-D_CpcM1Z.d.mts.map +1 -0
- package/dist/{StructuredFormat-B5ueioNr.d.mts → StructuredFormat-Cl41C56K.d.mts} +5 -5
- package/dist/StructuredFormat-Cl41C56K.d.mts.map +1 -0
- package/dist/{Tool-5wxOCuOh.d.mts → Tool-B8B5qVEy.d.mts} +13 -13
- package/dist/Tool-B8B5qVEy.d.mts.map +1 -0
- package/dist/{Turn-Bi83du4I.d.mts → Turn-7geUcKsf.d.mts} +5 -11
- package/dist/Turn-7geUcKsf.d.mts.map +1 -0
- package/dist/{chunk-CfYAbeIz.mjs → chunk-uyGKjUfl.mjs} +2 -1
- package/dist/dist-DV5ISja1.mjs +13782 -0
- package/dist/dist-DV5ISja1.mjs.map +1 -0
- package/dist/domain/AiError.d.mts +2 -2
- package/dist/domain/AiError.mjs +19 -3
- package/dist/domain/AiError.mjs.map +1 -1
- package/dist/domain/Audio.d.mts +2 -0
- package/dist/domain/Audio.mjs +14 -0
- package/dist/domain/Audio.mjs.map +1 -0
- package/dist/domain/Image.d.mts +2 -0
- package/dist/domain/Image.mjs +58 -0
- package/dist/domain/Image.mjs.map +1 -0
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +19 -42
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Media.d.mts +2 -0
- package/dist/domain/Media.mjs +14 -0
- package/dist/domain/Media.mjs.map +1 -0
- package/dist/domain/Music.d.mts +116 -0
- package/dist/domain/Music.d.mts.map +1 -0
- package/dist/domain/Music.mjs +29 -0
- package/dist/domain/Music.mjs.map +1 -0
- package/dist/domain/Transcript.d.mts +95 -0
- package/dist/domain/Transcript.d.mts.map +1 -0
- package/dist/domain/Transcript.mjs +22 -0
- package/dist/domain/Transcript.mjs.map +1 -0
- package/dist/domain/Turn.d.mts +1 -1
- package/dist/domain/Turn.mjs +1 -1
- package/dist/embedding-model/Embedding.d.mts +107 -0
- package/dist/embedding-model/Embedding.d.mts.map +1 -0
- package/dist/embedding-model/Embedding.mjs +18 -0
- package/dist/embedding-model/Embedding.mjs.map +1 -0
- package/dist/embedding-model/EmbeddingModel.d.mts +97 -0
- package/dist/embedding-model/EmbeddingModel.d.mts.map +1 -0
- package/dist/embedding-model/EmbeddingModel.mjs +17 -0
- package/dist/embedding-model/EmbeddingModel.mjs.map +1 -0
- package/dist/index.d.mts +21 -7
- package/dist/index.mjs +16 -2
- package/dist/language-model/LanguageModel.d.mts +12 -20
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs +3 -20
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +31 -7
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +39 -6
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.d.mts +1 -0
- package/dist/loop/Loop.test.mjs +411 -0
- package/dist/loop/Loop.test.mjs.map +1 -0
- package/dist/magic-string.es-BgIV5Mu3.mjs +1013 -0
- package/dist/magic-string.es-BgIV5Mu3.mjs.map +1 -0
- package/dist/math/Vector.d.mts +47 -0
- package/dist/math/Vector.d.mts.map +1 -0
- package/dist/math/Vector.mjs +117 -0
- package/dist/math/Vector.mjs.map +1 -0
- package/dist/music-generator/MusicGenerator.d.mts +77 -0
- package/dist/music-generator/MusicGenerator.d.mts.map +1 -0
- package/dist/music-generator/MusicGenerator.mjs +51 -0
- package/dist/music-generator/MusicGenerator.mjs.map +1 -0
- package/dist/music-generator/MusicGenerator.test.d.mts +1 -0
- package/dist/music-generator/MusicGenerator.test.mjs +154 -0
- package/dist/music-generator/MusicGenerator.test.mjs.map +1 -0
- package/dist/observability/Metrics.d.mts +2 -2
- package/dist/observability/Metrics.d.mts.map +1 -1
- package/dist/observability/Metrics.mjs +1 -1
- package/dist/observability/Metrics.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +96 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +48 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.test.d.mts +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +112 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -0
- package/dist/streaming/JSONL.d.mts +10 -3
- package/dist/streaming/JSONL.d.mts.map +1 -1
- package/dist/streaming/JSONL.mjs +13 -2
- package/dist/streaming/JSONL.mjs.map +1 -1
- package/dist/streaming/JSONL.test.d.mts +1 -0
- package/dist/streaming/JSONL.test.mjs +70 -0
- package/dist/streaming/JSONL.test.mjs.map +1 -0
- package/dist/streaming/Lines.mjs +1 -1
- package/dist/streaming/SSE.d.mts +2 -2
- package/dist/streaming/SSE.d.mts.map +1 -1
- package/dist/streaming/SSE.mjs +1 -1
- package/dist/streaming/SSE.mjs.map +1 -1
- package/dist/streaming/SSE.test.d.mts +1 -0
- package/dist/streaming/SSE.test.mjs +72 -0
- package/dist/streaming/SSE.test.mjs.map +1 -0
- package/dist/structured-format/StructuredFormat.d.mts +1 -1
- package/dist/structured-format/StructuredFormat.mjs +1 -1
- package/dist/structured-format/StructuredFormat.mjs.map +1 -1
- package/dist/testing/MockMusicGenerator.d.mts +39 -0
- package/dist/testing/MockMusicGenerator.d.mts.map +1 -0
- package/dist/testing/MockMusicGenerator.mjs +96 -0
- package/dist/testing/MockMusicGenerator.mjs.map +1 -0
- package/dist/testing/MockProvider.d.mts +6 -6
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.d.mts +37 -0
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -0
- package/dist/testing/MockSpeechSynthesizer.mjs +95 -0
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -0
- package/dist/testing/MockTranscriber.d.mts +37 -0
- package/dist/testing/MockTranscriber.d.mts.map +1 -0
- package/dist/testing/MockTranscriber.mjs +77 -0
- package/dist/testing/MockTranscriber.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -3
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +7 -1
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Outcome.d.mts +138 -2
- package/dist/tool/Outcome.d.mts.map +1 -0
- package/dist/tool/Outcome.mjs +32 -10
- package/dist/tool/Outcome.mjs.map +1 -1
- package/dist/tool/Resolvers.d.mts +11 -8
- package/dist/tool/Resolvers.d.mts.map +1 -1
- package/dist/tool/Resolvers.mjs +10 -1
- package/dist/tool/Resolvers.mjs.map +1 -1
- package/dist/tool/Resolvers.test.d.mts +1 -0
- package/dist/tool/Resolvers.test.mjs +317 -0
- package/dist/tool/Resolvers.test.mjs.map +1 -0
- package/dist/tool/Tool.d.mts +1 -1
- package/dist/tool/Tool.mjs +1 -1
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +151 -2
- package/dist/tool/ToolEvent.d.mts.map +1 -0
- package/dist/tool/ToolEvent.mjs +30 -4
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/Toolkit.d.mts +19 -10
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +5 -5
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.d.mts +1 -0
- package/dist/tool/Toolkit.test.mjs +113 -0
- package/dist/tool/Toolkit.test.mjs.map +1 -0
- package/dist/transcriber/Transcriber.d.mts +101 -0
- package/dist/transcriber/Transcriber.d.mts.map +1 -0
- package/dist/transcriber/Transcriber.mjs +49 -0
- package/dist/transcriber/Transcriber.mjs.map +1 -0
- package/dist/transcriber/Transcriber.test.d.mts +1 -0
- package/dist/transcriber/Transcriber.test.mjs +130 -0
- package/dist/transcriber/Transcriber.test.mjs.map +1 -0
- package/package.json +65 -13
- package/src/domain/AiError.ts +21 -0
- package/src/domain/Audio.ts +88 -0
- package/src/domain/Image.ts +75 -0
- package/src/domain/Items.ts +18 -47
- package/src/domain/Media.ts +61 -0
- package/src/domain/Music.ts +121 -0
- package/src/domain/Transcript.ts +83 -0
- package/src/embedding-model/Embedding.ts +117 -0
- package/src/embedding-model/EmbeddingModel.ts +107 -0
- package/src/index.ts +15 -1
- package/src/language-model/LanguageModel.ts +2 -22
- package/src/loop/Loop.test.ts +114 -2
- package/src/loop/Loop.ts +69 -5
- package/src/math/Vector.ts +138 -0
- package/src/music-generator/MusicGenerator.test.ts +170 -0
- package/src/music-generator/MusicGenerator.ts +123 -0
- package/src/observability/Metrics.ts +1 -1
- package/src/speech-synthesizer/SpeechSynthesizer.test.ts +141 -0
- package/src/speech-synthesizer/SpeechSynthesizer.ts +131 -0
- package/src/streaming/JSONL.ts +12 -0
- package/src/streaming/SSE.ts +1 -1
- package/src/structured-format/StructuredFormat.ts +2 -2
- package/src/testing/MockMusicGenerator.ts +170 -0
- package/src/testing/MockProvider.ts +2 -2
- package/src/testing/MockSpeechSynthesizer.ts +165 -0
- package/src/testing/MockTranscriber.ts +139 -0
- package/src/tool/HistoryCheck.ts +2 -5
- package/src/tool/Outcome.ts +36 -36
- package/src/tool/Resolvers.test.ts +11 -35
- package/src/tool/Resolvers.ts +5 -14
- package/src/tool/Tool.ts +9 -9
- package/src/tool/ToolEvent.ts +28 -24
- package/src/tool/Toolkit.test.ts +97 -2
- package/src/tool/Toolkit.ts +57 -33
- package/src/transcriber/Transcriber.test.ts +125 -0
- package/src/transcriber/Transcriber.ts +127 -0
- package/dist/Items-D1C2686t.d.mts.map +0 -1
- package/dist/Outcome-GiaNvt7i.d.mts +0 -32
- package/dist/Outcome-GiaNvt7i.d.mts.map +0 -1
- package/dist/StructuredFormat-B5ueioNr.d.mts.map +0 -1
- package/dist/Tool-5wxOCuOh.d.mts.map +0 -1
- package/dist/ToolEvent-wTMgb2GO.d.mts +0 -29
- package/dist/ToolEvent-wTMgb2GO.d.mts.map +0 -1
- package/dist/Turn-Bi83du4I.d.mts.map +0 -1
- package/dist/match/Match.d.mts +0 -16
- package/dist/match/Match.d.mts.map +0 -1
- package/dist/match/Match.mjs +0 -15
- package/dist/match/Match.mjs.map +0 -1
- package/src/match/Match.ts +0 -9
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
declare namespace Transcript_d_exports {
|
|
2
|
+
export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Per-word timing + metadata. `confidence` and `speakerId` are optional
|
|
6
|
+
* because providers vary widely in what they emit and when (some only on
|
|
7
|
+
* final, some only with diarization enabled, some not at all).
|
|
8
|
+
*/
|
|
9
|
+
type WordTimestamp = {
|
|
10
|
+
readonly text: string;
|
|
11
|
+
readonly startSeconds: number;
|
|
12
|
+
readonly endSeconds: number;
|
|
13
|
+
readonly confidence?: number;
|
|
14
|
+
readonly speakerId?: string;
|
|
15
|
+
readonly languageCode?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Sync STT result. `raw` preserves the provider-specific response for
|
|
19
|
+
* consumers that need fields the common shape doesn't expose
|
|
20
|
+
* (alternatives, segments, NBest, audio events, etc.).
|
|
21
|
+
*/
|
|
22
|
+
type TranscriptResult = {
|
|
23
|
+
readonly text: string;
|
|
24
|
+
readonly languageCode?: string;
|
|
25
|
+
readonly durationSeconds?: number;
|
|
26
|
+
readonly words?: ReadonlyArray<WordTimestamp>;
|
|
27
|
+
readonly raw?: unknown;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Streaming STT event union. Collapses every provider's vocabulary into
|
|
31
|
+
* a small set; provider-specific shapes survive on `metadata.raw`.
|
|
32
|
+
*
|
|
33
|
+
* - `partial`: interim hypothesis. `stability` is Google-only.
|
|
34
|
+
* - `final`: committed transcript for the current utterance / segment.
|
|
35
|
+
* - `speech-started` / `utterance-ended`: VAD-derived boundaries. Not
|
|
36
|
+
* all providers emit them (OpenAI Realtime, Google with
|
|
37
|
+
* `voice_activity_events`, Deepgram with `vad_events`, AssemblyAI).
|
|
38
|
+
* - `audio-event`: non-speech label (`(laughter)`, `(music)`) — ElevenLabs only.
|
|
39
|
+
* - `metadata`: opaque server-side bookkeeping (request_id, model info).
|
|
40
|
+
* - `error`: non-fatal provider error mid-stream. Fatal errors surface
|
|
41
|
+
* on the `Stream`'s error channel as `AiError.AiError`.
|
|
42
|
+
*/
|
|
43
|
+
type TranscriptEvent = {
|
|
44
|
+
readonly _tag: "partial";
|
|
45
|
+
readonly text: string;
|
|
46
|
+
readonly words?: ReadonlyArray<WordTimestamp>;
|
|
47
|
+
readonly stability?: number;
|
|
48
|
+
} | {
|
|
49
|
+
readonly _tag: "final";
|
|
50
|
+
readonly text: string;
|
|
51
|
+
readonly words?: ReadonlyArray<WordTimestamp>;
|
|
52
|
+
readonly languageCode?: string;
|
|
53
|
+
} | {
|
|
54
|
+
readonly _tag: "speech-started";
|
|
55
|
+
readonly atSeconds: number;
|
|
56
|
+
} | {
|
|
57
|
+
readonly _tag: "utterance-ended";
|
|
58
|
+
readonly atSeconds: number;
|
|
59
|
+
} | {
|
|
60
|
+
readonly _tag: "audio-event";
|
|
61
|
+
readonly label: string;
|
|
62
|
+
readonly startSeconds: number;
|
|
63
|
+
readonly endSeconds: number;
|
|
64
|
+
} | {
|
|
65
|
+
readonly _tag: "metadata";
|
|
66
|
+
readonly raw: unknown;
|
|
67
|
+
} | {
|
|
68
|
+
readonly _tag: "error";
|
|
69
|
+
readonly code?: string;
|
|
70
|
+
readonly message: string;
|
|
71
|
+
};
|
|
72
|
+
declare const isPartial: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
73
|
+
_tag: "partial";
|
|
74
|
+
}>;
|
|
75
|
+
declare const isFinal: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
76
|
+
_tag: "final";
|
|
77
|
+
}>;
|
|
78
|
+
declare const isSpeechStarted: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
79
|
+
_tag: "speech-started";
|
|
80
|
+
}>;
|
|
81
|
+
declare const isUtteranceEnded: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
82
|
+
_tag: "utterance-ended";
|
|
83
|
+
}>;
|
|
84
|
+
declare const isAudioEvent: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
85
|
+
_tag: "audio-event";
|
|
86
|
+
}>;
|
|
87
|
+
declare const isMetadata: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
88
|
+
_tag: "metadata";
|
|
89
|
+
}>;
|
|
90
|
+
declare const isError: (e: TranscriptEvent) => e is Extract<TranscriptEvent, {
|
|
91
|
+
_tag: "error";
|
|
92
|
+
}>;
|
|
93
|
+
//#endregion
|
|
94
|
+
export { TranscriptEvent, TranscriptResult, WordTimestamp, isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded, Transcript_d_exports as t };
|
|
95
|
+
//# sourceMappingURL=Transcript.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transcript.d.mts","names":[],"sources":["../../src/domain/Transcript.ts"],"mappings":";;;;;;;;KAKY,aAAA;EAAA,SACD,IAAA;EAAA,SACA,YAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA;EAAA,SACA,SAAA;EAAA,SACA,YAAA;AAAA;;;AANX;;;KAcY,gBAAA;EAAA,SACD,IAAA;EAAA,SACA,YAAA;EAAA,SACA,eAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,GAAA;AAAA;;;AALX;;;;;;;;;;;;KAsBY,eAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,SAAA;AAAA;EAAA,SAGA,IAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,aAAA;EAAA,SACtB,YAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAAiC,SAAA;AAAA;EAAA,SACjC,IAAA;EAAA,SAAkC,SAAA;AAAA;EAAA,SAElC,IAAA;EAAA,SACA,KAAA;EAAA,SACA,YAAA;EAAA,SACA,UAAA;AAAA;EAAA,SAEA,IAAA;EAAA,SAA2B,GAAA;AAAA;EAAA,SAC3B,IAAA;EAAA,SAAwB,IAAA;EAAA,SAAwB,OAAA;AAAA;AAAA,cAElD,SAAA,GAAa,CAAA,EAAG,eAAA,KAAkB,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cAElE,OAAA,GAAW,CAAA,EAAG,eAAA,KAAkB,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cAEhE,eAAA,GACX,CAAA,EAAG,eAAA,KACF,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cACtB,gBAAA,GACX,CAAA,EAAG,eAAA,KACF,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cACtB,YAAA,GACX,CAAA,EAAG,eAAA,KACF,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cACtB,UAAA,GACX,CAAA,EAAG,eAAA,KACF,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA;AAAA,cACtB,OAAA,GAAW,CAAA,EAAG,eAAA,KAAkB,CAAA,IAAK,OAAA,CAAQ,eAAA;EAAmB,IAAA;AAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
+
//#region src/domain/Transcript.ts
|
|
3
|
+
var Transcript_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
isAudioEvent: () => isAudioEvent,
|
|
5
|
+
isError: () => isError,
|
|
6
|
+
isFinal: () => isFinal,
|
|
7
|
+
isMetadata: () => isMetadata,
|
|
8
|
+
isPartial: () => isPartial,
|
|
9
|
+
isSpeechStarted: () => isSpeechStarted,
|
|
10
|
+
isUtteranceEnded: () => isUtteranceEnded
|
|
11
|
+
});
|
|
12
|
+
const isPartial = (e) => e._tag === "partial";
|
|
13
|
+
const isFinal = (e) => e._tag === "final";
|
|
14
|
+
const isSpeechStarted = (e) => e._tag === "speech-started";
|
|
15
|
+
const isUtteranceEnded = (e) => e._tag === "utterance-ended";
|
|
16
|
+
const isAudioEvent = (e) => e._tag === "audio-event";
|
|
17
|
+
const isMetadata = (e) => e._tag === "metadata";
|
|
18
|
+
const isError = (e) => e._tag === "error";
|
|
19
|
+
//#endregion
|
|
20
|
+
export { isAudioEvent, isError, isFinal, isMetadata, isPartial, isSpeechStarted, isUtteranceEnded, Transcript_exports as t };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=Transcript.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transcript.mjs","names":[],"sources":["../../src/domain/Transcript.ts"],"sourcesContent":["/**\n * Per-word timing + metadata. `confidence` and `speakerId` are optional\n * because providers vary widely in what they emit and when (some only on\n * final, some only with diarization enabled, some not at all).\n */\nexport type WordTimestamp = {\n readonly text: string\n readonly startSeconds: number\n readonly endSeconds: number\n readonly confidence?: number\n readonly speakerId?: string\n readonly languageCode?: string\n}\n\n/**\n * Sync STT result. `raw` preserves the provider-specific response for\n * consumers that need fields the common shape doesn't expose\n * (alternatives, segments, NBest, audio events, etc.).\n */\nexport type TranscriptResult = {\n readonly text: string\n readonly languageCode?: string\n readonly durationSeconds?: number\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly raw?: unknown\n}\n\n/**\n * Streaming STT event union. Collapses every provider's vocabulary into\n * a small set; provider-specific shapes survive on `metadata.raw`.\n *\n * - `partial`: interim hypothesis. `stability` is Google-only.\n * - `final`: committed transcript for the current utterance / segment.\n * - `speech-started` / `utterance-ended`: VAD-derived boundaries. Not\n * all providers emit them (OpenAI Realtime, Google with\n * `voice_activity_events`, Deepgram with `vad_events`, AssemblyAI).\n * - `audio-event`: non-speech label (`(laughter)`, `(music)`) — ElevenLabs only.\n * - `metadata`: opaque server-side bookkeeping (request_id, model info).\n * - `error`: non-fatal provider error mid-stream. Fatal errors surface\n * on the `Stream`'s error channel as `AiError.AiError`.\n */\nexport type TranscriptEvent =\n | {\n readonly _tag: \"partial\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly stability?: number\n }\n | {\n readonly _tag: \"final\"\n readonly text: string\n readonly words?: ReadonlyArray<WordTimestamp>\n readonly languageCode?: string\n }\n | { readonly _tag: \"speech-started\"; readonly atSeconds: number }\n | { readonly _tag: \"utterance-ended\"; readonly atSeconds: number }\n | {\n readonly _tag: \"audio-event\"\n readonly label: string\n readonly startSeconds: number\n readonly endSeconds: number\n }\n | { readonly _tag: \"metadata\"; readonly raw: unknown }\n | { readonly _tag: \"error\"; readonly code?: string; readonly message: string }\n\nexport const isPartial = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"partial\" }> =>\n e._tag === \"partial\"\nexport const isFinal = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"final\" }> =>\n e._tag === \"final\"\nexport const isSpeechStarted = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"speech-started\" }> => e._tag === \"speech-started\"\nexport const isUtteranceEnded = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"utterance-ended\" }> => e._tag === \"utterance-ended\"\nexport const isAudioEvent = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"audio-event\" }> => e._tag === \"audio-event\"\nexport const isMetadata = (\n e: TranscriptEvent,\n): e is Extract<TranscriptEvent, { _tag: \"metadata\" }> => e._tag === \"metadata\"\nexport const isError = (e: TranscriptEvent): e is Extract<TranscriptEvent, { _tag: \"error\" }> =>\n e._tag === \"error\"\n"],"mappings":";;;;;;;;;;;AAiEA,MAAa,aAAa,MACxB,EAAE,SAAS;AACb,MAAa,WAAW,MACtB,EAAE,SAAS;AACb,MAAa,mBACX,MAC8D,EAAE,SAAS;AAC3E,MAAa,oBACX,MAC+D,EAAE,SAAS;AAC5E,MAAa,gBACX,MAC2D,EAAE,SAAS;AACxE,MAAa,cACX,MACwD,EAAE,SAAS;AACrE,MAAa,WAAW,MACtB,EAAE,SAAS"}
|
package/dist/domain/Turn.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { c as functionCalls, d as textDeltas, f as toStructured, i as TurnEvent, l as isTurnComplete, n as RefusalRejected, o as appendTurn, r as Turn, s as assistantMessages, t as InteractionEvent, u as reasonings } from "../Turn-
|
|
1
|
+
import { c as functionCalls, d as textDeltas, f as toStructured, i as TurnEvent, l as isTurnComplete, n as RefusalRejected, o as appendTurn, r as Turn, s as assistantMessages, t as InteractionEvent, u as reasonings } from "../Turn-7geUcKsf.mjs";
|
|
2
2
|
export { InteractionEvent, RefusalRejected, Turn, TurnEvent, appendTurn, assistantMessages, functionCalls, isTurnComplete, reasonings, textDeltas, toStructured };
|
package/dist/domain/Turn.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
2
|
import { Item, StopReason, Usage, isOutputText, isRefusal } from "./Items.mjs";
|
|
3
3
|
import { parseJson } from "../structured-format/StructuredFormat.mjs";
|
|
4
4
|
import { Data, Effect, Result, Schema, Stream, pipe } from "effect";
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { i as ImageSource } from "../Image-DxyXqzAM.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/embedding-model/Embedding.d.ts
|
|
4
|
+
declare namespace Embedding_d_exports {
|
|
5
|
+
export { BinaryEmbedding, EmbedContentPart, EmbedInput, Embedding, Float32Embedding, Int8Embedding, MultivectorEmbedding, SparseEmbedding, Usage, isBinary, isFloat32, isInt8, isMultivector, isSparse };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* One part of a mixed text+image input. Used inside `EmbedInput.content[]`
|
|
9
|
+
* for providers that accept interleaved modalities in a single embed call
|
|
10
|
+
* (Cohere v4, Voyage multimodal, Jina v4, Google `gemini-embedding-2`).
|
|
11
|
+
*/
|
|
12
|
+
type EmbedContentPart = {
|
|
13
|
+
readonly text: string;
|
|
14
|
+
} | {
|
|
15
|
+
readonly image: ImageSource;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* What you embed. The `string` shorthand covers the common text-only case;
|
|
19
|
+
* structured variants exist for image-only and mixed-modality inputs.
|
|
20
|
+
*
|
|
21
|
+
* Not every provider accepts every variant: text-only providers (OpenAI,
|
|
22
|
+
* Mixedbread today) handle `string` and `{ text }`; multimodal providers
|
|
23
|
+
* (Google, Jina v4, Voyage multimodal, Cohere v4) handle all four. A
|
|
24
|
+
* provider layer rejects shapes it can't encode as `AiError.InvalidRequest`.
|
|
25
|
+
*/
|
|
26
|
+
type EmbedInput = string | {
|
|
27
|
+
readonly text: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly image: ImageSource;
|
|
30
|
+
} | {
|
|
31
|
+
readonly content: ReadonlyArray<EmbedContentPart>;
|
|
32
|
+
};
|
|
33
|
+
/** Dense float32 vector. The default representation across all providers. */
|
|
34
|
+
type Float32Embedding = {
|
|
35
|
+
readonly _tag: "float32";
|
|
36
|
+
readonly vector: Float32Array;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Dense int8-quantized vector. ~4x smaller than float32 with minimal
|
|
40
|
+
* recall loss on most benchmarks.
|
|
41
|
+
*/
|
|
42
|
+
type Int8Embedding = {
|
|
43
|
+
readonly _tag: "int8";
|
|
44
|
+
readonly vector: Int8Array;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Dense binary-quantized vector. One bit per dimension, packed into bytes.
|
|
48
|
+
* ~32x smaller than float32; meaningful recall loss but useful for hot
|
|
49
|
+
* indexes paired with a float32 reranker pass.
|
|
50
|
+
*/
|
|
51
|
+
type BinaryEmbedding = {
|
|
52
|
+
readonly _tag: "binary";
|
|
53
|
+
readonly vector: Uint8Array;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Sparse vector. Token-keyed weights for hybrid search (dense + lexical-
|
|
57
|
+
* style sparse). The single hosted producer today is Jina's `elser-v2`
|
|
58
|
+
* model, which returns subword tokens (e.g. `"bread"`, `"##ing"`) with
|
|
59
|
+
* their relevance weights.
|
|
60
|
+
*
|
|
61
|
+
* The shape is `Record<string, number>` rather than `(indices, values)`
|
|
62
|
+
* because real hosted learned-sparse encoders (ELSER, SPLADE) emit token
|
|
63
|
+
* strings with no shared vocabulary index. Converting to integer indices
|
|
64
|
+
* would either need a vocabulary table the model doesn't expose, or
|
|
65
|
+
* lose the cross-vector matching semantics. If a provider ever exposes
|
|
66
|
+
* index-valued sparse vectors (Pinecone-style, where you bring your own
|
|
67
|
+
* vocab), add an `IndexSparseEmbedding` sibling arm with `_tag:
|
|
68
|
+
* "sparse-indexed"`.
|
|
69
|
+
*
|
|
70
|
+
* Score with `Vector.sparseCosine` — dot product over the intersection
|
|
71
|
+
* of keys, normalized by the L2 norms of both maps.
|
|
72
|
+
*/
|
|
73
|
+
type SparseEmbedding = {
|
|
74
|
+
readonly _tag: "sparse";
|
|
75
|
+
readonly weights: Readonly<Record<string, number>>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Multivector / late-interaction output: one float32 vector per token.
|
|
79
|
+
* Score documents with `Vector.maxSim` (ColBERT-style: per query vector,
|
|
80
|
+
* max dot product across doc vectors, summed). Typically ~50-500 vectors
|
|
81
|
+
* per document, each shorter than a single-vector embedding (~128 dim
|
|
82
|
+
* vs ~1024).
|
|
83
|
+
*
|
|
84
|
+
* Quantized multivector forms aren't modeled for the same reason as
|
|
85
|
+
* sparse - nothing on hosted APIs ships them yet.
|
|
86
|
+
*/
|
|
87
|
+
type MultivectorEmbedding = {
|
|
88
|
+
readonly _tag: "multivector";
|
|
89
|
+
readonly vectors: ReadonlyArray<Float32Array>;
|
|
90
|
+
};
|
|
91
|
+
type Embedding = Float32Embedding | Int8Embedding | BinaryEmbedding | SparseEmbedding | MultivectorEmbedding;
|
|
92
|
+
declare const isFloat32: (e: Embedding) => e is Float32Embedding;
|
|
93
|
+
declare const isInt8: (e: Embedding) => e is Int8Embedding;
|
|
94
|
+
declare const isBinary: (e: Embedding) => e is BinaryEmbedding;
|
|
95
|
+
declare const isSparse: (e: Embedding) => e is SparseEmbedding;
|
|
96
|
+
declare const isMultivector: (e: Embedding) => e is MultivectorEmbedding;
|
|
97
|
+
/**
|
|
98
|
+
* Token usage for one embed / embedMany call. One value per HTTP request,
|
|
99
|
+
* not per input vector. Most providers populate `inputTokens`; the field
|
|
100
|
+
* is optional for those that don't (or for mock layers in tests).
|
|
101
|
+
*/
|
|
102
|
+
type Usage = {
|
|
103
|
+
readonly inputTokens?: number;
|
|
104
|
+
};
|
|
105
|
+
//#endregion
|
|
106
|
+
export { BinaryEmbedding, EmbedContentPart, EmbedInput, Embedding, Float32Embedding, Int8Embedding, MultivectorEmbedding, SparseEmbedding, Usage, isBinary, isFloat32, isInt8, isMultivector, isSparse, Embedding_d_exports as t };
|
|
107
|
+
//# sourceMappingURL=Embedding.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embedding.d.mts","names":[],"sources":["../../src/embedding-model/Embedding.ts"],"mappings":";;;;;;;;;;;KAOY,gBAAA;EAAA,SAA8B,IAAA;AAAA;EAAA,SAA4B,KAAA,EAAO,WAAA;AAAA;;;;;;;;;;KAWjE,UAAA;EAAA,SAEG,IAAA;AAAA;EAAA,SACA,KAAA,EAAO,WAAA;AAAA;EAAA,SACP,OAAA,EAAS,aAAA,CAAc,gBAAA;AAAA;;KAY1B,gBAAA;EAAA,SACD,IAAA;EAAA,SACA,MAAA,EAAQ,YAAA;AAAA;;;;;KAOP,aAAA;EAAA,SACD,IAAA;EAAA,SACA,MAAA,EAAQ,SAAA;AAAA;;;;;;KAQP,eAAA;EAAA,SACD,IAAA;EAAA,SACA,MAAA,EAAQ,UAAA;AAAA;;;;;;AAZnB;;;;;;;;;AAUA;;;;KAuBY,eAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA,EAAS,QAAA,CAAS,MAAA;AAAA;;AAF7B;;;;;;;;;KAeY,oBAAA;EAAA,SACD,IAAA;EAAA,SACA,OAAA,EAAS,aAAA,CAAc,YAAA;AAAA;AAAA,KAGtB,SAAA,GACR,gBAAA,GACA,aAAA,GACA,eAAA,GACA,eAAA,GACA,oBAAA;AAAA,cAES,SAAA,GAAa,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,gBAAA;AAAA,cACjC,MAAA,GAAU,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,aAAA;AAAA,cAC9B,QAAA,GAAY,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,eAAA;AAAA,cAChC,QAAA,GAAY,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,eAAA;AAAA,cAChC,aAAA,GAAiB,CAAA,EAAG,SAAA,KAAY,CAAA,IAAK,oBAAA;;AAXlD;;;;KAkBY,KAAA;EAAA,SACD,WAAA;AAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
+
//#region src/embedding-model/Embedding.ts
|
|
3
|
+
var Embedding_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
isBinary: () => isBinary,
|
|
5
|
+
isFloat32: () => isFloat32,
|
|
6
|
+
isInt8: () => isInt8,
|
|
7
|
+
isMultivector: () => isMultivector,
|
|
8
|
+
isSparse: () => isSparse
|
|
9
|
+
});
|
|
10
|
+
const isFloat32 = (e) => e._tag === "float32";
|
|
11
|
+
const isInt8 = (e) => e._tag === "int8";
|
|
12
|
+
const isBinary = (e) => e._tag === "binary";
|
|
13
|
+
const isSparse = (e) => e._tag === "sparse";
|
|
14
|
+
const isMultivector = (e) => e._tag === "multivector";
|
|
15
|
+
//#endregion
|
|
16
|
+
export { isBinary, isFloat32, isInt8, isMultivector, isSparse, Embedding_exports as t };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=Embedding.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embedding.mjs","names":[],"sources":["../../src/embedding-model/Embedding.ts"],"sourcesContent":["import type { ImageSource } from \"../domain/Image.js\"\n\n/**\n * One part of a mixed text+image input. Used inside `EmbedInput.content[]`\n * for providers that accept interleaved modalities in a single embed call\n * (Cohere v4, Voyage multimodal, Jina v4, Google `gemini-embedding-2`).\n */\nexport type EmbedContentPart = { readonly text: string } | { readonly image: ImageSource }\n\n/**\n * What you embed. The `string` shorthand covers the common text-only case;\n * structured variants exist for image-only and mixed-modality inputs.\n *\n * Not every provider accepts every variant: text-only providers (OpenAI,\n * Mixedbread today) handle `string` and `{ text }`; multimodal providers\n * (Google, Jina v4, Voyage multimodal, Cohere v4) handle all four. A\n * provider layer rejects shapes it can't encode as `AiError.InvalidRequest`.\n */\nexport type EmbedInput =\n | string\n | { readonly text: string }\n | { readonly image: ImageSource }\n | { readonly content: ReadonlyArray<EmbedContentPart> }\n\n// ---------------------------------------------------------------------------\n// Embedding representations\n//\n// The `_tag` reflects the wire form the provider returned, *not* what the\n// consumer asked for - request `encoding: \"int8\"` and you get back an\n// `Int8Embedding`. Math primitives are typed against the named interfaces\n// (see `Vector.ts`) so e.g. `sparseCosine` only accepts `SparseEmbedding`.\n// ---------------------------------------------------------------------------\n\n/** Dense float32 vector. The default representation across all providers. */\nexport type Float32Embedding = {\n readonly _tag: \"float32\"\n readonly vector: Float32Array\n}\n\n/**\n * Dense int8-quantized vector. ~4x smaller than float32 with minimal\n * recall loss on most benchmarks.\n */\nexport type Int8Embedding = {\n readonly _tag: \"int8\"\n readonly vector: Int8Array\n}\n\n/**\n * Dense binary-quantized vector. One bit per dimension, packed into bytes.\n * ~32x smaller than float32; meaningful recall loss but useful for hot\n * indexes paired with a float32 reranker pass.\n */\nexport type BinaryEmbedding = {\n readonly _tag: \"binary\"\n readonly vector: Uint8Array\n}\n\n/**\n * Sparse vector. Token-keyed weights for hybrid search (dense + lexical-\n * style sparse). The single hosted producer today is Jina's `elser-v2`\n * model, which returns subword tokens (e.g. `\"bread\"`, `\"##ing\"`) with\n * their relevance weights.\n *\n * The shape is `Record<string, number>` rather than `(indices, values)`\n * because real hosted learned-sparse encoders (ELSER, SPLADE) emit token\n * strings with no shared vocabulary index. Converting to integer indices\n * would either need a vocabulary table the model doesn't expose, or\n * lose the cross-vector matching semantics. If a provider ever exposes\n * index-valued sparse vectors (Pinecone-style, where you bring your own\n * vocab), add an `IndexSparseEmbedding` sibling arm with `_tag:\n * \"sparse-indexed\"`.\n *\n * Score with `Vector.sparseCosine` — dot product over the intersection\n * of keys, normalized by the L2 norms of both maps.\n */\nexport type SparseEmbedding = {\n readonly _tag: \"sparse\"\n readonly weights: Readonly<Record<string, number>>\n}\n\n/**\n * Multivector / late-interaction output: one float32 vector per token.\n * Score documents with `Vector.maxSim` (ColBERT-style: per query vector,\n * max dot product across doc vectors, summed). Typically ~50-500 vectors\n * per document, each shorter than a single-vector embedding (~128 dim\n * vs ~1024).\n *\n * Quantized multivector forms aren't modeled for the same reason as\n * sparse - nothing on hosted APIs ships them yet.\n */\nexport type MultivectorEmbedding = {\n readonly _tag: \"multivector\"\n readonly vectors: ReadonlyArray<Float32Array>\n}\n\nexport type Embedding =\n | Float32Embedding\n | Int8Embedding\n | BinaryEmbedding\n | SparseEmbedding\n | MultivectorEmbedding\n\nexport const isFloat32 = (e: Embedding): e is Float32Embedding => e._tag === \"float32\"\nexport const isInt8 = (e: Embedding): e is Int8Embedding => e._tag === \"int8\"\nexport const isBinary = (e: Embedding): e is BinaryEmbedding => e._tag === \"binary\"\nexport const isSparse = (e: Embedding): e is SparseEmbedding => e._tag === \"sparse\"\nexport const isMultivector = (e: Embedding): e is MultivectorEmbedding => e._tag === \"multivector\"\n\n/**\n * Token usage for one embed / embedMany call. One value per HTTP request,\n * not per input vector. Most providers populate `inputTokens`; the field\n * is optional for those that don't (or for mock layers in tests).\n */\nexport type Usage = {\n readonly inputTokens?: number\n}\n"],"mappings":";;;;;;;;;AAuGA,MAAa,aAAa,MAAwC,EAAE,SAAS;AAC7E,MAAa,UAAU,MAAqC,EAAE,SAAS;AACvE,MAAa,YAAY,MAAuC,EAAE,SAAS;AAC3E,MAAa,YAAY,MAAuC,EAAE,SAAS;AAC3E,MAAa,iBAAiB,MAA4C,EAAE,SAAS"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { t as AiError } from "../AiError-csR8Bhxx.mjs";
|
|
2
|
+
import { EmbedInput, Embedding, Usage } from "./Embedding.mjs";
|
|
3
|
+
import { Context, Effect } from "effect";
|
|
4
|
+
|
|
5
|
+
//#region src/embedding-model/EmbeddingModel.d.ts
|
|
6
|
+
declare namespace EmbeddingModel_d_exports {
|
|
7
|
+
export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, Encoding, embed, embedMany };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Output representation requested from the provider.
|
|
11
|
+
*
|
|
12
|
+
* Dense quantizations - same vector at different storage cost:
|
|
13
|
+
* - `float32` — universal default.
|
|
14
|
+
* - `int8` — ~4x smaller; minimal recall loss on most benchmarks.
|
|
15
|
+
* - `binary` — ~32x smaller; meaningful recall loss but pairs well with
|
|
16
|
+
* a float32 reranker pass over a small candidate set.
|
|
17
|
+
*
|
|
18
|
+
* Non-dense representations:
|
|
19
|
+
* - `sparse` — learned sparse vector for hybrid (dense + lexical) search.
|
|
20
|
+
* Currently Jina ELSER only on hosted APIs.
|
|
21
|
+
* - `multivector` — one vector per token for late-interaction (ColBERT-
|
|
22
|
+
* style) scoring via `Vector.maxSim`. Currently Jina v4 only.
|
|
23
|
+
*
|
|
24
|
+
* Each provider's typed request narrows this to its supported set at
|
|
25
|
+
* compile time (e.g. `JinaEncoding = "float32" | "binary" | "sparse" |
|
|
26
|
+
* "multivector"`). On the generic `EmbeddingModel` path, callers can
|
|
27
|
+
* pass any `Encoding` and the provider's API will reject mismatches at
|
|
28
|
+
* runtime.
|
|
29
|
+
*/
|
|
30
|
+
type Encoding = "float32" | "int8" | "binary" | "sparse" | "multivector";
|
|
31
|
+
/**
|
|
32
|
+
* Cross-provider single-embed request. Mirrors the shape of
|
|
33
|
+
* `LanguageModel.CommonRequest`: cross-cutting fields here, vendor
|
|
34
|
+
* specifics in the provider's typed request.
|
|
35
|
+
*
|
|
36
|
+
* Provider-specific extensions (Cohere widened `task` enum, Jina LoRA
|
|
37
|
+
* tasks, Mixedbread free-form `prompt`, etc.) live in that provider's own
|
|
38
|
+
* request interface, which extends this and narrows `model` / widens
|
|
39
|
+
* `task`.
|
|
40
|
+
*/
|
|
41
|
+
type CommonEmbedRequest = {
|
|
42
|
+
readonly input: EmbedInput;
|
|
43
|
+
/**
|
|
44
|
+
* Model identifier. Each provider narrows this to its typed literal
|
|
45
|
+
* union, so code that yields a typed provider tag gets autocompletion.
|
|
46
|
+
*/
|
|
47
|
+
readonly model: string;
|
|
48
|
+
/**
|
|
49
|
+
* Retrieval-task hint. Applies to the input. OpenAI ignores this;
|
|
50
|
+
* Mixedbread doesn't have it; Cohere v3+ requires it on the wire (typed
|
|
51
|
+
* as required in `CohereEmbedRequest`). Provider-specific task enums
|
|
52
|
+
* (classification, clustering, code retrieval, …) live on the
|
|
53
|
+
* provider's own request type.
|
|
54
|
+
*/
|
|
55
|
+
readonly task?: "query" | "document";
|
|
56
|
+
/**
|
|
57
|
+
* Matryoshka truncation. Default: provider's native dimension.
|
|
58
|
+
* Discrete-value providers (Cohere, Vertex `multimodalembedding@001`)
|
|
59
|
+
* narrow this to a literal union in their typed request.
|
|
60
|
+
*/
|
|
61
|
+
readonly dimensions?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Output representation - see {@link Encoding}. Dense float32 is the
|
|
64
|
+
* default; provider layers reject unsupported values up front with
|
|
65
|
+
* `InvalidRequest`.
|
|
66
|
+
*/
|
|
67
|
+
readonly encoding?: Encoding;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Cross-provider batch-embed request. One `task` for the whole batch -
|
|
71
|
+
* mixed-task batches aren't a real provider feature (rerankers exist for
|
|
72
|
+
* that).
|
|
73
|
+
*/
|
|
74
|
+
type CommonEmbedManyRequest = Omit<CommonEmbedRequest, "input"> & {
|
|
75
|
+
readonly inputs: ReadonlyArray<EmbedInput>;
|
|
76
|
+
};
|
|
77
|
+
type EmbedResponse = {
|
|
78
|
+
readonly embedding: Embedding;
|
|
79
|
+
readonly usage: Usage;
|
|
80
|
+
};
|
|
81
|
+
type EmbedManyResponse = {
|
|
82
|
+
readonly embeddings: ReadonlyArray<Embedding>;
|
|
83
|
+
readonly usage: Usage;
|
|
84
|
+
};
|
|
85
|
+
type EmbeddingModelService = {
|
|
86
|
+
readonly embed: (request: CommonEmbedRequest) => Effect.Effect<EmbedResponse, AiError>;
|
|
87
|
+
readonly embedMany: (request: CommonEmbedManyRequest) => Effect.Effect<EmbedManyResponse, AiError>;
|
|
88
|
+
};
|
|
89
|
+
declare const EmbeddingModel_base: Context.ServiceClass<EmbeddingModel, "@betalyra/effect-uai/EmbeddingModel", EmbeddingModelService>;
|
|
90
|
+
declare class EmbeddingModel extends EmbeddingModel_base {}
|
|
91
|
+
/** Embed a single input. */
|
|
92
|
+
declare const embed: (request: CommonEmbedRequest) => Effect.Effect<EmbedResponse, AiError, EmbeddingModel>;
|
|
93
|
+
/** Embed a batch in one provider call. Same `task` for every input. */
|
|
94
|
+
declare const embedMany: (request: CommonEmbedManyRequest) => Effect.Effect<EmbedManyResponse, AiError, EmbeddingModel>;
|
|
95
|
+
//#endregion
|
|
96
|
+
export { CommonEmbedManyRequest, CommonEmbedRequest, EmbedManyResponse, EmbedResponse, EmbeddingModel, EmbeddingModelService, Encoding, embed, embedMany, EmbeddingModel_d_exports as t };
|
|
97
|
+
//# sourceMappingURL=EmbeddingModel.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingModel.d.mts","names":[],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyBA;;;;;AAYA;;KAZY,QAAA;;;;;;;;;;;KAYA,kBAAA;EAAA,SACD,KAAA,EAAO,UAAA;;;;;WAKP,KAAA;EA6BqB;;;;;;;EAAA,SArBrB,IAAA;EAqBgC;AAG3C;;;;EAH2C,SAfhC,UAAA;EAmBW;;;;;EAAA,SAbX,QAAA,GAAW,QAAA;AAAA;;;;;;KAQV,sBAAA,GAAyB,IAAA,CAAK,kBAAA;EAAA,SAC/B,MAAA,EAAQ,aAAA,CAAc,UAAA;AAAA;AAAA,KAGrB,aAAA;EAAA,SACD,SAAA,EAAW,SAAA;EAAA,SACX,KAAA,EAAO,KAAA;AAAA;AAAA,KAGN,iBAAA;EAAA,SACD,UAAA,EAAY,aAAA,CAAc,SAAA;EAAA,SAC1B,KAAA,EAAO,KAAA;AAAA;AAAA,KAGN,qBAAA;EAAA,SACD,KAAA,GAAQ,OAAA,EAAS,kBAAA,KAAuB,MAAA,CAAO,MAAA,CAAO,aAAA,EAAe,OAAA;EAAA,SACrE,SAAA,GACP,OAAA,EAAS,sBAAA,KACN,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB,OAAA;AAAA;AAAA,cACvC,mBAAA;cAEY,cAAA,SAAuB,mBAAA;;cAKvB,KAAA,GACX,OAAA,EAAS,kBAAA,KACR,MAAA,CAAO,MAAA,CAAO,aAAA,EAAe,OAAA,EAAiB,cAAA;;cAIpC,SAAA,GACX,OAAA,EAAS,sBAAA,KACR,MAAA,CAAO,MAAA,CAAO,iBAAA,EAAmB,OAAA,EAAiB,cAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
+
import { Context, Effect } from "effect";
|
|
3
|
+
//#region src/embedding-model/EmbeddingModel.ts
|
|
4
|
+
var EmbeddingModel_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
EmbeddingModel: () => EmbeddingModel,
|
|
6
|
+
embed: () => embed,
|
|
7
|
+
embedMany: () => embedMany
|
|
8
|
+
});
|
|
9
|
+
var EmbeddingModel = class extends Context.Service()("@betalyra/effect-uai/EmbeddingModel") {};
|
|
10
|
+
/** Embed a single input. */
|
|
11
|
+
const embed = (request) => Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embed(request));
|
|
12
|
+
/** Embed a batch in one provider call. Same `task` for every input. */
|
|
13
|
+
const embedMany = (request) => Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embedMany(request));
|
|
14
|
+
//#endregion
|
|
15
|
+
export { EmbeddingModel, embed, embedMany, EmbeddingModel_exports as t };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=EmbeddingModel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmbeddingModel.mjs","names":[],"sources":["../../src/embedding-model/EmbeddingModel.ts"],"sourcesContent":["import { Context, Effect } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { Embedding, EmbedInput, Usage } from \"./Embedding.js\"\n\n/**\n * Output representation requested from the provider.\n *\n * Dense quantizations - same vector at different storage cost:\n * - `float32` — universal default.\n * - `int8` — ~4x smaller; minimal recall loss on most benchmarks.\n * - `binary` — ~32x smaller; meaningful recall loss but pairs well with\n * a float32 reranker pass over a small candidate set.\n *\n * Non-dense representations:\n * - `sparse` — learned sparse vector for hybrid (dense + lexical) search.\n * Currently Jina ELSER only on hosted APIs.\n * - `multivector` — one vector per token for late-interaction (ColBERT-\n * style) scoring via `Vector.maxSim`. Currently Jina v4 only.\n *\n * Each provider's typed request narrows this to its supported set at\n * compile time (e.g. `JinaEncoding = \"float32\" | \"binary\" | \"sparse\" |\n * \"multivector\"`). On the generic `EmbeddingModel` path, callers can\n * pass any `Encoding` and the provider's API will reject mismatches at\n * runtime.\n */\nexport type Encoding = \"float32\" | \"int8\" | \"binary\" | \"sparse\" | \"multivector\"\n\n/**\n * Cross-provider single-embed request. Mirrors the shape of\n * `LanguageModel.CommonRequest`: cross-cutting fields here, vendor\n * specifics in the provider's typed request.\n *\n * Provider-specific extensions (Cohere widened `task` enum, Jina LoRA\n * tasks, Mixedbread free-form `prompt`, etc.) live in that provider's own\n * request interface, which extends this and narrows `model` / widens\n * `task`.\n */\nexport type CommonEmbedRequest = {\n readonly input: EmbedInput\n /**\n * Model identifier. Each provider narrows this to its typed literal\n * union, so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n /**\n * Retrieval-task hint. Applies to the input. OpenAI ignores this;\n * Mixedbread doesn't have it; Cohere v3+ requires it on the wire (typed\n * as required in `CohereEmbedRequest`). Provider-specific task enums\n * (classification, clustering, code retrieval, …) live on the\n * provider's own request type.\n */\n readonly task?: \"query\" | \"document\"\n /**\n * Matryoshka truncation. Default: provider's native dimension.\n * Discrete-value providers (Cohere, Vertex `multimodalembedding@001`)\n * narrow this to a literal union in their typed request.\n */\n readonly dimensions?: number\n /**\n * Output representation - see {@link Encoding}. Dense float32 is the\n * default; provider layers reject unsupported values up front with\n * `InvalidRequest`.\n */\n readonly encoding?: Encoding\n}\n\n/**\n * Cross-provider batch-embed request. One `task` for the whole batch -\n * mixed-task batches aren't a real provider feature (rerankers exist for\n * that).\n */\nexport type CommonEmbedManyRequest = Omit<CommonEmbedRequest, \"input\"> & {\n readonly inputs: ReadonlyArray<EmbedInput>\n}\n\nexport type EmbedResponse = {\n readonly embedding: Embedding\n readonly usage: Usage\n}\n\nexport type EmbedManyResponse = {\n readonly embeddings: ReadonlyArray<Embedding>\n readonly usage: Usage\n}\n\nexport type EmbeddingModelService = {\n readonly embed: (request: CommonEmbedRequest) => Effect.Effect<EmbedResponse, AiError.AiError>\n readonly embedMany: (\n request: CommonEmbedManyRequest,\n ) => Effect.Effect<EmbedManyResponse, AiError.AiError>\n}\n\nexport class EmbeddingModel extends Context.Service<EmbeddingModel, EmbeddingModelService>()(\n \"@betalyra/effect-uai/EmbeddingModel\",\n) {}\n\n/** Embed a single input. */\nexport const embed = (\n request: CommonEmbedRequest,\n): Effect.Effect<EmbedResponse, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embed(request))\n\n/** Embed a batch in one provider call. Same `task` for every input. */\nexport const embedMany = (\n request: CommonEmbedManyRequest,\n): Effect.Effect<EmbedManyResponse, AiError.AiError, EmbeddingModel> =>\n Effect.flatMap(EmbeddingModel.asEffect(), (m) => m.embedMany(request))\n"],"mappings":";;;;;;;;AA4FA,IAAa,iBAAb,cAAoC,QAAQ,SAAgD,CAC1F,sCACD,CAAC;;AAGF,MAAa,SACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,MAAM,QAAQ,CAAC;;AAGpE,MAAa,aACX,YAEA,OAAO,QAAQ,eAAe,UAAU,GAAG,MAAM,EAAE,UAAU,QAAQ,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
|
-
import { n as AiError_d_exports } from "./AiError-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { n as AiError_d_exports } from "./AiError-csR8Bhxx.mjs";
|
|
2
|
+
import { a as Media_d_exports } from "./Media-D_CpcM1Z.mjs";
|
|
3
|
+
import { o as Audio_d_exports } from "./Audio-BfCTGnH3.mjs";
|
|
4
|
+
import { o as Image_d_exports } from "./Image-DxyXqzAM.mjs";
|
|
5
|
+
import { f as Items_d_exports } from "./Items-Hg5AsYxl.mjs";
|
|
6
|
+
import { t as Music_d_exports } from "./domain/Music.mjs";
|
|
7
|
+
import { t as Transcript_d_exports } from "./domain/Transcript.mjs";
|
|
8
|
+
import { a as StructuredFormat_d_exports } from "./StructuredFormat-Cl41C56K.mjs";
|
|
9
|
+
import { a as Turn_d_exports } from "./Turn-7geUcKsf.mjs";
|
|
10
|
+
import { t as Embedding_d_exports } from "./embedding-model/Embedding.mjs";
|
|
11
|
+
import { t as EmbeddingModel_d_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
12
|
+
import { l as Tool_d_exports } from "./Tool-B8B5qVEy.mjs";
|
|
6
13
|
import { t as LanguageModel_d_exports } from "./language-model/LanguageModel.mjs";
|
|
14
|
+
import { t as MusicGenerator_d_exports } from "./music-generator/MusicGenerator.mjs";
|
|
15
|
+
import { t as SpeechSynthesizer_d_exports } from "./speech-synthesizer/SpeechSynthesizer.mjs";
|
|
16
|
+
import { t as Transcriber_d_exports } from "./transcriber/Transcriber.mjs";
|
|
17
|
+
import { t as Vector_d_exports } from "./math/Vector.mjs";
|
|
7
18
|
import { t as Loop_d_exports } from "./loop/Loop.mjs";
|
|
8
|
-
import { t as
|
|
19
|
+
import { t as Outcome_d_exports } from "./tool/Outcome.mjs";
|
|
20
|
+
import { t as ToolEvent_d_exports } from "./tool/ToolEvent.mjs";
|
|
9
21
|
import { t as Toolkit_d_exports } from "./tool/Toolkit.mjs";
|
|
22
|
+
import { t as Resolvers_d_exports } from "./tool/Resolvers.mjs";
|
|
23
|
+
import { t as HistoryCheck_d_exports } from "./tool/HistoryCheck.mjs";
|
|
10
24
|
import { t as JSONL_d_exports } from "./streaming/JSONL.mjs";
|
|
11
25
|
import { t as Lines_d_exports } from "./streaming/Lines.mjs";
|
|
12
26
|
import { t as SSE_d_exports } from "./streaming/SSE.mjs";
|
|
13
27
|
import { t as Metrics_d_exports } from "./observability/Metrics.mjs";
|
|
14
|
-
export { AiError_d_exports as AiError, Items_d_exports as Items, JSONL_d_exports as JSONL, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop,
|
|
28
|
+
export { AiError_d_exports as AiError, Audio_d_exports as Audio, Embedding_d_exports as Embedding, EmbeddingModel_d_exports as EmbeddingModel, HistoryCheck_d_exports as HistoryCheck, Image_d_exports as Image, Items_d_exports as Items, JSONL_d_exports as JSONL, LanguageModel_d_exports as LanguageModel, Lines_d_exports as Lines, Loop_d_exports as Loop, Media_d_exports as Media, Metrics_d_exports as Metrics, Music_d_exports as Music, MusicGenerator_d_exports as MusicGenerator, Outcome_d_exports as Outcome, Resolvers_d_exports as Resolvers, SSE_d_exports as SSE, SpeechSynthesizer_d_exports as SpeechSynthesizer, StructuredFormat_d_exports as StructuredFormat, Tool_d_exports as Tool, ToolEvent_d_exports as ToolEvent, Toolkit_d_exports as Toolkit, Transcriber_d_exports as Transcriber, Transcript_d_exports as Transcript, Turn_d_exports as Turn, Vector_d_exports as Vector };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
import { t as AiError_exports } from "./domain/AiError.mjs";
|
|
2
|
+
import { t as Audio_exports } from "./domain/Audio.mjs";
|
|
3
|
+
import { t as Image_exports } from "./domain/Image.mjs";
|
|
2
4
|
import { t as Items_exports } from "./domain/Items.mjs";
|
|
5
|
+
import { t as Media_exports } from "./domain/Media.mjs";
|
|
6
|
+
import { t as Music_exports } from "./domain/Music.mjs";
|
|
7
|
+
import { t as Transcript_exports } from "./domain/Transcript.mjs";
|
|
3
8
|
import { t as StructuredFormat_exports } from "./structured-format/StructuredFormat.mjs";
|
|
4
9
|
import { t as Turn_exports } from "./domain/Turn.mjs";
|
|
10
|
+
import { t as Embedding_exports } from "./embedding-model/Embedding.mjs";
|
|
11
|
+
import { t as EmbeddingModel_exports } from "./embedding-model/EmbeddingModel.mjs";
|
|
5
12
|
import { t as LanguageModel_exports } from "./language-model/LanguageModel.mjs";
|
|
13
|
+
import { t as MusicGenerator_exports } from "./music-generator/MusicGenerator.mjs";
|
|
14
|
+
import { t as SpeechSynthesizer_exports } from "./speech-synthesizer/SpeechSynthesizer.mjs";
|
|
15
|
+
import { t as Transcriber_exports } from "./transcriber/Transcriber.mjs";
|
|
16
|
+
import { t as Vector_exports } from "./math/Vector.mjs";
|
|
6
17
|
import { t as Loop_exports } from "./loop/Loop.mjs";
|
|
7
|
-
import { t as Match_exports } from "./match/Match.mjs";
|
|
8
18
|
import { t as Tool_exports } from "./tool/Tool.mjs";
|
|
19
|
+
import { t as Outcome_exports } from "./tool/Outcome.mjs";
|
|
20
|
+
import { t as ToolEvent_exports } from "./tool/ToolEvent.mjs";
|
|
9
21
|
import { t as Toolkit_exports } from "./tool/Toolkit.mjs";
|
|
22
|
+
import { t as Resolvers_exports } from "./tool/Resolvers.mjs";
|
|
23
|
+
import { t as HistoryCheck_exports } from "./tool/HistoryCheck.mjs";
|
|
10
24
|
import { t as JSONL_exports } from "./streaming/JSONL.mjs";
|
|
11
25
|
import { t as Lines_exports } from "./streaming/Lines.mjs";
|
|
12
26
|
import { t as SSE_exports } from "./streaming/SSE.mjs";
|
|
13
27
|
import { t as Metrics_exports } from "./observability/Metrics.mjs";
|
|
14
|
-
export { AiError_exports as AiError, Items_exports as Items, JSONL_exports as JSONL, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop,
|
|
28
|
+
export { AiError_exports as AiError, Audio_exports as Audio, Embedding_exports as Embedding, EmbeddingModel_exports as EmbeddingModel, HistoryCheck_exports as HistoryCheck, Image_exports as Image, Items_exports as Items, JSONL_exports as JSONL, LanguageModel_exports as LanguageModel, Lines_exports as Lines, Loop_exports as Loop, Media_exports as Media, Metrics_exports as Metrics, Music_exports as Music, MusicGenerator_exports as MusicGenerator, Outcome_exports as Outcome, Resolvers_exports as Resolvers, SSE_exports as SSE, SpeechSynthesizer_exports as SpeechSynthesizer, StructuredFormat_exports as StructuredFormat, Tool_exports as Tool, ToolEvent_exports as ToolEvent, Toolkit_exports as Toolkit, Transcriber_exports as Transcriber, Transcript_exports as Transcript, Turn_exports as Turn, Vector_exports as Vector };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { t as AiError } from "../AiError-
|
|
2
|
-
import {
|
|
3
|
-
import { i as StructuredFormat } from "../StructuredFormat-
|
|
4
|
-
import { i as TurnEvent
|
|
5
|
-
import { o as ToolDescriptor } from "../Tool-
|
|
6
|
-
import { Context,
|
|
1
|
+
import { t as AiError } from "../AiError-csR8Bhxx.mjs";
|
|
2
|
+
import { d as Item } from "../Items-Hg5AsYxl.mjs";
|
|
3
|
+
import { i as StructuredFormat } from "../StructuredFormat-Cl41C56K.mjs";
|
|
4
|
+
import { i as TurnEvent } from "../Turn-7geUcKsf.mjs";
|
|
5
|
+
import { o as ToolDescriptor } from "../Tool-B8B5qVEy.mjs";
|
|
6
|
+
import { Context, Stream } from "effect";
|
|
7
7
|
|
|
8
8
|
//#region src/language-model/LanguageModel.d.ts
|
|
9
9
|
declare namespace LanguageModel_d_exports {
|
|
10
|
-
export { CommonRequest, LanguageModel, LanguageModelService, streamTurn
|
|
10
|
+
export { CommonRequest, LanguageModel, LanguageModelService, streamTurn };
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Cross-provider request shape. Every call carries its own `history` and
|
|
@@ -15,7 +15,7 @@ declare namespace LanguageModel_d_exports {
|
|
|
15
15
|
* to a single provider (reasoning effort, prompt caching, store flags,
|
|
16
16
|
* ...) lives in that provider's own request interface, which extends this.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
type CommonRequest = {
|
|
19
19
|
readonly history: ReadonlyArray<Item>;
|
|
20
20
|
/**
|
|
21
21
|
* Model identifier. Each provider narrows this to its typed literal union,
|
|
@@ -37,24 +37,16 @@ interface CommonRequest {
|
|
|
37
37
|
* `output_config`, Gemini `responseJsonSchema`).
|
|
38
38
|
*/
|
|
39
39
|
readonly structured?: StructuredFormat<unknown>;
|
|
40
|
-
}
|
|
41
|
-
|
|
40
|
+
};
|
|
41
|
+
type LanguageModelService = {
|
|
42
42
|
readonly streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError>;
|
|
43
|
-
}
|
|
43
|
+
};
|
|
44
44
|
declare const LanguageModel_base: Context.ServiceClass<LanguageModel, "@betalyra/effect-uai/LanguageModel", LanguageModelService>;
|
|
45
45
|
declare class LanguageModel extends LanguageModel_base {}
|
|
46
46
|
/**
|
|
47
47
|
* Stream the deltas of a single turn.
|
|
48
48
|
*/
|
|
49
49
|
declare const streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError, LanguageModel>;
|
|
50
|
-
/**
|
|
51
|
-
* Run a single turn to completion and return the assembled `Turn`.
|
|
52
|
-
*
|
|
53
|
-
* Implementation: drain the delta stream and pluck the terminal
|
|
54
|
-
* `turn_complete` event. The provider is contractually required to emit
|
|
55
|
-
* exactly one such event as the last delta.
|
|
56
|
-
*/
|
|
57
|
-
declare const turn: (request: CommonRequest) => Effect.Effect<Turn, AiError, LanguageModel>;
|
|
58
50
|
//#endregion
|
|
59
|
-
export { CommonRequest, LanguageModel, LanguageModelService, streamTurn, LanguageModel_d_exports as t
|
|
51
|
+
export { CommonRequest, LanguageModel, LanguageModelService, streamTurn, LanguageModel_d_exports as t };
|
|
60
52
|
//# sourceMappingURL=LanguageModel.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"LanguageModel.d.mts","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"mappings":";;;;;;;;;;;;;;;;;KAaY,aAAA;EAAA,SACD,OAAA,EAAS,aAAA,CAAc,IAAA;;AADlC;;;WAMW,KAAA;EAAA,SACA,KAAA,GAAQ,aAAA,CAAc,cAAA;EAAA,SACtB,UAAA;IAAA,SAIM,IAAA;IAAA,SAA2B,IAAA;EAAA;EAAA,SACjC,WAAA;EAAA,SACA,IAAA;EAAA,SACA,eAAA;EAduB;;;;;;EAAA,SAqBvB,UAAA,GAAa,gBAAA;AAAA;AAAA,KAGZ,oBAAA;EAAA,SACD,UAAA,GAAa,OAAA,EAAS,aAAA,KAAkB,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA;AAAA;AAAA,cAC3E,kBAAA;cAEY,aAAA,SAAsB,kBAAA;;;AAJnC;cAWa,UAAA,GACX,OAAA,EAAS,aAAA,KACR,MAAA,CAAO,MAAA,CAAO,SAAA,EAAW,OAAA,EAAiB,aAAA"}
|
|
@@ -1,33 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Unavailable } from "../domain/AiError.mjs";
|
|
3
|
-
import { isTurnComplete } from "../domain/Turn.mjs";
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
4
2
|
import { Context, Effect, Stream } from "effect";
|
|
5
3
|
//#region src/language-model/LanguageModel.ts
|
|
6
4
|
var LanguageModel_exports = /* @__PURE__ */ __exportAll({
|
|
7
5
|
LanguageModel: () => LanguageModel,
|
|
8
|
-
streamTurn: () => streamTurn
|
|
9
|
-
turn: () => turn
|
|
6
|
+
streamTurn: () => streamTurn
|
|
10
7
|
});
|
|
11
8
|
var LanguageModel = class extends Context.Service()("@betalyra/effect-uai/LanguageModel") {};
|
|
12
9
|
/**
|
|
13
10
|
* Stream the deltas of a single turn.
|
|
14
11
|
*/
|
|
15
12
|
const streamTurn = (request) => Stream.unwrap(Effect.map(LanguageModel.asEffect(), (m) => m.streamTurn(request)));
|
|
16
|
-
/**
|
|
17
|
-
* Run a single turn to completion and return the assembled `Turn`.
|
|
18
|
-
*
|
|
19
|
-
* Implementation: drain the delta stream and pluck the terminal
|
|
20
|
-
* `turn_complete` event. The provider is contractually required to emit
|
|
21
|
-
* exactly one such event as the last delta.
|
|
22
|
-
*/
|
|
23
|
-
const turn = (request) => Effect.flatMap(Stream.runCollect(streamTurn(request)), (deltas) => {
|
|
24
|
-
const last = deltas[deltas.length - 1];
|
|
25
|
-
return last !== void 0 && isTurnComplete(last) ? Effect.succeed(last.turn) : Effect.fail(new Unavailable({
|
|
26
|
-
provider: "unknown",
|
|
27
|
-
raw: "Provider stream ended without a turn_complete event"
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
13
|
//#endregion
|
|
31
|
-
export { LanguageModel, streamTurn, LanguageModel_exports as t
|
|
14
|
+
export { LanguageModel, streamTurn, LanguageModel_exports as t };
|
|
32
15
|
|
|
33
16
|
//# sourceMappingURL=LanguageModel.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageModel.mjs","names":[
|
|
1
|
+
{"version":3,"file":"LanguageModel.mjs","names":[],"sources":["../../src/language-model/LanguageModel.ts"],"sourcesContent":["import { Context, Effect, Stream } from \"effect\"\nimport * as AiError from \"../domain/AiError.js\"\nimport type { Item } from \"../domain/Items.js\"\nimport type * as StructuredFormat from \"../structured-format/StructuredFormat.js\"\nimport type { ToolDescriptor } from \"../tool/Tool.js\"\nimport { isTurnComplete, type Turn, type TurnEvent } from \"../domain/Turn.js\"\n\n/**\n * Cross-provider request shape. Every call carries its own `history` and\n * `model` - models are not bound at layer construction. Anything specific\n * to a single provider (reasoning effort, prompt caching, store flags,\n * ...) lives in that provider's own request interface, which extends this.\n */\nexport type CommonRequest = {\n readonly history: ReadonlyArray<Item>\n /**\n * Model identifier. Each provider narrows this to its typed literal union,\n * so code that yields a typed provider tag gets autocompletion.\n */\n readonly model: string\n readonly tools?: ReadonlyArray<ToolDescriptor>\n readonly toolChoice?:\n | \"auto\"\n | \"required\"\n | \"none\"\n | { readonly type: \"function\"; readonly name: string }\n readonly temperature?: number\n readonly topP?: number\n readonly maxOutputTokens?: number\n /**\n * Schema-bound JSON output. The provider constrains the wire to match the\n * schema; pair with `Turn.toStructured` for runtime validation. Supported\n * across all current providers (OpenAI Responses json_schema, Anthropic\n * `output_config`, Gemini `responseJsonSchema`).\n */\n readonly structured?: StructuredFormat.StructuredFormat<unknown>\n}\n\nexport type LanguageModelService = {\n readonly streamTurn: (request: CommonRequest) => Stream.Stream<TurnEvent, AiError.AiError>\n}\n\nexport class LanguageModel extends Context.Service<LanguageModel, LanguageModelService>()(\n \"@betalyra/effect-uai/LanguageModel\",\n) {}\n\n/**\n * Stream the deltas of a single turn.\n */\nexport const streamTurn = (\n request: CommonRequest,\n): Stream.Stream<TurnEvent, AiError.AiError, LanguageModel> =>\n Stream.unwrap(Effect.map(LanguageModel.asEffect(), (m) => m.streamTurn(request)))\n"],"mappings":";;;;;;;AA0CA,IAAa,gBAAb,cAAmC,QAAQ,SAA8C,CACvF,qCACD,CAAC;;;;AAKF,MAAa,cACX,YAEA,OAAO,OAAO,OAAO,IAAI,cAAc,UAAU,GAAG,MAAM,EAAE,WAAW,QAAQ,CAAC,CAAC"}
|