modelfusion 0.20.0 → 0.21.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 +6 -8
- package/composed-function/summarize/SummarizationFunction.d.ts +3 -3
- package/model-function/Model.d.ts +5 -2
- package/model-function/ModelCallEvent.d.ts +3 -3
- package/model-function/ModelFunctionOptions.d.ts +4 -0
- package/model-function/SuccessfulModelCall.cjs +3 -15
- package/model-function/SuccessfulModelCall.d.ts +2 -2
- package/model-function/SuccessfulModelCall.js +3 -15
- package/model-function/embed-text/TextEmbeddingEvent.d.ts +6 -8
- package/model-function/embed-text/TextEmbeddingModel.d.ts +2 -2
- package/model-function/embed-text/embedText.cjs +16 -22
- package/model-function/embed-text/embedText.d.ts +3 -3
- package/model-function/embed-text/embedText.js +16 -22
- package/model-function/executeCall.cjs +30 -8
- package/model-function/executeCall.d.ts +16 -9
- package/model-function/executeCall.js +30 -8
- package/model-function/generate-image/ImageGenerationEvent.d.ts +6 -8
- package/model-function/generate-image/ImageGenerationModel.d.ts +2 -2
- package/model-function/generate-image/generateImage.cjs +8 -11
- package/model-function/generate-image/generateImage.d.ts +2 -2
- package/model-function/generate-image/generateImage.js +8 -11
- package/model-function/generate-json/GenerateJsonModel.d.ts +2 -2
- package/model-function/generate-json/GenerateJsonOrTextModel.d.ts +2 -2
- package/model-function/generate-json/JsonGenerationEvent.d.ts +6 -8
- package/model-function/generate-json/JsonTextGenerationModel.d.ts +2 -2
- package/model-function/generate-json/generateJson.cjs +8 -11
- package/model-function/generate-json/generateJson.d.ts +2 -2
- package/model-function/generate-json/generateJson.js +8 -11
- package/model-function/generate-json/generateJsonOrText.cjs +8 -11
- package/model-function/generate-json/generateJsonOrText.d.ts +2 -2
- package/model-function/generate-json/generateJsonOrText.js +8 -11
- package/model-function/generate-text/TextGenerationEvent.d.ts +6 -8
- package/model-function/generate-text/TextGenerationModel.d.ts +3 -3
- package/model-function/generate-text/TextStreamingEvent.d.ts +6 -8
- package/model-function/generate-text/generateText.cjs +8 -11
- package/model-function/generate-text/generateText.d.ts +2 -2
- package/model-function/generate-text/generateText.js +8 -11
- package/model-function/generate-text/streamText.cjs +38 -23
- package/model-function/generate-text/streamText.d.ts +5 -5
- package/model-function/generate-text/streamText.js +38 -23
- package/model-function/index.cjs +1 -1
- package/model-function/index.d.ts +1 -1
- package/model-function/index.js +1 -1
- package/model-function/synthesize-speech/SpeechSynthesisEvent.d.ts +6 -8
- package/model-function/synthesize-speech/SpeechSynthesisModel.d.ts +2 -2
- package/model-function/synthesize-speech/synthesizeSpeech.cjs +8 -10
- package/model-function/synthesize-speech/synthesizeSpeech.d.ts +2 -2
- package/model-function/synthesize-speech/synthesizeSpeech.js +8 -10
- package/model-function/transcribe-speech/TranscriptionEvent.d.ts +6 -8
- package/model-function/transcribe-speech/TranscriptionModel.d.ts +2 -2
- package/model-function/transcribe-speech/transcribe.cjs +8 -11
- package/model-function/transcribe-speech/transcribe.d.ts +2 -2
- package/model-function/transcribe-speech/transcribe.js +8 -11
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +3 -3
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +3 -3
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +4 -4
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.d.ts +2 -2
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.d.ts +3 -3
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +3 -3
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +3 -3
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +4 -4
- package/model-provider/openai/OpenAIImageGenerationModel.d.ts +3 -3
- package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +3 -3
- package/model-provider/openai/OpenAITextGenerationModel.d.ts +4 -4
- package/model-provider/openai/OpenAITranscriptionModel.d.ts +3 -3
- package/model-provider/openai/chat/OpenAIChatModel.d.ts +5 -5
- package/model-provider/stability/StabilityImageGenerationModel.d.ts +3 -3
- package/package.json +1 -1
- package/prompt/PromptFormatTextGenerationModel.d.ts +3 -3
- package/run/ConsoleLogger.cjs +1 -4
- package/run/ConsoleLogger.d.ts +4 -5
- package/run/ConsoleLogger.js +1 -4
- package/run/DefaultRun.cjs +1 -4
- package/run/DefaultRun.d.ts +5 -5
- package/run/DefaultRun.js +1 -4
- package/run/FunctionEvent.d.ts +51 -0
- package/run/{RunFunctionEventSource.js → FunctionEventSource.cjs} +7 -13
- package/run/FunctionEventSource.d.ts +12 -0
- package/run/{RunFunctionEventSource.cjs → FunctionEventSource.js} +3 -17
- package/run/FunctionObserver.d.ts +7 -0
- package/run/FunctionOptions.d.ts +19 -0
- package/run/GlobalFunctionObservers.cjs +12 -0
- package/run/GlobalFunctionObservers.d.ts +3 -0
- package/run/GlobalFunctionObservers.js +7 -0
- package/run/Run.d.ts +2 -2
- package/run/index.cjs +5 -5
- package/run/index.d.ts +5 -5
- package/run/index.js +5 -5
- package/text-chunk/SimilarTextChunksFromVectorIndexRetriever.cjs +1 -0
- package/text-chunk/SimilarTextChunksFromVectorIndexRetriever.d.ts +2 -2
- package/text-chunk/SimilarTextChunksFromVectorIndexRetriever.js +1 -0
- package/text-chunk/retrieve-text-chunks/TextChunkRetriever.d.ts +2 -2
- package/text-chunk/retrieve-text-chunks/retrieveTextChunks.d.ts +2 -2
- package/text-chunk/split/SplitFunction.d.ts +3 -3
- package/text-chunk/upsertTextChunks.d.ts +2 -2
- package/tool/ExecuteToolEvent.d.ts +6 -8
- package/tool/Tool.d.ts +3 -3
- package/tool/WebSearchTool.d.ts +2 -1
- package/tool/executeTool.cjs +28 -26
- package/tool/executeTool.d.ts +5 -4
- package/tool/executeTool.js +28 -26
- package/tool/index.cjs +1 -0
- package/tool/index.d.ts +1 -0
- package/tool/index.js +1 -0
- package/tool/useTool.cjs +2 -6
- package/tool/useTool.d.ts +2 -2
- package/tool/useTool.js +2 -6
- package/tool/useToolOrGenerateText.cjs +1 -3
- package/tool/useToolOrGenerateText.d.ts +2 -2
- package/tool/useToolOrGenerateText.js +1 -3
- package/util/DurationMeasurement.cjs +6 -0
- package/util/DurationMeasurement.d.ts +1 -0
- package/util/DurationMeasurement.js +6 -0
- package/util/api/postToApi.cjs +8 -0
- package/util/api/postToApi.js +8 -0
- package/model-function/FunctionOptions.d.ts +0 -6
- package/run/IdMetadata.d.ts +0 -7
- package/run/RunFunction.d.ts +0 -9
- package/run/RunFunctionEvent.d.ts +0 -12
- package/run/RunFunctionEventSource.d.ts +0 -13
- package/run/RunFunctionObserver.cjs +0 -2
- package/run/RunFunctionObserver.d.ts +0 -5
- package/run/RunFunctionObserver.js +0 -1
- /package/model-function/{FunctionOptions.cjs → ModelFunctionOptions.cjs} +0 -0
- /package/model-function/{FunctionOptions.js → ModelFunctionOptions.js} +0 -0
- /package/run/{IdMetadata.cjs → FunctionEvent.cjs} +0 -0
- /package/run/{IdMetadata.js → FunctionEvent.js} +0 -0
- /package/run/{RunFunction.cjs → FunctionObserver.cjs} +0 -0
- /package/run/{RunFunction.js → FunctionObserver.js} +0 -0
- /package/run/{RunFunctionEvent.cjs → FunctionOptions.cjs} +0 -0
- /package/run/{RunFunctionEvent.js → FunctionOptions.js} +0 -0
@@ -2,7 +2,8 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.streamText = exports.StreamTextPromise = void 0;
|
4
4
|
const nanoid_1 = require("nanoid");
|
5
|
-
const
|
5
|
+
const FunctionEventSource_js_1 = require("../../run/FunctionEventSource.cjs");
|
6
|
+
const GlobalFunctionObservers_js_1 = require("../../run/GlobalFunctionObservers.cjs");
|
6
7
|
const DurationMeasurement_js_1 = require("../../util/DurationMeasurement.cjs");
|
7
8
|
const AbortError_js_1 = require("../../util/api/AbortError.cjs");
|
8
9
|
const runSafe_js_1 = require("../../util/runSafe.cjs");
|
@@ -50,13 +51,19 @@ async function doStreamText(model, prompt, options) {
|
|
50
51
|
model = model.withSettings(options.settings);
|
51
52
|
options = {
|
52
53
|
functionId: options.functionId,
|
54
|
+
observers: options.observers,
|
53
55
|
run: options.run,
|
54
56
|
};
|
55
57
|
}
|
56
58
|
const run = options?.run;
|
57
59
|
const settings = model.settings;
|
58
|
-
const eventSource = new
|
59
|
-
observers: [
|
60
|
+
const eventSource = new FunctionEventSource_js_1.FunctionEventSource({
|
61
|
+
observers: [
|
62
|
+
...(0, GlobalFunctionObservers_js_1.getGlobalFunctionObservers)(),
|
63
|
+
...(settings.observers ?? []),
|
64
|
+
...(run?.observers ?? []),
|
65
|
+
...(options?.observers ?? []),
|
66
|
+
],
|
60
67
|
errorHandler: run?.errorHandler,
|
61
68
|
});
|
62
69
|
const durationMeasurement = (0, DurationMeasurement_js_1.startDurationMeasurement)();
|
@@ -67,11 +74,13 @@ async function doStreamText(model, prompt, options) {
|
|
67
74
|
userId: run?.userId,
|
68
75
|
functionId: options?.functionId,
|
69
76
|
model: model.modelInformation,
|
70
|
-
|
77
|
+
timestamp: durationMeasurement.startDate,
|
78
|
+
startTimestamp: durationMeasurement.startDate,
|
71
79
|
};
|
72
|
-
eventSource.
|
73
|
-
|
74
|
-
|
80
|
+
eventSource.notify({
|
81
|
+
...startMetadata,
|
82
|
+
functionType: "text-streaming",
|
83
|
+
eventType: "started",
|
75
84
|
settings,
|
76
85
|
prompt,
|
77
86
|
});
|
@@ -85,12 +94,14 @@ async function doStreamText(model, prompt, options) {
|
|
85
94
|
onDone: (fullText, lastFullDelta) => {
|
86
95
|
const finishMetadata = {
|
87
96
|
...startMetadata,
|
97
|
+
eventType: "finished",
|
98
|
+
finishTimestamp: new Date(),
|
88
99
|
durationInMs: durationMeasurement.durationInMs,
|
89
100
|
};
|
90
|
-
eventSource.
|
91
|
-
|
101
|
+
eventSource.notify({
|
102
|
+
...finishMetadata,
|
103
|
+
functionType: "text-streaming",
|
92
104
|
status: "success",
|
93
|
-
metadata: finishMetadata,
|
94
105
|
settings,
|
95
106
|
prompt,
|
96
107
|
response: lastFullDelta,
|
@@ -100,20 +111,22 @@ async function doStreamText(model, prompt, options) {
|
|
100
111
|
onError: (error) => {
|
101
112
|
const finishMetadata = {
|
102
113
|
...startMetadata,
|
114
|
+
eventType: "finished",
|
115
|
+
finishTimestamp: new Date(),
|
103
116
|
durationInMs: durationMeasurement.durationInMs,
|
104
117
|
};
|
105
|
-
eventSource.
|
118
|
+
eventSource.notify(error instanceof AbortError_js_1.AbortError
|
106
119
|
? {
|
107
|
-
|
120
|
+
...finishMetadata,
|
121
|
+
functionType: "text-streaming",
|
108
122
|
status: "abort",
|
109
|
-
metadata: finishMetadata,
|
110
123
|
settings,
|
111
124
|
prompt,
|
112
125
|
}
|
113
126
|
: {
|
114
|
-
|
115
|
-
|
116
|
-
|
127
|
+
...finishMetadata,
|
128
|
+
functionType: "text-streaming",
|
129
|
+
status: "error",
|
117
130
|
settings,
|
118
131
|
prompt,
|
119
132
|
error,
|
@@ -123,22 +136,24 @@ async function doStreamText(model, prompt, options) {
|
|
123
136
|
if (!result.ok) {
|
124
137
|
const finishMetadata = {
|
125
138
|
...startMetadata,
|
139
|
+
eventType: "finished",
|
140
|
+
finishTimestamp: new Date(),
|
126
141
|
durationInMs: durationMeasurement.durationInMs,
|
127
142
|
};
|
128
143
|
if (result.isAborted) {
|
129
|
-
eventSource.
|
130
|
-
|
144
|
+
eventSource.notify({
|
145
|
+
...finishMetadata,
|
146
|
+
functionType: "text-streaming",
|
131
147
|
status: "abort",
|
132
|
-
metadata: finishMetadata,
|
133
148
|
settings,
|
134
149
|
prompt,
|
135
150
|
});
|
136
151
|
throw new AbortError_js_1.AbortError();
|
137
152
|
}
|
138
|
-
eventSource.
|
139
|
-
|
140
|
-
|
141
|
-
|
153
|
+
eventSource.notify({
|
154
|
+
...finishMetadata,
|
155
|
+
functionType: "text-streaming",
|
156
|
+
status: "error",
|
142
157
|
settings,
|
143
158
|
prompt,
|
144
159
|
error: result.error,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelFunctionOptions } from "../ModelFunctionOptions.js";
|
2
2
|
import { CallMetadata } from "../executeCall.js";
|
3
3
|
import { DeltaEvent } from "./DeltaEvent.js";
|
4
4
|
import { TextGenerationModel, TextGenerationModelSettings } from "./TextGenerationModel.js";
|
@@ -7,17 +7,17 @@ export declare class StreamTextPromise<PROMPT, FULL_DELTA, SETTINGS extends Text
|
|
7
7
|
private outputPromise;
|
8
8
|
constructor(fullPromise: Promise<{
|
9
9
|
output: AsyncIterable<string>;
|
10
|
-
metadata: Omit<CallMetadata<TextGenerationModel<PROMPT, unknown, FULL_DELTA, SETTINGS>>, "durationInMs">;
|
10
|
+
metadata: Omit<CallMetadata<TextGenerationModel<PROMPT, unknown, FULL_DELTA, SETTINGS>>, "durationInMs" | "finishTimestamp">;
|
11
11
|
}>);
|
12
12
|
asFullResponse(): Promise<{
|
13
13
|
output: AsyncIterable<string>;
|
14
|
-
metadata: Omit<CallMetadata<TextGenerationModel<PROMPT, unknown, FULL_DELTA, SETTINGS>>, "durationInMs">;
|
14
|
+
metadata: Omit<CallMetadata<TextGenerationModel<PROMPT, unknown, FULL_DELTA, SETTINGS>>, "durationInMs" | "finishTimestamp">;
|
15
15
|
}>;
|
16
16
|
then<TResult1 = AsyncIterable<string>, TResult2 = never>(onfulfilled?: ((value: AsyncIterable<string>) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
17
17
|
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined | null): Promise<AsyncIterable<string> | TResult>;
|
18
18
|
finally(onfinally?: (() => void) | undefined | null): Promise<AsyncIterable<string>>;
|
19
19
|
}
|
20
20
|
export declare function streamText<PROMPT, FULL_DELTA, SETTINGS extends TextGenerationModelSettings>(model: TextGenerationModel<PROMPT, unknown, FULL_DELTA, SETTINGS> & {
|
21
|
-
generateDeltaStreamResponse: (prompt: PROMPT, options:
|
21
|
+
generateDeltaStreamResponse: (prompt: PROMPT, options: ModelFunctionOptions<SETTINGS>) => PromiseLike<AsyncIterable<DeltaEvent<FULL_DELTA>>>;
|
22
22
|
extractTextDelta: (fullDelta: FULL_DELTA) => string | undefined;
|
23
|
-
}, prompt: PROMPT, options?:
|
23
|
+
}, prompt: PROMPT, options?: ModelFunctionOptions<SETTINGS>): StreamTextPromise<PROMPT, FULL_DELTA, SETTINGS>;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { nanoid as createId } from "nanoid";
|
2
|
-
import {
|
2
|
+
import { FunctionEventSource } from "../../run/FunctionEventSource.js";
|
3
|
+
import { getGlobalFunctionObservers } from "../../run/GlobalFunctionObservers.js";
|
3
4
|
import { startDurationMeasurement } from "../../util/DurationMeasurement.js";
|
4
5
|
import { AbortError } from "../../util/api/AbortError.js";
|
5
6
|
import { runSafe } from "../../util/runSafe.js";
|
@@ -45,13 +46,19 @@ async function doStreamText(model, prompt, options) {
|
|
45
46
|
model = model.withSettings(options.settings);
|
46
47
|
options = {
|
47
48
|
functionId: options.functionId,
|
49
|
+
observers: options.observers,
|
48
50
|
run: options.run,
|
49
51
|
};
|
50
52
|
}
|
51
53
|
const run = options?.run;
|
52
54
|
const settings = model.settings;
|
53
|
-
const eventSource = new
|
54
|
-
observers: [
|
55
|
+
const eventSource = new FunctionEventSource({
|
56
|
+
observers: [
|
57
|
+
...getGlobalFunctionObservers(),
|
58
|
+
...(settings.observers ?? []),
|
59
|
+
...(run?.observers ?? []),
|
60
|
+
...(options?.observers ?? []),
|
61
|
+
],
|
55
62
|
errorHandler: run?.errorHandler,
|
56
63
|
});
|
57
64
|
const durationMeasurement = startDurationMeasurement();
|
@@ -62,11 +69,13 @@ async function doStreamText(model, prompt, options) {
|
|
62
69
|
userId: run?.userId,
|
63
70
|
functionId: options?.functionId,
|
64
71
|
model: model.modelInformation,
|
65
|
-
|
72
|
+
timestamp: durationMeasurement.startDate,
|
73
|
+
startTimestamp: durationMeasurement.startDate,
|
66
74
|
};
|
67
|
-
eventSource.
|
68
|
-
|
69
|
-
|
75
|
+
eventSource.notify({
|
76
|
+
...startMetadata,
|
77
|
+
functionType: "text-streaming",
|
78
|
+
eventType: "started",
|
70
79
|
settings,
|
71
80
|
prompt,
|
72
81
|
});
|
@@ -80,12 +89,14 @@ async function doStreamText(model, prompt, options) {
|
|
80
89
|
onDone: (fullText, lastFullDelta) => {
|
81
90
|
const finishMetadata = {
|
82
91
|
...startMetadata,
|
92
|
+
eventType: "finished",
|
93
|
+
finishTimestamp: new Date(),
|
83
94
|
durationInMs: durationMeasurement.durationInMs,
|
84
95
|
};
|
85
|
-
eventSource.
|
86
|
-
|
96
|
+
eventSource.notify({
|
97
|
+
...finishMetadata,
|
98
|
+
functionType: "text-streaming",
|
87
99
|
status: "success",
|
88
|
-
metadata: finishMetadata,
|
89
100
|
settings,
|
90
101
|
prompt,
|
91
102
|
response: lastFullDelta,
|
@@ -95,20 +106,22 @@ async function doStreamText(model, prompt, options) {
|
|
95
106
|
onError: (error) => {
|
96
107
|
const finishMetadata = {
|
97
108
|
...startMetadata,
|
109
|
+
eventType: "finished",
|
110
|
+
finishTimestamp: new Date(),
|
98
111
|
durationInMs: durationMeasurement.durationInMs,
|
99
112
|
};
|
100
|
-
eventSource.
|
113
|
+
eventSource.notify(error instanceof AbortError
|
101
114
|
? {
|
102
|
-
|
115
|
+
...finishMetadata,
|
116
|
+
functionType: "text-streaming",
|
103
117
|
status: "abort",
|
104
|
-
metadata: finishMetadata,
|
105
118
|
settings,
|
106
119
|
prompt,
|
107
120
|
}
|
108
121
|
: {
|
109
|
-
|
110
|
-
|
111
|
-
|
122
|
+
...finishMetadata,
|
123
|
+
functionType: "text-streaming",
|
124
|
+
status: "error",
|
112
125
|
settings,
|
113
126
|
prompt,
|
114
127
|
error,
|
@@ -118,22 +131,24 @@ async function doStreamText(model, prompt, options) {
|
|
118
131
|
if (!result.ok) {
|
119
132
|
const finishMetadata = {
|
120
133
|
...startMetadata,
|
134
|
+
eventType: "finished",
|
135
|
+
finishTimestamp: new Date(),
|
121
136
|
durationInMs: durationMeasurement.durationInMs,
|
122
137
|
};
|
123
138
|
if (result.isAborted) {
|
124
|
-
eventSource.
|
125
|
-
|
139
|
+
eventSource.notify({
|
140
|
+
...finishMetadata,
|
141
|
+
functionType: "text-streaming",
|
126
142
|
status: "abort",
|
127
|
-
metadata: finishMetadata,
|
128
143
|
settings,
|
129
144
|
prompt,
|
130
145
|
});
|
131
146
|
throw new AbortError();
|
132
147
|
}
|
133
|
-
eventSource.
|
134
|
-
|
135
|
-
|
136
|
-
|
148
|
+
eventSource.notify({
|
149
|
+
...finishMetadata,
|
150
|
+
functionType: "text-streaming",
|
151
|
+
status: "error",
|
137
152
|
settings,
|
138
153
|
prompt,
|
139
154
|
error: result.error,
|
package/model-function/index.cjs
CHANGED
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./FunctionOptions.cjs"), exports);
|
18
17
|
__exportStar(require("./Model.cjs"), exports);
|
19
18
|
__exportStar(require("./ModelCallEvent.cjs"), exports);
|
19
|
+
__exportStar(require("./ModelFunctionOptions.cjs"), exports);
|
20
20
|
__exportStar(require("./ModelInformation.cjs"), exports);
|
21
21
|
__exportStar(require("./SuccessfulModelCall.cjs"), exports);
|
22
22
|
__exportStar(require("./embed-text/TextEmbeddingEvent.cjs"), exports);
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from "./FunctionOptions.js";
|
2
1
|
export * from "./Model.js";
|
3
2
|
export * from "./ModelCallEvent.js";
|
3
|
+
export * from "./ModelFunctionOptions.js";
|
4
4
|
export * from "./ModelInformation.js";
|
5
5
|
export * from "./SuccessfulModelCall.js";
|
6
6
|
export * from "./embed-text/TextEmbeddingEvent.js";
|
package/model-function/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from "./FunctionOptions.js";
|
2
1
|
export * from "./Model.js";
|
3
2
|
export * from "./ModelCallEvent.js";
|
3
|
+
export * from "./ModelFunctionOptions.js";
|
4
4
|
export * from "./ModelInformation.js";
|
5
5
|
export * from "./SuccessfulModelCall.js";
|
6
6
|
export * from "./embed-text/TextEmbeddingEvent.js";
|
@@ -1,21 +1,19 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
|
-
import {
|
3
|
-
export type SpeechSynthesisStartedEvent = {
|
4
|
-
|
5
|
-
metadata: ModelCallStartedEventMetadata;
|
2
|
+
import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
|
3
|
+
export type SpeechSynthesisStartedEvent = BaseModelCallStartedEvent & {
|
4
|
+
functionType: "speech-synthesis";
|
6
5
|
settings: unknown;
|
7
6
|
text: string;
|
8
7
|
};
|
9
|
-
export type SpeechSynthesisFinishedEvent = {
|
10
|
-
|
11
|
-
metadata: ModelCallFinishedEventMetadata;
|
8
|
+
export type SpeechSynthesisFinishedEvent = BaseModelCallFinishedEvent & {
|
9
|
+
functionType: "speech-synthesis";
|
12
10
|
settings: unknown;
|
13
11
|
text: string;
|
14
12
|
} & ({
|
15
13
|
status: "success";
|
16
14
|
response: Buffer;
|
17
15
|
} | {
|
18
|
-
status: "
|
16
|
+
status: "error";
|
19
17
|
error: unknown;
|
20
18
|
} | {
|
21
19
|
status: "abort";
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
|
-
import {
|
2
|
+
import { ModelFunctionOptions } from "../ModelFunctionOptions.js";
|
3
3
|
import { Model, ModelSettings } from "../Model.js";
|
4
4
|
export interface SpeechSynthesisModelSettings extends ModelSettings {
|
5
5
|
}
|
@@ -7,5 +7,5 @@ export interface SpeechSynthesisModel<SETTINGS> extends Model<SETTINGS> {
|
|
7
7
|
/**
|
8
8
|
* Generates an mp3 audio buffer that contains the speech for the given text.
|
9
9
|
*/
|
10
|
-
generateSpeechResponse: (text: string, options?:
|
10
|
+
generateSpeechResponse: (text: string, options?: ModelFunctionOptions<SETTINGS>) => PromiseLike<Buffer>;
|
11
11
|
}
|
@@ -12,30 +12,28 @@ function synthesizeSpeech(model, text, options) {
|
|
12
12
|
generateResponse: (options) => model.generateSpeechResponse(text, options),
|
13
13
|
extractOutputValue: (buffer) => buffer,
|
14
14
|
getStartEvent: (metadata, settings) => ({
|
15
|
-
|
16
|
-
|
15
|
+
...metadata,
|
16
|
+
functionType: "speech-synthesis",
|
17
17
|
settings,
|
18
18
|
text,
|
19
19
|
}),
|
20
20
|
getAbortEvent: (metadata, settings) => ({
|
21
|
-
|
21
|
+
...metadata,
|
22
|
+
functionType: "speech-synthesis",
|
22
23
|
status: "abort",
|
23
24
|
settings,
|
24
|
-
metadata,
|
25
25
|
text,
|
26
26
|
}),
|
27
27
|
getFailureEvent: (metadata, settings, error) => ({
|
28
|
-
|
29
|
-
|
30
|
-
metadata,
|
28
|
+
...metadata,
|
29
|
+
functionType: "speech-synthesis",
|
31
30
|
settings,
|
32
31
|
text,
|
33
32
|
error,
|
34
33
|
}),
|
35
34
|
getSuccessEvent: (metadata, settings, response, output) => ({
|
36
|
-
|
37
|
-
|
38
|
-
metadata,
|
35
|
+
...metadata,
|
36
|
+
functionType: "speech-synthesis",
|
39
37
|
settings,
|
40
38
|
text,
|
41
39
|
response,
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
2
|
-
import {
|
2
|
+
import { ModelFunctionOptions } from "../ModelFunctionOptions.js";
|
3
3
|
import { ModelFunctionPromise } from "../executeCall.js";
|
4
4
|
import { SpeechSynthesisModel, SpeechSynthesisModelSettings } from "./SpeechSynthesisModel.js";
|
5
5
|
/**
|
6
6
|
* Synthesizes speech from text.
|
7
7
|
*/
|
8
|
-
export declare function synthesizeSpeech<SETTINGS extends SpeechSynthesisModelSettings>(model: SpeechSynthesisModel<SETTINGS>, text: string, options?:
|
8
|
+
export declare function synthesizeSpeech<SETTINGS extends SpeechSynthesisModelSettings>(model: SpeechSynthesisModel<SETTINGS>, text: string, options?: ModelFunctionOptions<SETTINGS>): ModelFunctionPromise<SpeechSynthesisModel<SETTINGS>, Buffer, Buffer>;
|
@@ -9,30 +9,28 @@ export function synthesizeSpeech(model, text, options) {
|
|
9
9
|
generateResponse: (options) => model.generateSpeechResponse(text, options),
|
10
10
|
extractOutputValue: (buffer) => buffer,
|
11
11
|
getStartEvent: (metadata, settings) => ({
|
12
|
-
|
13
|
-
|
12
|
+
...metadata,
|
13
|
+
functionType: "speech-synthesis",
|
14
14
|
settings,
|
15
15
|
text,
|
16
16
|
}),
|
17
17
|
getAbortEvent: (metadata, settings) => ({
|
18
|
-
|
18
|
+
...metadata,
|
19
|
+
functionType: "speech-synthesis",
|
19
20
|
status: "abort",
|
20
21
|
settings,
|
21
|
-
metadata,
|
22
22
|
text,
|
23
23
|
}),
|
24
24
|
getFailureEvent: (metadata, settings, error) => ({
|
25
|
-
|
26
|
-
|
27
|
-
metadata,
|
25
|
+
...metadata,
|
26
|
+
functionType: "speech-synthesis",
|
28
27
|
settings,
|
29
28
|
text,
|
30
29
|
error,
|
31
30
|
}),
|
32
31
|
getSuccessEvent: (metadata, settings, response, output) => ({
|
33
|
-
|
34
|
-
|
35
|
-
metadata,
|
32
|
+
...metadata,
|
33
|
+
functionType: "speech-synthesis",
|
36
34
|
settings,
|
37
35
|
text,
|
38
36
|
response,
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
export type TranscriptionStartedEvent = {
|
3
|
-
|
4
|
-
metadata: ModelCallStartedEventMetadata;
|
1
|
+
import { BaseModelCallFinishedEvent, BaseModelCallStartedEvent } from "../ModelCallEvent.js";
|
2
|
+
export type TranscriptionStartedEvent = BaseModelCallStartedEvent & {
|
3
|
+
functionType: "transcription";
|
5
4
|
settings: unknown;
|
6
5
|
data: unknown;
|
7
6
|
};
|
8
|
-
export type TranscriptionFinishedEvent = {
|
9
|
-
|
10
|
-
metadata: ModelCallFinishedEventMetadata;
|
7
|
+
export type TranscriptionFinishedEvent = BaseModelCallFinishedEvent & {
|
8
|
+
functionType: "transcription";
|
11
9
|
settings: unknown;
|
12
10
|
data: unknown;
|
13
11
|
} & ({
|
@@ -15,7 +13,7 @@ export type TranscriptionFinishedEvent = {
|
|
15
13
|
response: unknown;
|
16
14
|
transcription: string;
|
17
15
|
} | {
|
18
|
-
status: "
|
16
|
+
status: "error";
|
19
17
|
error: unknown;
|
20
18
|
} | {
|
21
19
|
status: "abort";
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelFunctionOptions } from "../ModelFunctionOptions.js";
|
2
2
|
import { Model, ModelSettings } from "../Model.js";
|
3
3
|
export interface TranscriptionModelSettings extends ModelSettings {
|
4
4
|
}
|
5
5
|
export interface TranscriptionModel<DATA, RESPONSE, SETTINGS> extends Model<SETTINGS> {
|
6
|
-
generateTranscriptionResponse: (data: DATA, options?:
|
6
|
+
generateTranscriptionResponse: (data: DATA, options?: ModelFunctionOptions<SETTINGS>) => PromiseLike<RESPONSE>;
|
7
7
|
extractTranscriptionText: (response: RESPONSE) => string;
|
8
8
|
}
|
@@ -23,30 +23,27 @@ function transcribe(model, data, options) {
|
|
23
23
|
generateResponse: (options) => model.generateTranscriptionResponse(data, options),
|
24
24
|
extractOutputValue: model.extractTranscriptionText,
|
25
25
|
getStartEvent: (metadata, settings) => ({
|
26
|
-
|
27
|
-
|
26
|
+
...metadata,
|
27
|
+
functionType: "transcription",
|
28
28
|
settings,
|
29
29
|
data,
|
30
30
|
}),
|
31
31
|
getAbortEvent: (metadata, settings) => ({
|
32
|
-
|
33
|
-
|
32
|
+
...metadata,
|
33
|
+
functionType: "transcription",
|
34
34
|
settings,
|
35
|
-
metadata,
|
36
35
|
data,
|
37
36
|
}),
|
38
37
|
getFailureEvent: (metadata, settings, error) => ({
|
39
|
-
|
40
|
-
|
41
|
-
metadata,
|
38
|
+
...metadata,
|
39
|
+
functionType: "transcription",
|
42
40
|
settings,
|
43
41
|
data,
|
44
42
|
error,
|
45
43
|
}),
|
46
44
|
getSuccessEvent: (metadata, settings, response, output) => ({
|
47
|
-
|
48
|
-
|
49
|
-
metadata,
|
45
|
+
...metadata,
|
46
|
+
functionType: "transcription",
|
50
47
|
settings,
|
51
48
|
data,
|
52
49
|
response,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelFunctionOptions } from "../ModelFunctionOptions.js";
|
2
2
|
import { ModelFunctionPromise } from "../executeCall.js";
|
3
3
|
import { TranscriptionModel, TranscriptionModelSettings } from "./TranscriptionModel.js";
|
4
4
|
/**
|
@@ -15,4 +15,4 @@ import { TranscriptionModel, TranscriptionModelSettings } from "./TranscriptionM
|
|
15
15
|
* }
|
16
16
|
* );
|
17
17
|
*/
|
18
|
-
export declare function transcribe<DATA, RESPONSE, SETTINGS extends TranscriptionModelSettings>(model: TranscriptionModel<DATA, RESPONSE, SETTINGS>, data: DATA, options?:
|
18
|
+
export declare function transcribe<DATA, RESPONSE, SETTINGS extends TranscriptionModelSettings>(model: TranscriptionModel<DATA, RESPONSE, SETTINGS>, data: DATA, options?: ModelFunctionOptions<SETTINGS>): ModelFunctionPromise<TranscriptionModel<DATA, RESPONSE, SETTINGS>, string, RESPONSE>;
|
@@ -20,30 +20,27 @@ export function transcribe(model, data, options) {
|
|
20
20
|
generateResponse: (options) => model.generateTranscriptionResponse(data, options),
|
21
21
|
extractOutputValue: model.extractTranscriptionText,
|
22
22
|
getStartEvent: (metadata, settings) => ({
|
23
|
-
|
24
|
-
|
23
|
+
...metadata,
|
24
|
+
functionType: "transcription",
|
25
25
|
settings,
|
26
26
|
data,
|
27
27
|
}),
|
28
28
|
getAbortEvent: (metadata, settings) => ({
|
29
|
-
|
30
|
-
|
29
|
+
...metadata,
|
30
|
+
functionType: "transcription",
|
31
31
|
settings,
|
32
|
-
metadata,
|
33
32
|
data,
|
34
33
|
}),
|
35
34
|
getFailureEvent: (metadata, settings, error) => ({
|
36
|
-
|
37
|
-
|
38
|
-
metadata,
|
35
|
+
...metadata,
|
36
|
+
functionType: "transcription",
|
39
37
|
settings,
|
40
38
|
data,
|
41
39
|
error,
|
42
40
|
}),
|
43
41
|
getSuccessEvent: (metadata, settings, response, output) => ({
|
44
|
-
|
45
|
-
|
46
|
-
metadata,
|
42
|
+
...metadata,
|
43
|
+
functionType: "transcription",
|
47
44
|
settings,
|
48
45
|
data,
|
49
46
|
response,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { z } from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
|
-
import {
|
3
|
+
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
4
4
|
import { ImageGenerationModel, ImageGenerationModelSettings } from "../../model-function/generate-image/ImageGenerationModel.js";
|
5
5
|
import { RetryFunction } from "../../util/api/RetryFunction.js";
|
6
6
|
import { ThrottleFunction } from "../../util/api/ThrottleFunction.js";
|
@@ -13,8 +13,8 @@ export declare class Automatic1111ImageGenerationModel extends AbstractModel<Aut
|
|
13
13
|
constructor(settings: Automatic1111ImageGenerationModelSettings);
|
14
14
|
readonly provider: "Automatic1111";
|
15
15
|
get modelName(): string;
|
16
|
-
callAPI(input: A111ImageGenerationPrompt, options?:
|
17
|
-
generateImageResponse(prompt: A111ImageGenerationPrompt, options?:
|
16
|
+
callAPI(input: A111ImageGenerationPrompt, options?: ModelFunctionOptions<Automatic1111ImageGenerationModelSettings>): Promise<Automatic1111ImageGenerationResponse>;
|
17
|
+
generateImageResponse(prompt: A111ImageGenerationPrompt, options?: ModelFunctionOptions<Automatic1111ImageGenerationModelSettings>): Promise<{
|
18
18
|
images: string[];
|
19
19
|
parameters: {};
|
20
20
|
info: string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
|
-
import {
|
3
|
+
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
4
4
|
import { TextEmbeddingModel, TextEmbeddingModelSettings } from "../../model-function/embed-text/TextEmbeddingModel.js";
|
5
5
|
import { FullTokenizer } from "../../model-function/tokenize-text/Tokenizer.js";
|
6
6
|
import { RetryFunction } from "../../util/api/RetryFunction.js";
|
@@ -61,8 +61,8 @@ export declare class CohereTextEmbeddingModel extends AbstractModel<CohereTextEm
|
|
61
61
|
}>;
|
62
62
|
detokenize(tokens: number[]): Promise<string>;
|
63
63
|
private get apiKey();
|
64
|
-
callAPI(texts: Array<string>, options?:
|
65
|
-
generateEmbeddingResponse(texts: string[], options?:
|
64
|
+
callAPI(texts: Array<string>, options?: ModelFunctionOptions<CohereTextEmbeddingModelSettings>): Promise<CohereTextEmbeddingResponse>;
|
65
|
+
generateEmbeddingResponse(texts: string[], options?: ModelFunctionOptions<CohereTextEmbeddingModelSettings>): Promise<{
|
66
66
|
texts: string[];
|
67
67
|
id: string;
|
68
68
|
meta: {
|