modelfusion 0.77.0 → 0.78.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/model-provider/ollama/OllamaTextGenerationModel.cjs +1 -1
- package/model-provider/ollama/OllamaTextGenerationModel.js +1 -1
- package/package.json +1 -1
- package/tool/generate-tool-call/index.cjs +0 -14
- package/tool/generate-tool-call/index.d.ts +0 -1
- package/tool/generate-tool-call/index.js +0 -1
- package/tool/generate-tool-call/FunctionListToolCallPromptFormat.cjs +0 -70
- package/tool/generate-tool-call/FunctionListToolCallPromptFormat.d.ts +0 -14
- package/tool/generate-tool-call/FunctionListToolCallPromptFormat.js +0 -65
@@ -97,7 +97,7 @@ class OllamaTextGenerationModel extends AbstractModel_js_1.AbstractModel {
|
|
97
97
|
}
|
98
98
|
asToolCallGenerationModel(promptFormat) {
|
99
99
|
return new TextGenerationToolCallModel_js_1.TextGenerationToolCallModel({
|
100
|
-
model: this
|
100
|
+
model: this,
|
101
101
|
format: promptFormat,
|
102
102
|
});
|
103
103
|
}
|
@@ -94,7 +94,7 @@ export class OllamaTextGenerationModel extends AbstractModel {
|
|
94
94
|
}
|
95
95
|
asToolCallGenerationModel(promptFormat) {
|
96
96
|
return new TextGenerationToolCallModel({
|
97
|
-
model: this
|
97
|
+
model: this,
|
98
98
|
format: promptFormat,
|
99
99
|
});
|
100
100
|
}
|
package/package.json
CHANGED
@@ -10,24 +10,10 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
11
11
|
o[k2] = m[k];
|
12
12
|
}));
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
-
}) : function(o, v) {
|
16
|
-
o["default"] = v;
|
17
|
-
});
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
-
if (mod && mod.__esModule) return mod;
|
20
|
-
var result = {};
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
-
__setModuleDefault(result, mod);
|
23
|
-
return result;
|
24
|
-
};
|
25
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
26
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
15
|
};
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.FunctionListToolCallPromptFormat = void 0;
|
30
|
-
exports.FunctionListToolCallPromptFormat = __importStar(require("./FunctionListToolCallPromptFormat.cjs"));
|
31
17
|
__exportStar(require("./TextGenerationToolCallModel.cjs"), exports);
|
32
18
|
__exportStar(require("./ToolCallGenerationEvent.cjs"), exports);
|
33
19
|
__exportStar(require("./ToolCallGenerationModel.cjs"), exports);
|
@@ -1,70 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.instruction = exports.text = void 0;
|
4
|
-
const nanoid_1 = require("nanoid");
|
5
|
-
const zod_1 = require("zod");
|
6
|
-
const ZodSchema_js_1 = require("../../core/schema/ZodSchema.cjs");
|
7
|
-
const parseJSON_js_1 = require("../../core/schema/parseJSON.cjs");
|
8
|
-
const functionSchema = new ZodSchema_js_1.ZodSchema(zod_1.z.object({
|
9
|
-
function: zod_1.z.string(),
|
10
|
-
parameters: zod_1.z.any(),
|
11
|
-
}));
|
12
|
-
const DEFAULT_FUNCTION_CALL_PROMPT = [
|
13
|
-
``,
|
14
|
-
`Select the most suitable function and parameters ` +
|
15
|
-
`from the list of available functions below, based on the user's input. ` +
|
16
|
-
`Provide your response in JSON format.`,
|
17
|
-
``,
|
18
|
-
`Available functions:`,
|
19
|
-
].join("\n");
|
20
|
-
function text({ functionCallPrompt = DEFAULT_FUNCTION_CALL_PROMPT, baseFormat, } = {}) {
|
21
|
-
return {
|
22
|
-
createPrompt(instruction, tool) {
|
23
|
-
const instructionWithFunctionCall = [
|
24
|
-
instruction,
|
25
|
-
functionCallPrompt,
|
26
|
-
`${tool.name}:`,
|
27
|
-
` description: ${tool.description ?? ""}`,
|
28
|
-
` parameters: ${JSON.stringify(tool.parameters.getJsonSchema())}`,
|
29
|
-
``,
|
30
|
-
].join("\n");
|
31
|
-
return (baseFormat?.format(instructionWithFunctionCall) ??
|
32
|
-
// handled by signature overloading:
|
33
|
-
instructionWithFunctionCall); // eslint-disable-line @typescript-eslint/no-explicit-any
|
34
|
-
},
|
35
|
-
extractToolCall(response) {
|
36
|
-
const json = (0, parseJSON_js_1.parseJSON)({ text: response, schema: functionSchema });
|
37
|
-
return {
|
38
|
-
id: (0, nanoid_1.nanoid)(),
|
39
|
-
args: json.parameters,
|
40
|
-
};
|
41
|
-
},
|
42
|
-
};
|
43
|
-
}
|
44
|
-
exports.text = text;
|
45
|
-
function instruction({ functionCallPrompt = DEFAULT_FUNCTION_CALL_PROMPT, baseFormat, }) {
|
46
|
-
return {
|
47
|
-
createPrompt(instruction, tool) {
|
48
|
-
const instructionWithFunctionCall = [
|
49
|
-
instruction.instruction,
|
50
|
-
functionCallPrompt,
|
51
|
-
`${tool.name}:`,
|
52
|
-
` description: ${tool.description ?? ""}`,
|
53
|
-
` parameters: ${JSON.stringify(tool.parameters.getJsonSchema())}`,
|
54
|
-
``,
|
55
|
-
].join("\n");
|
56
|
-
return baseFormat.format({
|
57
|
-
...instruction,
|
58
|
-
instruction: instructionWithFunctionCall,
|
59
|
-
});
|
60
|
-
},
|
61
|
-
extractToolCall(response) {
|
62
|
-
const json = (0, parseJSON_js_1.parseJSON)({ text: response, schema: functionSchema });
|
63
|
-
return {
|
64
|
-
id: (0, nanoid_1.nanoid)(),
|
65
|
-
args: json.parameters,
|
66
|
-
};
|
67
|
-
},
|
68
|
-
};
|
69
|
-
}
|
70
|
-
exports.instruction = instruction;
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import { PromptFormat } from "../../model-function/PromptFormat.js";
|
2
|
-
import { InstructionPrompt } from "../../model-function/generate-text/prompt-format/InstructionPrompt.js";
|
3
|
-
import { ToolCallPromptFormat } from "./TextGenerationToolCallModel.js";
|
4
|
-
export declare function text(options?: {
|
5
|
-
functionCallPrompt?: string;
|
6
|
-
}): ToolCallPromptFormat<string, string>;
|
7
|
-
export declare function text<TARGET_PROMPT>({ functionCallPrompt, baseFormat, }: {
|
8
|
-
functionCallPrompt?: string;
|
9
|
-
baseFormat: PromptFormat<string, TARGET_PROMPT>;
|
10
|
-
}): ToolCallPromptFormat<string, TARGET_PROMPT>;
|
11
|
-
export declare function instruction<TARGET_PROMPT>({ functionCallPrompt, baseFormat, }: {
|
12
|
-
functionCallPrompt?: string;
|
13
|
-
baseFormat: PromptFormat<InstructionPrompt, TARGET_PROMPT>;
|
14
|
-
}): ToolCallPromptFormat<InstructionPrompt, TARGET_PROMPT>;
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import { nanoid } from "nanoid";
|
2
|
-
import { z } from "zod";
|
3
|
-
import { ZodSchema } from "../../core/schema/ZodSchema.js";
|
4
|
-
import { parseJSON } from "../../core/schema/parseJSON.js";
|
5
|
-
const functionSchema = new ZodSchema(z.object({
|
6
|
-
function: z.string(),
|
7
|
-
parameters: z.any(),
|
8
|
-
}));
|
9
|
-
const DEFAULT_FUNCTION_CALL_PROMPT = [
|
10
|
-
``,
|
11
|
-
`Select the most suitable function and parameters ` +
|
12
|
-
`from the list of available functions below, based on the user's input. ` +
|
13
|
-
`Provide your response in JSON format.`,
|
14
|
-
``,
|
15
|
-
`Available functions:`,
|
16
|
-
].join("\n");
|
17
|
-
export function text({ functionCallPrompt = DEFAULT_FUNCTION_CALL_PROMPT, baseFormat, } = {}) {
|
18
|
-
return {
|
19
|
-
createPrompt(instruction, tool) {
|
20
|
-
const instructionWithFunctionCall = [
|
21
|
-
instruction,
|
22
|
-
functionCallPrompt,
|
23
|
-
`${tool.name}:`,
|
24
|
-
` description: ${tool.description ?? ""}`,
|
25
|
-
` parameters: ${JSON.stringify(tool.parameters.getJsonSchema())}`,
|
26
|
-
``,
|
27
|
-
].join("\n");
|
28
|
-
return (baseFormat?.format(instructionWithFunctionCall) ??
|
29
|
-
// handled by signature overloading:
|
30
|
-
instructionWithFunctionCall); // eslint-disable-line @typescript-eslint/no-explicit-any
|
31
|
-
},
|
32
|
-
extractToolCall(response) {
|
33
|
-
const json = parseJSON({ text: response, schema: functionSchema });
|
34
|
-
return {
|
35
|
-
id: nanoid(),
|
36
|
-
args: json.parameters,
|
37
|
-
};
|
38
|
-
},
|
39
|
-
};
|
40
|
-
}
|
41
|
-
export function instruction({ functionCallPrompt = DEFAULT_FUNCTION_CALL_PROMPT, baseFormat, }) {
|
42
|
-
return {
|
43
|
-
createPrompt(instruction, tool) {
|
44
|
-
const instructionWithFunctionCall = [
|
45
|
-
instruction.instruction,
|
46
|
-
functionCallPrompt,
|
47
|
-
`${tool.name}:`,
|
48
|
-
` description: ${tool.description ?? ""}`,
|
49
|
-
` parameters: ${JSON.stringify(tool.parameters.getJsonSchema())}`,
|
50
|
-
``,
|
51
|
-
].join("\n");
|
52
|
-
return baseFormat.format({
|
53
|
-
...instruction,
|
54
|
-
instruction: instructionWithFunctionCall,
|
55
|
-
});
|
56
|
-
},
|
57
|
-
extractToolCall(response) {
|
58
|
-
const json = parseJSON({ text: response, schema: functionSchema });
|
59
|
-
return {
|
60
|
-
id: nanoid(),
|
61
|
-
args: json.parameters,
|
62
|
-
};
|
63
|
-
},
|
64
|
-
};
|
65
|
-
}
|