modelfusion 0.20.1 → 0.22.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 +5 -7
- package/composed-function/summarize/SummarizationFunction.d.ts +3 -3
- package/composed-function/summarize/summarizeRecursively.d.ts +1 -1
- package/composed-function/summarize/summarizeRecursivelyWithTextGenerationAndTokenSplitting.d.ts +1 -1
- package/{run → core}/ConsoleLogger.cjs +1 -4
- package/core/ConsoleLogger.d.ts +5 -0
- package/core/ConsoleLogger.js +5 -0
- package/{run → core}/DefaultRun.cjs +2 -5
- package/{run → core}/DefaultRun.d.ts +5 -5
- package/{run → core}/DefaultRun.js +2 -5
- package/core/FunctionEvent.d.ts +75 -0
- package/{run/RunFunctionEventSource.js → core/FunctionEventSource.cjs} +7 -13
- package/core/FunctionEventSource.d.ts +12 -0
- package/{run/RunFunctionEventSource.cjs → core/FunctionEventSource.js} +3 -17
- package/core/FunctionObserver.d.ts +7 -0
- package/core/FunctionOptions.d.ts +19 -0
- package/core/GlobalFunctionObservers.cjs +12 -0
- package/core/GlobalFunctionObservers.d.ts +3 -0
- package/core/GlobalFunctionObservers.js +7 -0
- package/{run → core}/Run.d.ts +2 -2
- package/{run → core}/index.cjs +5 -5
- package/core/index.d.ts +9 -0
- package/core/index.js +9 -0
- package/index.cjs +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/model-function/Model.d.ts +5 -2
- package/model-function/ModelCallEvent.d.ts +20 -5
- package/model-function/ModelFunctionOptions.d.ts +4 -0
- package/model-function/SuccessfulModelCall.cjs +6 -16
- package/model-function/SuccessfulModelCall.d.ts +2 -2
- package/model-function/SuccessfulModelCall.js +6 -16
- package/model-function/embed-text/TextEmbeddingEvent.d.ts +15 -17
- package/model-function/embed-text/TextEmbeddingModel.d.ts +3 -3
- package/model-function/embed-text/embedText.cjs +6 -67
- package/model-function/embed-text/embedText.d.ts +4 -4
- package/model-function/embed-text/embedText.js +6 -67
- package/model-function/executeCall.cjs +49 -14
- package/model-function/executeCall.d.ts +9 -10
- package/model-function/executeCall.js +49 -14
- package/model-function/generate-image/ImageGenerationEvent.d.ts +12 -16
- package/model-function/generate-image/ImageGenerationModel.d.ts +2 -2
- package/model-function/generate-image/generateImage.cjs +2 -30
- package/model-function/generate-image/generateImage.d.ts +2 -2
- package/model-function/generate-image/generateImage.js +2 -30
- 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 -21
- package/model-function/generate-json/JsonTextGenerationModel.d.ts +2 -2
- package/model-function/generate-json/generateJson.cjs +2 -30
- package/model-function/generate-json/generateJson.d.ts +2 -2
- package/model-function/generate-json/generateJson.js +2 -30
- package/model-function/generate-json/generateJsonOrText.cjs +2 -30
- package/model-function/generate-json/generateJsonOrText.d.ts +2 -2
- package/model-function/generate-json/generateJsonOrText.js +2 -30
- package/model-function/generate-text/TextGenerationEvent.d.ts +13 -15
- package/model-function/generate-text/TextGenerationModel.d.ts +3 -3
- package/model-function/generate-text/TextStreamingEvent.d.ts +7 -22
- package/model-function/generate-text/generateText.cjs +2 -30
- package/model-function/generate-text/generateText.d.ts +2 -2
- package/model-function/generate-text/generateText.js +2 -30
- package/model-function/generate-text/streamText.cjs +52 -42
- package/model-function/generate-text/streamText.d.ts +5 -5
- package/model-function/generate-text/streamText.js +52 -42
- 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 +14 -15
- package/model-function/synthesize-speech/SpeechSynthesisModel.d.ts +2 -2
- package/model-function/synthesize-speech/synthesizeSpeech.cjs +2 -30
- package/model-function/synthesize-speech/synthesizeSpeech.d.ts +2 -2
- package/model-function/synthesize-speech/synthesizeSpeech.js +2 -30
- package/model-function/transcribe-speech/TranscriptionEvent.d.ts +12 -16
- package/model-function/transcribe-speech/TranscriptionModel.d.ts +2 -2
- package/model-function/transcribe-speech/transcribe.cjs +2 -30
- package/model-function/transcribe-speech/transcribe.d.ts +2 -2
- package/model-function/transcribe-speech/transcribe.js +2 -30
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +3 -3
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +6 -6
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +4 -4
- package/model-provider/cohere/CohereTokenizer.d.ts +1 -1
- 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/llamacpp/LlamaCppTokenizer.d.ts +1 -1
- 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/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 +9 -20
- package/tool/Tool.d.ts +3 -3
- package/tool/WebSearchTool.cjs +25 -0
- package/tool/WebSearchTool.d.ts +57 -1
- package/tool/WebSearchTool.js +25 -0
- package/tool/executeTool.cjs +39 -31
- package/tool/executeTool.d.ts +5 -4
- package/tool/executeTool.js +39 -31
- 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/vector-index/VectorIndex.d.ts +1 -1
- package/vector-index/memory/MemoryVectorIndex.d.ts +1 -1
- package/vector-index/pinecone/PineconeVectorIndex.d.ts +1 -1
- package/model-function/FunctionOptions.d.ts +0 -6
- package/run/ConsoleLogger.d.ts +0 -6
- package/run/ConsoleLogger.js +0 -8
- 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/run/index.d.ts +0 -9
- package/run/index.js +0 -9
- /package/{model-function/FunctionOptions.cjs → core/FunctionEvent.cjs} +0 -0
- /package/{model-function/FunctionOptions.js → core/FunctionEvent.js} +0 -0
- /package/{run/IdMetadata.cjs → core/FunctionObserver.cjs} +0 -0
- /package/{run/IdMetadata.js → core/FunctionObserver.js} +0 -0
- /package/{run/Run.cjs → core/FunctionOptions.cjs} +0 -0
- /package/{run/Run.js → core/FunctionOptions.js} +0 -0
- /package/{run/RunFunction.cjs → core/Run.cjs} +0 -0
- /package/{run/RunFunction.js → core/Run.js} +0 -0
- /package/{run → core}/Vector.cjs +0 -0
- /package/{run → core}/Vector.d.ts +0 -0
- /package/{run → core}/Vector.js +0 -0
- /package/{run/RunFunctionEvent.cjs → model-function/ModelFunctionOptions.cjs} +0 -0
- /package/{run/RunFunctionEvent.js → model-function/ModelFunctionOptions.js} +0 -0
package/tool/executeTool.d.ts
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
import { FunctionOptions } from "../model-function/FunctionOptions.js";
|
2
|
-
import { Tool } from "./Tool.js";
|
3
1
|
import { z } from "zod";
|
2
|
+
import { FunctionOptions } from "../core/FunctionOptions.js";
|
3
|
+
import { Tool } from "./Tool.js";
|
4
4
|
export type ExecuteToolMetadata = {
|
5
5
|
callId: string;
|
6
6
|
runId?: string;
|
7
7
|
sessionId?: string;
|
8
8
|
userId?: string;
|
9
9
|
functionId?: string;
|
10
|
-
|
10
|
+
startTimestamp: Date;
|
11
|
+
finishTimestamp: Date;
|
11
12
|
durationInMs: number;
|
12
13
|
};
|
13
14
|
export declare class ExecuteToolPromise<OUTPUT> extends Promise<OUTPUT> {
|
@@ -28,4 +29,4 @@ export declare class ExecuteToolPromise<OUTPUT> extends Promise<OUTPUT> {
|
|
28
29
|
/**
|
29
30
|
* `executeTool` directly executes a tool with the given parameters.
|
30
31
|
*/
|
31
|
-
export declare function executeTool<TOOL extends Tool<any, any, any>>(tool: TOOL, input: z.infer<TOOL["inputSchema"]>, options?: FunctionOptions
|
32
|
+
export declare function executeTool<TOOL extends Tool<any, any, any>>(tool: TOOL, input: z.infer<TOOL["inputSchema"]>, options?: FunctionOptions): ExecuteToolPromise<ReturnType<TOOL["execute"]>>;
|
package/tool/executeTool.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { nanoid as createId } from "nanoid";
|
2
|
-
import {
|
2
|
+
import { FunctionEventSource } from "../core/FunctionEventSource.js";
|
3
|
+
import { getGlobalFunctionObservers } from "../core/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";
|
@@ -47,48 +48,56 @@ export function executeTool(tool, input, options) {
|
|
47
48
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
48
49
|
async function doExecuteTool(tool, input, options) {
|
49
50
|
const run = options?.run;
|
50
|
-
const eventSource = new
|
51
|
-
observers:
|
51
|
+
const eventSource = new FunctionEventSource({
|
52
|
+
observers: [
|
53
|
+
...getGlobalFunctionObservers(),
|
54
|
+
...(run?.observers ?? []),
|
55
|
+
...(options?.observers ?? []),
|
56
|
+
],
|
52
57
|
errorHandler: run?.errorHandler,
|
53
58
|
});
|
54
59
|
const durationMeasurement = startDurationMeasurement();
|
55
|
-
const
|
60
|
+
const metadata = {
|
61
|
+
functionType: "execute-tool",
|
56
62
|
callId: `call-${createId()}`,
|
57
63
|
runId: run?.runId,
|
58
64
|
sessionId: run?.sessionId,
|
59
65
|
userId: run?.userId,
|
60
66
|
functionId: options?.functionId,
|
61
|
-
|
62
|
-
};
|
63
|
-
eventSource.notifyRunFunctionStarted({
|
64
|
-
type: "execute-tool-started",
|
65
|
-
metadata: startMetadata,
|
66
|
-
tool: tool,
|
67
|
+
toolName: tool.name,
|
67
68
|
input,
|
69
|
+
};
|
70
|
+
eventSource.notify({
|
71
|
+
...metadata,
|
72
|
+
eventType: "started",
|
73
|
+
timestamp: durationMeasurement.startDate,
|
74
|
+
startTimestamp: durationMeasurement.startDate,
|
68
75
|
});
|
69
76
|
const result = await runSafe(() => tool.execute(input, options));
|
70
77
|
const finishMetadata = {
|
71
|
-
...
|
78
|
+
...metadata,
|
79
|
+
eventType: "finished",
|
80
|
+
timestamp: new Date(),
|
81
|
+
startTimestamp: durationMeasurement.startDate,
|
82
|
+
finishTimestamp: new Date(),
|
72
83
|
durationInMs: durationMeasurement.durationInMs,
|
73
84
|
};
|
74
85
|
if (!result.ok) {
|
75
86
|
if (result.isAborted) {
|
76
|
-
eventSource.
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
input,
|
87
|
+
eventSource.notify({
|
88
|
+
...finishMetadata,
|
89
|
+
result: {
|
90
|
+
status: "abort",
|
91
|
+
},
|
82
92
|
});
|
83
93
|
throw new AbortError();
|
84
94
|
}
|
85
|
-
eventSource.
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
error: result.error,
|
95
|
+
eventSource.notify({
|
96
|
+
...finishMetadata,
|
97
|
+
result: {
|
98
|
+
status: "error",
|
99
|
+
error: result.error,
|
100
|
+
},
|
92
101
|
});
|
93
102
|
throw new ToolExecutionError({
|
94
103
|
toolName: tool.name,
|
@@ -99,13 +108,12 @@ async function doExecuteTool(tool, input, options) {
|
|
99
108
|
});
|
100
109
|
}
|
101
110
|
const output = result.output;
|
102
|
-
eventSource.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
output,
|
111
|
+
eventSource.notify({
|
112
|
+
...finishMetadata,
|
113
|
+
result: {
|
114
|
+
status: "success",
|
115
|
+
output,
|
116
|
+
},
|
109
117
|
});
|
110
118
|
return {
|
111
119
|
output,
|
package/tool/useTool.cjs
CHANGED
@@ -18,15 +18,11 @@ async function useTool(model, tool, prompt, options) {
|
|
18
18
|
name: tool.name,
|
19
19
|
description: tool.description,
|
20
20
|
schema: tool.inputSchema,
|
21
|
-
}, () => prompt(tool),
|
22
|
-
...(options ?? {}),
|
23
|
-
}).asFullResponse();
|
21
|
+
}, () => prompt(tool), options).asFullResponse();
|
24
22
|
return {
|
25
23
|
tool: tool.name,
|
26
24
|
parameters: value,
|
27
|
-
result: await (0, executeTool_js_1.executeTool)(tool, value,
|
28
|
-
run: options?.run,
|
29
|
-
}),
|
25
|
+
result: await (0, executeTool_js_1.executeTool)(tool, value, options),
|
30
26
|
};
|
31
27
|
}
|
32
28
|
exports.useTool = useTool;
|
package/tool/useTool.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelFunctionOptions } from "../model-function/ModelFunctionOptions.js";
|
2
2
|
import { GenerateJsonModel, GenerateJsonModelSettings } from "../model-function/generate-json/GenerateJsonModel.js";
|
3
3
|
import { Tool } from "./Tool.js";
|
4
4
|
/**
|
@@ -8,7 +8,7 @@ import { Tool } from "./Tool.js";
|
|
8
8
|
* the parameters (`parameters` property, typed),
|
9
9
|
* and the result of the tool execution (`result` property, typed).
|
10
10
|
*/
|
11
|
-
export declare function useTool<PROMPT, RESPONSE, SETTINGS extends GenerateJsonModelSettings, TOOL extends Tool<any, any, any>>(model: GenerateJsonModel<PROMPT, RESPONSE, SETTINGS>, tool: TOOL, prompt: (tool: TOOL) => PROMPT, options?:
|
11
|
+
export declare function useTool<PROMPT, RESPONSE, SETTINGS extends GenerateJsonModelSettings, TOOL extends Tool<any, any, any>>(model: GenerateJsonModel<PROMPT, RESPONSE, SETTINGS>, tool: TOOL, prompt: (tool: TOOL) => PROMPT, options?: ModelFunctionOptions<SETTINGS>): Promise<{
|
12
12
|
tool: TOOL["name"];
|
13
13
|
parameters: TOOL["inputSchema"];
|
14
14
|
result: Awaited<ReturnType<TOOL["execute"]>>;
|
package/tool/useTool.js
CHANGED
@@ -15,14 +15,10 @@ export async function useTool(model, tool, prompt, options) {
|
|
15
15
|
name: tool.name,
|
16
16
|
description: tool.description,
|
17
17
|
schema: tool.inputSchema,
|
18
|
-
}, () => prompt(tool),
|
19
|
-
...(options ?? {}),
|
20
|
-
}).asFullResponse();
|
18
|
+
}, () => prompt(tool), options).asFullResponse();
|
21
19
|
return {
|
22
20
|
tool: tool.name,
|
23
21
|
parameters: value,
|
24
|
-
result: await executeTool(tool, value,
|
25
|
-
run: options?.run,
|
26
|
-
}),
|
22
|
+
result: await executeTool(tool, value, options),
|
27
23
|
};
|
28
24
|
}
|
@@ -25,9 +25,7 @@ async function useToolOrGenerateText(model, tools, prompt, options) {
|
|
25
25
|
throw new NoSuchToolError_js_1.NoSuchToolError(schema.toString());
|
26
26
|
}
|
27
27
|
const toolParameters = modelResponse.value;
|
28
|
-
const result = await (0, executeTool_js_1.executeTool)(tool, toolParameters,
|
29
|
-
run: options?.run,
|
30
|
-
});
|
28
|
+
const result = await (0, executeTool_js_1.executeTool)(tool, toolParameters, options);
|
31
29
|
return {
|
32
30
|
tool: schema,
|
33
31
|
result,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { ModelFunctionOptions } from "../model-function/ModelFunctionOptions.js";
|
2
2
|
import { GenerateJsonOrTextModel, GenerateJsonOrTextModelSettings, GenerateJsonOrTextPrompt } from "../model-function/generate-json/GenerateJsonOrTextModel.js";
|
3
3
|
import { Tool } from "./Tool.js";
|
4
4
|
type ToolArray<T extends Tool<any, any, any>[]> = T;
|
@@ -14,7 +14,7 @@ type ToToolUnion<T> = {
|
|
14
14
|
} : never;
|
15
15
|
}[keyof T];
|
16
16
|
type ToOutputValue<TOOLS extends ToolArray<Tool<any, any, any>[]>> = ToToolUnion<ToToolMap<TOOLS>>;
|
17
|
-
export declare function useToolOrGenerateText<PROMPT, RESPONSE, SETTINGS extends GenerateJsonOrTextModelSettings, TOOLS extends Array<Tool<any, any, any>>>(model: GenerateJsonOrTextModel<PROMPT, RESPONSE, SETTINGS>, tools: TOOLS, prompt: (tools: TOOLS) => PROMPT & GenerateJsonOrTextPrompt<RESPONSE>, options?:
|
17
|
+
export declare function useToolOrGenerateText<PROMPT, RESPONSE, SETTINGS extends GenerateJsonOrTextModelSettings, TOOLS extends Array<Tool<any, any, any>>>(model: GenerateJsonOrTextModel<PROMPT, RESPONSE, SETTINGS>, tools: TOOLS, prompt: (tools: TOOLS) => PROMPT & GenerateJsonOrTextPrompt<RESPONSE>, options?: ModelFunctionOptions<SETTINGS>): Promise<{
|
18
18
|
tool: null;
|
19
19
|
parameters: null;
|
20
20
|
result: null;
|
@@ -22,9 +22,7 @@ export async function useToolOrGenerateText(model, tools, prompt, options) {
|
|
22
22
|
throw new NoSuchToolError(schema.toString());
|
23
23
|
}
|
24
24
|
const toolParameters = modelResponse.value;
|
25
|
-
const result = await executeTool(tool, toolParameters,
|
26
|
-
run: options?.run,
|
27
|
-
});
|
25
|
+
const result = await executeTool(tool, toolParameters, options);
|
28
26
|
return {
|
29
27
|
tool: schema,
|
30
28
|
result,
|
@@ -20,6 +20,9 @@ class PerformanceNowDurationMeasurement {
|
|
20
20
|
get startEpochSeconds() {
|
21
21
|
return Math.floor((globalThis.performance.timeOrigin + this.startTime) / 1000);
|
22
22
|
}
|
23
|
+
get startDate() {
|
24
|
+
return new Date(this.startEpochSeconds * 1000);
|
25
|
+
}
|
23
26
|
get durationInMs() {
|
24
27
|
return Math.ceil(globalThis.performance.now() - this.startTime);
|
25
28
|
}
|
@@ -36,6 +39,9 @@ class DateDurationMeasurement {
|
|
36
39
|
get startEpochSeconds() {
|
37
40
|
return Math.floor(this.startTime / 1000);
|
38
41
|
}
|
42
|
+
get startDate() {
|
43
|
+
return new Date(this.startTime);
|
44
|
+
}
|
39
45
|
get durationInMs() {
|
40
46
|
return Date.now() - this.startTime;
|
41
47
|
}
|
@@ -16,6 +16,9 @@ class PerformanceNowDurationMeasurement {
|
|
16
16
|
get startEpochSeconds() {
|
17
17
|
return Math.floor((globalThis.performance.timeOrigin + this.startTime) / 1000);
|
18
18
|
}
|
19
|
+
get startDate() {
|
20
|
+
return new Date(this.startEpochSeconds * 1000);
|
21
|
+
}
|
19
22
|
get durationInMs() {
|
20
23
|
return Math.ceil(globalThis.performance.now() - this.startTime);
|
21
24
|
}
|
@@ -32,6 +35,9 @@ class DateDurationMeasurement {
|
|
32
35
|
get startEpochSeconds() {
|
33
36
|
return Math.floor(this.startTime / 1000);
|
34
37
|
}
|
38
|
+
get startDate() {
|
39
|
+
return new Date(this.startTime);
|
40
|
+
}
|
35
41
|
get durationInMs() {
|
36
42
|
return Date.now() - this.startTime;
|
37
43
|
}
|
package/util/api/postToApi.cjs
CHANGED
@@ -105,6 +105,14 @@ const postToApi = async ({ url, headers = {}, body, successfulResponseHandler, f
|
|
105
105
|
throw error;
|
106
106
|
}
|
107
107
|
}
|
108
|
+
// unwrap original error when fetch failed (for easier debugging):
|
109
|
+
if (error instanceof TypeError && error.message === "fetch failed") {
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
111
|
+
if (error.cause != null) {
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
113
|
+
throw error.cause;
|
114
|
+
}
|
115
|
+
}
|
108
116
|
throw error;
|
109
117
|
}
|
110
118
|
};
|
package/util/api/postToApi.js
CHANGED
@@ -98,6 +98,14 @@ export const postToApi = async ({ url, headers = {}, body, successfulResponseHan
|
|
98
98
|
throw error;
|
99
99
|
}
|
100
100
|
}
|
101
|
+
// unwrap original error when fetch failed (for easier debugging):
|
102
|
+
if (error instanceof TypeError && error.message === "fetch failed") {
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
104
|
+
if (error.cause != null) {
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
106
|
+
throw error.cause;
|
107
|
+
}
|
108
|
+
}
|
101
109
|
throw error;
|
102
110
|
}
|
103
111
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { VectorOperationsApi } from "@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/index.js";
|
2
2
|
import { z } from "zod";
|
3
|
-
import { Vector } from "../../
|
3
|
+
import { Vector } from "../../core/Vector.js";
|
4
4
|
import { VectorIndex } from "../VectorIndex.js";
|
5
5
|
export declare class PineconeVectorIndex<DATA extends object | undefined> implements VectorIndex<DATA, PineconeVectorIndex<DATA>> {
|
6
6
|
readonly index: VectorOperationsApi;
|
package/run/ConsoleLogger.d.ts
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
import { RunFunctionFinishedEvent, RunFunctionStartedEvent } from "./RunFunctionEvent.js";
|
2
|
-
import { RunFunctionObserver } from "./RunFunctionObserver.js";
|
3
|
-
export declare class ConsoleLogger implements RunFunctionObserver {
|
4
|
-
onRunFunctionStarted(event: RunFunctionStartedEvent): void;
|
5
|
-
onRunFunctionFinished(event: RunFunctionFinishedEvent): void;
|
6
|
-
}
|
package/run/ConsoleLogger.js
DELETED
package/run/IdMetadata.d.ts
DELETED
package/run/RunFunction.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Run } from "./Run.js";
|
2
|
-
/**
|
3
|
-
* Standardized function signature for functions that are part of a run.
|
4
|
-
*
|
5
|
-
* This enables wrapping and chaining of run functions.
|
6
|
-
*/
|
7
|
-
export type RunFunction<INPUT, OUTPUT> = (input: INPUT, options?: {
|
8
|
-
run?: Run;
|
9
|
-
}) => PromiseLike<OUTPUT>;
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { ExecuteToolFinishedEvent, ExecuteToolStartedEvent } from "../tool/ExecuteToolEvent.js";
|
2
|
-
import { ModelCallFinishedEvent, ModelCallStartedEvent } from "../model-function/ModelCallEvent.js";
|
3
|
-
import { IdMetadata } from "./IdMetadata.js";
|
4
|
-
export type RunFunctionEvent = RunFunctionStartedEvent | RunFunctionFinishedEvent;
|
5
|
-
export type RunFunctionStartedEventMetadata = IdMetadata & {
|
6
|
-
startEpochSeconds: number;
|
7
|
-
};
|
8
|
-
export type RunFunctionStartedEvent = ModelCallStartedEvent | ExecuteToolStartedEvent;
|
9
|
-
export type RunFunctionFinishedEventMetadata = RunFunctionStartedEventMetadata & {
|
10
|
-
durationInMs: number;
|
11
|
-
};
|
12
|
-
export type RunFunctionFinishedEvent = ModelCallFinishedEvent | ExecuteToolFinishedEvent;
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import { ErrorHandler } from "../util/ErrorHandler.js";
|
2
|
-
import { RunFunctionFinishedEvent, RunFunctionStartedEvent } from "./RunFunctionEvent.js";
|
3
|
-
import { RunFunctionObserver } from "./RunFunctionObserver.js";
|
4
|
-
export declare class RunFunctionEventSource {
|
5
|
-
readonly observers: RunFunctionObserver[];
|
6
|
-
readonly errorHandler: ErrorHandler;
|
7
|
-
constructor({ observers, errorHandler, }: {
|
8
|
-
observers: RunFunctionObserver[];
|
9
|
-
errorHandler?: ErrorHandler;
|
10
|
-
});
|
11
|
-
notifyRunFunctionStarted(event: RunFunctionStartedEvent): void;
|
12
|
-
notifyRunFunctionFinished(event: RunFunctionFinishedEvent): void;
|
13
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/run/index.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
export * from "./ConsoleLogger.js";
|
2
|
-
export * from "./DefaultRun.js";
|
3
|
-
export * from "./IdMetadata.js";
|
4
|
-
export * from "./Run.js";
|
5
|
-
export * from "./RunFunction.js";
|
6
|
-
export * from "./RunFunctionEvent.js";
|
7
|
-
export * from "./RunFunctionObserver.js";
|
8
|
-
export * from "./RunFunctionEventSource.js";
|
9
|
-
export * from "./Vector.js";
|
package/run/index.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
export * from "./ConsoleLogger.js";
|
2
|
-
export * from "./DefaultRun.js";
|
3
|
-
export * from "./IdMetadata.js";
|
4
|
-
export * from "./Run.js";
|
5
|
-
export * from "./RunFunction.js";
|
6
|
-
export * from "./RunFunctionEvent.js";
|
7
|
-
export * from "./RunFunctionObserver.js";
|
8
|
-
export * from "./RunFunctionEventSource.js";
|
9
|
-
export * from "./Vector.js";
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/{run → core}/Vector.cjs
RENAMED
File without changes
|
File without changes
|
/package/{run → core}/Vector.js
RENAMED
File without changes
|
File without changes
|
File without changes
|