modelfusion 0.42.0 → 0.44.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 +42 -2
- package/core/getRun.cjs +60 -0
- package/core/getRun.d.ts +9 -0
- package/core/getRun.js +32 -0
- package/core/index.cjs +1 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/guard/fixStructure.cjs +21 -0
- package/guard/fixStructure.d.ts +10 -0
- package/guard/fixStructure.js +17 -0
- package/guard/guard.cjs +72 -0
- package/guard/guard.d.ts +28 -0
- package/guard/guard.js +68 -0
- package/guard/index.cjs +18 -0
- package/guard/index.d.ts +2 -0
- package/guard/index.js +2 -0
- package/index.cjs +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/model-function/executeCall.cjs +8 -2
- package/model-function/executeCall.js +8 -2
- package/model-function/generate-structure/StructureFromTextGenerationModel.cjs +15 -4
- package/model-function/generate-structure/StructureFromTextGenerationModel.d.ts +2 -1
- package/model-function/generate-structure/StructureFromTextGenerationModel.js +15 -4
- package/model-function/generate-structure/StructureGenerationModel.d.ts +2 -1
- package/model-function/generate-structure/StructureOrTextGenerationModel.d.ts +2 -0
- package/model-function/generate-structure/StructureParseError.cjs +34 -0
- package/model-function/generate-structure/StructureParseError.d.ts +10 -0
- package/model-function/generate-structure/StructureParseError.js +30 -0
- package/model-function/generate-structure/StructureValidationError.cjs +10 -3
- package/model-function/generate-structure/StructureValidationError.d.ts +3 -1
- package/model-function/generate-structure/StructureValidationError.js +10 -3
- package/model-function/generate-structure/generateStructure.cjs +2 -1
- package/model-function/generate-structure/generateStructure.js +2 -1
- package/model-function/generate-structure/generateStructureOrText.cjs +1 -0
- package/model-function/generate-structure/generateStructureOrText.js +1 -0
- package/model-function/generate-structure/streamStructure.cjs +8 -2
- package/model-function/generate-structure/streamStructure.js +8 -2
- package/model-function/generate-text/streamText.cjs +8 -2
- package/model-function/generate-text/streamText.js +8 -2
- package/model-function/index.cjs +1 -0
- package/model-function/index.d.ts +1 -0
- package/model-function/index.js +1 -0
- package/model-provider/openai/chat/OpenAIChatModel.cjs +47 -20
- package/model-provider/openai/chat/OpenAIChatModel.d.ts +36 -2
- package/model-provider/openai/chat/OpenAIChatModel.js +47 -20
- package/package.json +1 -1
- package/retriever/retrieve.cjs +8 -2
- package/retriever/retrieve.js +8 -2
- package/tool/executeTool.cjs +8 -2
- package/tool/executeTool.js +8 -2
package/retriever/retrieve.js
CHANGED
@@ -4,10 +4,11 @@ import { getGlobalFunctionLogging } from "../core/GlobalFunctionLogging.js";
|
|
4
4
|
import { getGlobalFunctionObservers } from "../core/GlobalFunctionObservers.js";
|
5
5
|
import { AbortError } from "../core/api/AbortError.js";
|
6
6
|
import { getFunctionCallLogger } from "../core/getFunctionCallLogger.js";
|
7
|
+
import { getRun } from "../core/getRun.js";
|
7
8
|
import { startDurationMeasurement } from "../util/DurationMeasurement.js";
|
8
9
|
import { runSafe } from "../util/runSafe.js";
|
9
10
|
export async function retrieve(retriever, query, options) {
|
10
|
-
const run = options?.run;
|
11
|
+
const run = await getRun(options?.run);
|
11
12
|
const eventSource = new FunctionEventSource({
|
12
13
|
observers: [
|
13
14
|
...getFunctionCallLogger(options?.logging ?? getGlobalFunctionLogging()),
|
@@ -33,7 +34,12 @@ export async function retrieve(retriever, query, options) {
|
|
33
34
|
eventType: "started",
|
34
35
|
...startMetadata,
|
35
36
|
});
|
36
|
-
const result = await runSafe(() => retriever.retrieve(query,
|
37
|
+
const result = await runSafe(() => retriever.retrieve(query, {
|
38
|
+
functionId: options?.functionId,
|
39
|
+
logging: options?.logging,
|
40
|
+
observers: options?.observers,
|
41
|
+
run,
|
42
|
+
}));
|
37
43
|
const finishMetadata = {
|
38
44
|
eventType: "finished",
|
39
45
|
...startMetadata,
|
package/tool/executeTool.cjs
CHANGED
@@ -7,6 +7,7 @@ const GlobalFunctionLogging_js_1 = require("../core/GlobalFunctionLogging.cjs");
|
|
7
7
|
const GlobalFunctionObservers_js_1 = require("../core/GlobalFunctionObservers.cjs");
|
8
8
|
const AbortError_js_1 = require("../core/api/AbortError.cjs");
|
9
9
|
const getFunctionCallLogger_js_1 = require("../core/getFunctionCallLogger.cjs");
|
10
|
+
const getRun_js_1 = require("../core/getRun.cjs");
|
10
11
|
const DurationMeasurement_js_1 = require("../util/DurationMeasurement.cjs");
|
11
12
|
const runSafe_js_1 = require("../util/runSafe.cjs");
|
12
13
|
const ToolExecutionError_js_1 = require("./ToolExecutionError.cjs");
|
@@ -54,7 +55,7 @@ function executeTool(tool, input, options) {
|
|
54
55
|
exports.executeTool = executeTool;
|
55
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
56
57
|
async function doExecuteTool(tool, input, options) {
|
57
|
-
const run = options?.run;
|
58
|
+
const run = await (0, getRun_js_1.getRun)(options?.run);
|
58
59
|
const eventSource = new FunctionEventSource_js_1.FunctionEventSource({
|
59
60
|
observers: [
|
60
61
|
...(0, getFunctionCallLogger_js_1.getFunctionCallLogger)(options?.logging ?? (0, GlobalFunctionLogging_js_1.getGlobalFunctionLogging)()),
|
@@ -81,7 +82,12 @@ async function doExecuteTool(tool, input, options) {
|
|
81
82
|
timestamp: durationMeasurement.startDate,
|
82
83
|
startTimestamp: durationMeasurement.startDate,
|
83
84
|
});
|
84
|
-
const result = await (0, runSafe_js_1.runSafe)(() => tool.execute(input,
|
85
|
+
const result = await (0, runSafe_js_1.runSafe)(() => tool.execute(input, {
|
86
|
+
functionId: options?.functionId,
|
87
|
+
logging: options?.logging,
|
88
|
+
observers: options?.observers,
|
89
|
+
run,
|
90
|
+
}));
|
85
91
|
const finishMetadata = {
|
86
92
|
...metadata,
|
87
93
|
eventType: "finished",
|
package/tool/executeTool.js
CHANGED
@@ -4,6 +4,7 @@ import { getGlobalFunctionLogging } from "../core/GlobalFunctionLogging.js";
|
|
4
4
|
import { getGlobalFunctionObservers } from "../core/GlobalFunctionObservers.js";
|
5
5
|
import { AbortError } from "../core/api/AbortError.js";
|
6
6
|
import { getFunctionCallLogger } from "../core/getFunctionCallLogger.js";
|
7
|
+
import { getRun } from "../core/getRun.js";
|
7
8
|
import { startDurationMeasurement } from "../util/DurationMeasurement.js";
|
8
9
|
import { runSafe } from "../util/runSafe.js";
|
9
10
|
import { ToolExecutionError } from "./ToolExecutionError.js";
|
@@ -49,7 +50,7 @@ export function executeTool(tool, input, options) {
|
|
49
50
|
}
|
50
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
51
52
|
async function doExecuteTool(tool, input, options) {
|
52
|
-
const run = options?.run;
|
53
|
+
const run = await getRun(options?.run);
|
53
54
|
const eventSource = new FunctionEventSource({
|
54
55
|
observers: [
|
55
56
|
...getFunctionCallLogger(options?.logging ?? getGlobalFunctionLogging()),
|
@@ -76,7 +77,12 @@ async function doExecuteTool(tool, input, options) {
|
|
76
77
|
timestamp: durationMeasurement.startDate,
|
77
78
|
startTimestamp: durationMeasurement.startDate,
|
78
79
|
});
|
79
|
-
const result = await runSafe(() => tool.execute(input,
|
80
|
+
const result = await runSafe(() => tool.execute(input, {
|
81
|
+
functionId: options?.functionId,
|
82
|
+
logging: options?.logging,
|
83
|
+
observers: options?.observers,
|
84
|
+
run,
|
85
|
+
}));
|
80
86
|
const finishMetadata = {
|
81
87
|
...metadata,
|
82
88
|
eventType: "finished",
|