modelfusion 0.120.0 → 0.121.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/CHANGELOG.md +11 -0
- package/README.md +5 -5
- package/core/FunctionOptions.d.ts +7 -2
- package/core/executeFunction.cjs +1 -7
- package/core/executeFunction.d.ts +2 -2
- package/core/executeFunction.js +1 -7
- package/core/executeFunctionCall.cjs +3 -2
- package/core/executeFunctionCall.d.ts +2 -2
- package/core/executeFunctionCall.js +3 -2
- package/core/getFunctionCallLogger.cjs +22 -7
- package/core/getFunctionCallLogger.js +22 -7
- package/model-function/executeStandardCall.cjs +2 -2
- package/model-function/executeStandardCall.js +2 -2
- package/model-function/executeStreamCall.cjs +2 -2
- package/model-function/executeStreamCall.js +2 -2
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.cjs +78 -0
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.d.ts +35 -0
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.js +72 -0
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.test.cjs +60 -0
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.test.d.ts +1 -0
- package/model-function/generate-text/prompt-template/SynthiaPromptTemplate.test.js +58 -0
- package/model-function/generate-text/prompt-template/VicunaPromptTemplate.cjs +11 -13
- package/model-function/generate-text/prompt-template/VicunaPromptTemplate.d.ts +1 -1
- package/model-function/generate-text/prompt-template/VicunaPromptTemplate.js +11 -13
- package/model-function/generate-text/prompt-template/index.cjs +2 -1
- package/model-function/generate-text/prompt-template/index.d.ts +1 -0
- package/model-function/generate-text/prompt-template/index.js +1 -0
- package/model-provider/llamacpp/LlamaCppPrompt.cjs +3 -1
- package/model-provider/llamacpp/LlamaCppPrompt.d.ts +1 -0
- package/model-provider/llamacpp/LlamaCppPrompt.js +2 -0
- package/model-provider/ollama/OllamaCompletionPrompt.cjs +3 -1
- package/model-provider/ollama/OllamaCompletionPrompt.d.ts +1 -0
- package/model-provider/ollama/OllamaCompletionPrompt.js +2 -0
- package/package.json +1 -1
- package/tool/Tool.d.ts +2 -2
- package/tool/execute-tool/executeTool.cjs +3 -2
- package/tool/execute-tool/executeTool.js +3 -2
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v0.121.0 - 2024-01-09
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Synthia prompt template
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- **breaking change**: Renamed `parentCallId` function parameter to `callId` to enable options pass-through.
|
12
|
+
- Better output filtering for `detailed-object` log format (e.g. via `modelfusion.setLogFormat("detailed-object")`)
|
13
|
+
|
3
14
|
## v0.120.0 - 2024-01-09
|
4
15
|
|
5
16
|
### Added
|
package/README.md
CHANGED
@@ -473,13 +473,13 @@ const textStream = await streamText(
|
|
473
473
|
|
474
474
|
| Prompt Template | Text Prompt | Instruction Prompt | Chat Prompt |
|
475
475
|
| ---------------- | ----------- | ------------------ | ----------- |
|
476
|
-
|
|
477
|
-
| Llama 2 | ✅ | ✅ | ✅ |
|
476
|
+
| Alpaca | ✅ | ✅ | ❌ |
|
478
477
|
| ChatML | ✅ | ✅ | ✅ |
|
479
|
-
|
|
478
|
+
| Llama 2 | ✅ | ✅ | ✅ |
|
480
479
|
| Mistral Instruct | ✅ | ✅ | ✅ |
|
481
|
-
|
|
482
|
-
|
|
480
|
+
| NeuralChat | ✅ | ✅ | ✅ |
|
481
|
+
| Synthia | ✅ | ✅ | ✅ |
|
482
|
+
| Vicuna | ✅ | ✅ | ✅ |
|
483
483
|
| Generic Text | ✅ | ✅ | ✅ |
|
484
484
|
|
485
485
|
### [Image Generation Prompt Templates](https://modelfusion.dev/guide/function/generate-image/prompt-format)
|
@@ -31,14 +31,19 @@ export type FunctionOptions = {
|
|
31
31
|
run?: Run;
|
32
32
|
/**
|
33
33
|
* Unique identifier of the call id of the parent function. Used in events and logging.
|
34
|
+
*
|
35
|
+
* It has the same name as the `callId` in `FunctionCallOptions` to allow for easy
|
36
|
+
* propagation of the call id.
|
37
|
+
*
|
38
|
+
* However, in the `FunctionOptions`, it is the call ID for the parent call, and it is optional.
|
34
39
|
*/
|
35
|
-
|
40
|
+
callId?: string | undefined;
|
36
41
|
};
|
37
42
|
/**
|
38
43
|
* Extended options that are passed to models when functions are called. They are passed
|
39
44
|
* into e.g. API providers to create custom headers.
|
40
45
|
*/
|
41
|
-
export type FunctionCallOptions = Omit<FunctionOptions, "
|
46
|
+
export type FunctionCallOptions = Omit<FunctionOptions, "callId"> & {
|
42
47
|
functionType: string;
|
43
48
|
callId: string;
|
44
49
|
};
|
package/core/executeFunction.cjs
CHANGED
@@ -7,13 +7,7 @@ async function executeFunction(fn, input, options) {
|
|
7
7
|
options,
|
8
8
|
input,
|
9
9
|
functionType: "execute-function",
|
10
|
-
execute: async (options) => fn(input,
|
11
|
-
// omit functionId
|
12
|
-
logging: options?.logging,
|
13
|
-
observers: options?.observers,
|
14
|
-
run: options?.run,
|
15
|
-
parentCallId: options?.parentCallId,
|
16
|
-
}),
|
10
|
+
execute: async (options) => fn(input, options),
|
17
11
|
});
|
18
12
|
}
|
19
13
|
exports.executeFunction = executeFunction;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import { FunctionOptions } from "./FunctionOptions.js";
|
2
|
-
export declare function executeFunction<INPUT, OUTPUT>(fn: (input: INPUT, options
|
1
|
+
import { FunctionCallOptions, FunctionOptions } from "./FunctionOptions.js";
|
2
|
+
export declare function executeFunction<INPUT, OUTPUT>(fn: (input: INPUT, options: FunctionCallOptions) => PromiseLike<OUTPUT>, input: INPUT, options?: FunctionOptions): Promise<OUTPUT>;
|
package/core/executeFunction.js
CHANGED
@@ -4,12 +4,6 @@ export async function executeFunction(fn, input, options) {
|
|
4
4
|
options,
|
5
5
|
input,
|
6
6
|
functionType: "execute-function",
|
7
|
-
execute: async (options) => fn(input,
|
8
|
-
// omit functionId
|
9
|
-
logging: options?.logging,
|
10
|
-
observers: options?.observers,
|
11
|
-
run: options?.run,
|
12
|
-
parentCallId: options?.parentCallId,
|
13
|
-
}),
|
7
|
+
execute: async (options) => fn(input, options),
|
14
8
|
});
|
15
9
|
}
|
@@ -25,7 +25,7 @@ async function executeFunctionCall({ options, input, functionType, execute, inpu
|
|
25
25
|
const startMetadata = {
|
26
26
|
functionType,
|
27
27
|
callId: `call-${(0, nanoid_1.nanoid)()}`,
|
28
|
-
parentCallId: options?.
|
28
|
+
parentCallId: options?.callId,
|
29
29
|
runId: run?.runId,
|
30
30
|
sessionId: run?.sessionId,
|
31
31
|
userId: run?.userId,
|
@@ -39,11 +39,12 @@ async function executeFunctionCall({ options, input, functionType, execute, inpu
|
|
39
39
|
...startMetadata,
|
40
40
|
});
|
41
41
|
const result = await (0, runSafe_js_1.runSafe)(() => execute({
|
42
|
+
functionType,
|
42
43
|
functionId: options?.functionId,
|
44
|
+
callId: startMetadata.callId,
|
43
45
|
logging: options?.logging,
|
44
46
|
observers: options?.observers,
|
45
47
|
run,
|
46
|
-
parentCallId: startMetadata.callId,
|
47
48
|
}));
|
48
49
|
const finishMetadata = {
|
49
50
|
eventType: "finished",
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { FunctionOptions } from "./FunctionOptions.js";
|
1
|
+
import { FunctionCallOptions, FunctionOptions } from "./FunctionOptions.js";
|
2
2
|
import { FunctionEvent } from "./FunctionEvent.js";
|
3
3
|
export declare function executeFunctionCall<VALUE>({ options, input, functionType, execute, inputPropertyName, outputPropertyName, }: {
|
4
4
|
options?: FunctionOptions;
|
5
5
|
input: unknown;
|
6
6
|
functionType: FunctionEvent["functionType"];
|
7
|
-
execute: (options
|
7
|
+
execute: (options: FunctionCallOptions) => PromiseLike<VALUE>;
|
8
8
|
inputPropertyName?: string;
|
9
9
|
outputPropertyName?: string;
|
10
10
|
}): Promise<VALUE>;
|
@@ -22,7 +22,7 @@ export async function executeFunctionCall({ options, input, functionType, execut
|
|
22
22
|
const startMetadata = {
|
23
23
|
functionType,
|
24
24
|
callId: `call-${createId()}`,
|
25
|
-
parentCallId: options?.
|
25
|
+
parentCallId: options?.callId,
|
26
26
|
runId: run?.runId,
|
27
27
|
sessionId: run?.sessionId,
|
28
28
|
userId: run?.userId,
|
@@ -36,11 +36,12 @@ export async function executeFunctionCall({ options, input, functionType, execut
|
|
36
36
|
...startMetadata,
|
37
37
|
});
|
38
38
|
const result = await runSafe(() => execute({
|
39
|
+
functionType,
|
39
40
|
functionId: options?.functionId,
|
41
|
+
callId: startMetadata.callId,
|
40
42
|
logging: options?.logging,
|
41
43
|
observers: options?.observers,
|
42
44
|
run,
|
43
|
-
parentCallId: startMetadata.callId,
|
44
45
|
}));
|
45
46
|
const finishMetadata = {
|
46
47
|
eventType: "finished",
|
@@ -51,15 +51,30 @@ const detailedObjectObserver = {
|
|
51
51
|
if (obj instanceof Date || typeof obj === "string") {
|
52
52
|
return obj;
|
53
53
|
}
|
54
|
+
if (Array.isArray(obj)) {
|
55
|
+
return obj.map((item) => cleanObject(item));
|
56
|
+
}
|
54
57
|
if (obj !== null && typeof obj === "object") {
|
55
58
|
return Object.fromEntries(Object.entries(obj)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
60
|
+
.map(([k, v]) => {
|
61
|
+
if (v === undefined) {
|
62
|
+
return [k, undefined];
|
63
|
+
}
|
64
|
+
else if (v instanceof Buffer) {
|
65
|
+
return [k, "omitted<Buffer>"];
|
66
|
+
}
|
67
|
+
else if (Array.isArray(v) &&
|
68
|
+
v.length > 20 &&
|
69
|
+
v.every((v) => typeof v === "number")) {
|
70
|
+
return [k, "omitted<Array<number>>"];
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
return [k, cleanObject(v)];
|
74
|
+
}
|
75
|
+
})
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
77
|
+
.filter(([_, v]) => v !== undefined));
|
63
78
|
}
|
64
79
|
return obj;
|
65
80
|
}
|
@@ -47,15 +47,30 @@ const detailedObjectObserver = {
|
|
47
47
|
if (obj instanceof Date || typeof obj === "string") {
|
48
48
|
return obj;
|
49
49
|
}
|
50
|
+
if (Array.isArray(obj)) {
|
51
|
+
return obj.map((item) => cleanObject(item));
|
52
|
+
}
|
50
53
|
if (obj !== null && typeof obj === "object") {
|
51
54
|
return Object.fromEntries(Object.entries(obj)
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
56
|
+
.map(([k, v]) => {
|
57
|
+
if (v === undefined) {
|
58
|
+
return [k, undefined];
|
59
|
+
}
|
60
|
+
else if (v instanceof Buffer) {
|
61
|
+
return [k, "omitted<Buffer>"];
|
62
|
+
}
|
63
|
+
else if (Array.isArray(v) &&
|
64
|
+
v.length > 20 &&
|
65
|
+
v.every((v) => typeof v === "number")) {
|
66
|
+
return [k, "omitted<Array<number>>"];
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
return [k, cleanObject(v)];
|
70
|
+
}
|
71
|
+
})
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
73
|
+
.filter(([_, v]) => v !== undefined));
|
59
74
|
}
|
60
75
|
return obj;
|
61
76
|
}
|
@@ -27,7 +27,7 @@ async function executeStandardCall({ model, options, input, functionType, genera
|
|
27
27
|
const startMetadata = {
|
28
28
|
functionType,
|
29
29
|
callId: `call-${(0, nanoid_1.nanoid)()}`,
|
30
|
-
parentCallId: options?.
|
30
|
+
parentCallId: options?.callId,
|
31
31
|
runId: run?.runId,
|
32
32
|
sessionId: run?.sessionId,
|
33
33
|
userId: run?.userId,
|
@@ -43,7 +43,7 @@ async function executeStandardCall({ model, options, input, functionType, genera
|
|
43
43
|
...startMetadata,
|
44
44
|
});
|
45
45
|
const result = await (0, runSafe_js_1.runSafe)(() => generateResponse({
|
46
|
-
functionType
|
46
|
+
functionType,
|
47
47
|
functionId: options?.functionId,
|
48
48
|
callId: startMetadata.callId,
|
49
49
|
logging: options?.logging,
|
@@ -24,7 +24,7 @@ export async function executeStandardCall({ model, options, input, functionType,
|
|
24
24
|
const startMetadata = {
|
25
25
|
functionType,
|
26
26
|
callId: `call-${createId()}`,
|
27
|
-
parentCallId: options?.
|
27
|
+
parentCallId: options?.callId,
|
28
28
|
runId: run?.runId,
|
29
29
|
sessionId: run?.sessionId,
|
30
30
|
userId: run?.userId,
|
@@ -40,7 +40,7 @@ export async function executeStandardCall({ model, options, input, functionType,
|
|
40
40
|
...startMetadata,
|
41
41
|
});
|
42
42
|
const result = await runSafe(() => generateResponse({
|
43
|
-
functionType
|
43
|
+
functionType,
|
44
44
|
functionId: options?.functionId,
|
45
45
|
callId: startMetadata.callId,
|
46
46
|
logging: options?.logging,
|
@@ -28,7 +28,7 @@ async function executeStreamCall({ model, options, input, functionType, startStr
|
|
28
28
|
const startMetadata = {
|
29
29
|
functionType,
|
30
30
|
callId: `call-${(0, nanoid_1.nanoid)()}`,
|
31
|
-
parentCallId: options?.
|
31
|
+
parentCallId: options?.callId,
|
32
32
|
runId: run?.runId,
|
33
33
|
sessionId: run?.sessionId,
|
34
34
|
userId: run?.userId,
|
@@ -45,7 +45,7 @@ async function executeStreamCall({ model, options, input, functionType, startStr
|
|
45
45
|
});
|
46
46
|
const result = await (0, runSafe_js_1.runSafe)(async () => {
|
47
47
|
const deltaIterable = await startStream({
|
48
|
-
functionType
|
48
|
+
functionType,
|
49
49
|
functionId: options?.functionId,
|
50
50
|
callId: startMetadata.callId,
|
51
51
|
logging: options?.logging,
|
@@ -25,7 +25,7 @@ export async function executeStreamCall({ model, options, input, functionType, s
|
|
25
25
|
const startMetadata = {
|
26
26
|
functionType,
|
27
27
|
callId: `call-${createId()}`,
|
28
|
-
parentCallId: options?.
|
28
|
+
parentCallId: options?.callId,
|
29
29
|
runId: run?.runId,
|
30
30
|
sessionId: run?.sessionId,
|
31
31
|
userId: run?.userId,
|
@@ -42,7 +42,7 @@ export async function executeStreamCall({ model, options, input, functionType, s
|
|
42
42
|
});
|
43
43
|
const result = await runSafe(async () => {
|
44
44
|
const deltaIterable = await startStream({
|
45
|
-
functionType
|
45
|
+
functionType,
|
46
46
|
functionId: options?.functionId,
|
47
47
|
callId: startMetadata.callId,
|
48
48
|
logging: options?.logging,
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.chat = exports.instruction = exports.text = void 0;
|
4
|
+
const ContentPart_js_1 = require("./ContentPart.cjs");
|
5
|
+
const InvalidPromptError_js_1 = require("./InvalidPromptError.cjs");
|
6
|
+
/**
|
7
|
+
* Formats a text prompt as a Synthia text prompt.
|
8
|
+
*
|
9
|
+
* Synthia prompt template:
|
10
|
+
* ```
|
11
|
+
* USER: text
|
12
|
+
* ASSISTANT:
|
13
|
+
* ```
|
14
|
+
*/
|
15
|
+
const text = () => ({
|
16
|
+
stopSequences: [],
|
17
|
+
format: (prompt) => `USER: ${prompt}\nASSISTANT: `,
|
18
|
+
});
|
19
|
+
exports.text = text;
|
20
|
+
/**
|
21
|
+
* Formats an instruction prompt as a Synthia prompt.
|
22
|
+
*
|
23
|
+
* Synthia prompt template:
|
24
|
+
* ```
|
25
|
+
* SYSTEM: system message
|
26
|
+
* USER: instruction
|
27
|
+
* ASSISTANT: response prefix
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
const instruction = () => ({
|
31
|
+
stopSequences: [`\nUSER:`],
|
32
|
+
format(prompt) {
|
33
|
+
let text = prompt.system != null ? `SYSTEM: ${prompt.system}\n` : "";
|
34
|
+
text += `USER: ${(0, ContentPart_js_1.validateContentIsString)(prompt.instruction, prompt)}\n`;
|
35
|
+
text += `ASSISTANT: ${prompt.responsePrefix ?? ""}`;
|
36
|
+
return text;
|
37
|
+
},
|
38
|
+
});
|
39
|
+
exports.instruction = instruction;
|
40
|
+
/**
|
41
|
+
* Formats a chat prompt as a Synthia prompt.
|
42
|
+
*
|
43
|
+
* Synthia prompt template:
|
44
|
+
* ```
|
45
|
+
* SYSTEM: system message
|
46
|
+
* USER: user message
|
47
|
+
* ASSISTANT: assistant message
|
48
|
+
* ```
|
49
|
+
*/
|
50
|
+
const chat = () => ({
|
51
|
+
format(prompt) {
|
52
|
+
let text = prompt.system != null ? `SYSTEM: ${prompt.system}\n` : "";
|
53
|
+
for (const { role, content } of prompt.messages) {
|
54
|
+
switch (role) {
|
55
|
+
case "user": {
|
56
|
+
text += `USER: ${(0, ContentPart_js_1.validateContentIsString)(content, prompt)}\n`;
|
57
|
+
break;
|
58
|
+
}
|
59
|
+
case "assistant": {
|
60
|
+
text += `ASSISTANT: ${(0, ContentPart_js_1.validateContentIsString)(content, prompt)}\n`;
|
61
|
+
break;
|
62
|
+
}
|
63
|
+
case "tool": {
|
64
|
+
throw new InvalidPromptError_js_1.InvalidPromptError("Tool messages are not supported.", prompt);
|
65
|
+
}
|
66
|
+
default: {
|
67
|
+
const _exhaustiveCheck = role;
|
68
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
// Assistant message prefix:
|
73
|
+
text += `ASSISTANT: `;
|
74
|
+
return text;
|
75
|
+
},
|
76
|
+
stopSequences: [`\nUSER:`],
|
77
|
+
});
|
78
|
+
exports.chat = chat;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { TextGenerationPromptTemplate } from "../TextGenerationPromptTemplate.js";
|
2
|
+
import { ChatPrompt } from "./ChatPrompt.js";
|
3
|
+
import { InstructionPrompt } from "./InstructionPrompt.js";
|
4
|
+
/**
|
5
|
+
* Formats a text prompt as a Synthia text prompt.
|
6
|
+
*
|
7
|
+
* Synthia prompt template:
|
8
|
+
* ```
|
9
|
+
* USER: text
|
10
|
+
* ASSISTANT:
|
11
|
+
* ```
|
12
|
+
*/
|
13
|
+
export declare const text: () => TextGenerationPromptTemplate<string, string>;
|
14
|
+
/**
|
15
|
+
* Formats an instruction prompt as a Synthia prompt.
|
16
|
+
*
|
17
|
+
* Synthia prompt template:
|
18
|
+
* ```
|
19
|
+
* SYSTEM: system message
|
20
|
+
* USER: instruction
|
21
|
+
* ASSISTANT: response prefix
|
22
|
+
* ```
|
23
|
+
*/
|
24
|
+
export declare const instruction: () => TextGenerationPromptTemplate<InstructionPrompt, string>;
|
25
|
+
/**
|
26
|
+
* Formats a chat prompt as a Synthia prompt.
|
27
|
+
*
|
28
|
+
* Synthia prompt template:
|
29
|
+
* ```
|
30
|
+
* SYSTEM: system message
|
31
|
+
* USER: user message
|
32
|
+
* ASSISTANT: assistant message
|
33
|
+
* ```
|
34
|
+
*/
|
35
|
+
export declare const chat: () => TextGenerationPromptTemplate<ChatPrompt, string>;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { validateContentIsString } from "./ContentPart.js";
|
2
|
+
import { InvalidPromptError } from "./InvalidPromptError.js";
|
3
|
+
/**
|
4
|
+
* Formats a text prompt as a Synthia text prompt.
|
5
|
+
*
|
6
|
+
* Synthia prompt template:
|
7
|
+
* ```
|
8
|
+
* USER: text
|
9
|
+
* ASSISTANT:
|
10
|
+
* ```
|
11
|
+
*/
|
12
|
+
export const text = () => ({
|
13
|
+
stopSequences: [],
|
14
|
+
format: (prompt) => `USER: ${prompt}\nASSISTANT: `,
|
15
|
+
});
|
16
|
+
/**
|
17
|
+
* Formats an instruction prompt as a Synthia prompt.
|
18
|
+
*
|
19
|
+
* Synthia prompt template:
|
20
|
+
* ```
|
21
|
+
* SYSTEM: system message
|
22
|
+
* USER: instruction
|
23
|
+
* ASSISTANT: response prefix
|
24
|
+
* ```
|
25
|
+
*/
|
26
|
+
export const instruction = () => ({
|
27
|
+
stopSequences: [`\nUSER:`],
|
28
|
+
format(prompt) {
|
29
|
+
let text = prompt.system != null ? `SYSTEM: ${prompt.system}\n` : "";
|
30
|
+
text += `USER: ${validateContentIsString(prompt.instruction, prompt)}\n`;
|
31
|
+
text += `ASSISTANT: ${prompt.responsePrefix ?? ""}`;
|
32
|
+
return text;
|
33
|
+
},
|
34
|
+
});
|
35
|
+
/**
|
36
|
+
* Formats a chat prompt as a Synthia prompt.
|
37
|
+
*
|
38
|
+
* Synthia prompt template:
|
39
|
+
* ```
|
40
|
+
* SYSTEM: system message
|
41
|
+
* USER: user message
|
42
|
+
* ASSISTANT: assistant message
|
43
|
+
* ```
|
44
|
+
*/
|
45
|
+
export const chat = () => ({
|
46
|
+
format(prompt) {
|
47
|
+
let text = prompt.system != null ? `SYSTEM: ${prompt.system}\n` : "";
|
48
|
+
for (const { role, content } of prompt.messages) {
|
49
|
+
switch (role) {
|
50
|
+
case "user": {
|
51
|
+
text += `USER: ${validateContentIsString(content, prompt)}\n`;
|
52
|
+
break;
|
53
|
+
}
|
54
|
+
case "assistant": {
|
55
|
+
text += `ASSISTANT: ${validateContentIsString(content, prompt)}\n`;
|
56
|
+
break;
|
57
|
+
}
|
58
|
+
case "tool": {
|
59
|
+
throw new InvalidPromptError("Tool messages are not supported.", prompt);
|
60
|
+
}
|
61
|
+
default: {
|
62
|
+
const _exhaustiveCheck = role;
|
63
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
// Assistant message prefix:
|
68
|
+
text += `ASSISTANT: `;
|
69
|
+
return text;
|
70
|
+
},
|
71
|
+
stopSequences: [`\nUSER:`],
|
72
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const SynthiaPromptTemplate_js_1 = require("./SynthiaPromptTemplate.cjs");
|
4
|
+
describe("text prompt", () => {
|
5
|
+
it("should format prompt", () => {
|
6
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.text)().format("prompt");
|
7
|
+
expect(prompt).toMatchSnapshot();
|
8
|
+
});
|
9
|
+
});
|
10
|
+
describe("instruction prompt", () => {
|
11
|
+
it("should format prompt with instruction", () => {
|
12
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.instruction)().format({
|
13
|
+
instruction: "instruction",
|
14
|
+
});
|
15
|
+
expect(prompt).toMatchSnapshot();
|
16
|
+
});
|
17
|
+
it("should format prompt with system and instruction", () => {
|
18
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.instruction)().format({
|
19
|
+
system: "system",
|
20
|
+
instruction: "instruction",
|
21
|
+
});
|
22
|
+
expect(prompt).toMatchSnapshot();
|
23
|
+
});
|
24
|
+
it("should format prompt with instruction and response prefix", () => {
|
25
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.instruction)().format({
|
26
|
+
instruction: "instruction",
|
27
|
+
responsePrefix: "response prefix",
|
28
|
+
});
|
29
|
+
expect(prompt).toMatchSnapshot();
|
30
|
+
});
|
31
|
+
});
|
32
|
+
describe("chat prompt", () => {
|
33
|
+
it("should format prompt with user message", () => {
|
34
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.chat)().format({
|
35
|
+
messages: [{ role: "user", content: "user message" }],
|
36
|
+
});
|
37
|
+
expect(prompt).toMatchSnapshot();
|
38
|
+
});
|
39
|
+
it("should format prompt with user-assistant-user messages", () => {
|
40
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.chat)().format({
|
41
|
+
messages: [
|
42
|
+
{ role: "user", content: "1st user message" },
|
43
|
+
{ role: "assistant", content: "assistant message" },
|
44
|
+
{ role: "user", content: "2nd user message" },
|
45
|
+
],
|
46
|
+
});
|
47
|
+
expect(prompt).toMatchSnapshot();
|
48
|
+
});
|
49
|
+
it("should format prompt with system message and user-assistant-user messages", () => {
|
50
|
+
const prompt = (0, SynthiaPromptTemplate_js_1.chat)().format({
|
51
|
+
system: "you are a chatbot",
|
52
|
+
messages: [
|
53
|
+
{ role: "user", content: "1st user message" },
|
54
|
+
{ role: "assistant", content: "assistant message" },
|
55
|
+
{ role: "user", content: "2nd user message" },
|
56
|
+
],
|
57
|
+
});
|
58
|
+
expect(prompt).toMatchSnapshot();
|
59
|
+
});
|
60
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import { chat, instruction, text } from "./SynthiaPromptTemplate.js";
|
2
|
+
describe("text prompt", () => {
|
3
|
+
it("should format prompt", () => {
|
4
|
+
const prompt = text().format("prompt");
|
5
|
+
expect(prompt).toMatchSnapshot();
|
6
|
+
});
|
7
|
+
});
|
8
|
+
describe("instruction prompt", () => {
|
9
|
+
it("should format prompt with instruction", () => {
|
10
|
+
const prompt = instruction().format({
|
11
|
+
instruction: "instruction",
|
12
|
+
});
|
13
|
+
expect(prompt).toMatchSnapshot();
|
14
|
+
});
|
15
|
+
it("should format prompt with system and instruction", () => {
|
16
|
+
const prompt = instruction().format({
|
17
|
+
system: "system",
|
18
|
+
instruction: "instruction",
|
19
|
+
});
|
20
|
+
expect(prompt).toMatchSnapshot();
|
21
|
+
});
|
22
|
+
it("should format prompt with instruction and response prefix", () => {
|
23
|
+
const prompt = instruction().format({
|
24
|
+
instruction: "instruction",
|
25
|
+
responsePrefix: "response prefix",
|
26
|
+
});
|
27
|
+
expect(prompt).toMatchSnapshot();
|
28
|
+
});
|
29
|
+
});
|
30
|
+
describe("chat prompt", () => {
|
31
|
+
it("should format prompt with user message", () => {
|
32
|
+
const prompt = chat().format({
|
33
|
+
messages: [{ role: "user", content: "user message" }],
|
34
|
+
});
|
35
|
+
expect(prompt).toMatchSnapshot();
|
36
|
+
});
|
37
|
+
it("should format prompt with user-assistant-user messages", () => {
|
38
|
+
const prompt = chat().format({
|
39
|
+
messages: [
|
40
|
+
{ role: "user", content: "1st user message" },
|
41
|
+
{ role: "assistant", content: "assistant message" },
|
42
|
+
{ role: "user", content: "2nd user message" },
|
43
|
+
],
|
44
|
+
});
|
45
|
+
expect(prompt).toMatchSnapshot();
|
46
|
+
});
|
47
|
+
it("should format prompt with system message and user-assistant-user messages", () => {
|
48
|
+
const prompt = chat().format({
|
49
|
+
system: "you are a chatbot",
|
50
|
+
messages: [
|
51
|
+
{ role: "user", content: "1st user message" },
|
52
|
+
{ role: "assistant", content: "assistant message" },
|
53
|
+
{ role: "user", content: "2nd user message" },
|
54
|
+
],
|
55
|
+
});
|
56
|
+
expect(prompt).toMatchSnapshot();
|
57
|
+
});
|
58
|
+
});
|
@@ -25,19 +25,17 @@ exports.text = text;
|
|
25
25
|
/**
|
26
26
|
* Formats an instruction prompt as a Vicuna prompt.
|
27
27
|
*/
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
};
|
40
|
-
}
|
28
|
+
const instruction = () => ({
|
29
|
+
stopSequences: [`\nUSER:`],
|
30
|
+
format(prompt) {
|
31
|
+
let text = prompt.system != null
|
32
|
+
? `${prompt.system}\n\n`
|
33
|
+
: `${DEFAULT_SYSTEM_MESSAGE}\n\n`;
|
34
|
+
text += `USER: ${(0, ContentPart_js_1.validateContentIsString)(prompt.instruction, prompt)}\n`;
|
35
|
+
text += `ASSISTANT: `;
|
36
|
+
return text;
|
37
|
+
},
|
38
|
+
});
|
41
39
|
exports.instruction = instruction;
|
42
40
|
/**
|
43
41
|
* Formats a chat prompt as a Vicuna prompt.
|
@@ -8,7 +8,7 @@ export declare function text(): TextGenerationPromptTemplate<string, string>;
|
|
8
8
|
/**
|
9
9
|
* Formats an instruction prompt as a Vicuna prompt.
|
10
10
|
*/
|
11
|
-
export declare
|
11
|
+
export declare const instruction: () => TextGenerationPromptTemplate<InstructionPrompt, string>;
|
12
12
|
/**
|
13
13
|
* Formats a chat prompt as a Vicuna prompt.
|
14
14
|
*
|
@@ -21,19 +21,17 @@ export function text() {
|
|
21
21
|
/**
|
22
22
|
* Formats an instruction prompt as a Vicuna prompt.
|
23
23
|
*/
|
24
|
-
export
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
};
|
36
|
-
}
|
24
|
+
export const instruction = () => ({
|
25
|
+
stopSequences: [`\nUSER:`],
|
26
|
+
format(prompt) {
|
27
|
+
let text = prompt.system != null
|
28
|
+
? `${prompt.system}\n\n`
|
29
|
+
: `${DEFAULT_SYSTEM_MESSAGE}\n\n`;
|
30
|
+
text += `USER: ${validateContentIsString(prompt.instruction, prompt)}\n`;
|
31
|
+
text += `ASSISTANT: `;
|
32
|
+
return text;
|
33
|
+
},
|
34
|
+
});
|
37
35
|
/**
|
38
36
|
* Formats a chat prompt as a Vicuna prompt.
|
39
37
|
*
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
27
27
|
};
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
-
exports.VicunaPrompt = exports.TextPrompt = exports.NeuralChatPrompt = exports.MistralInstructPrompt = exports.Llama2Prompt = exports.ChatMLPrompt = exports.AlpacaPrompt = void 0;
|
29
|
+
exports.VicunaPrompt = exports.TextPrompt = exports.SynthiaPrompt = exports.NeuralChatPrompt = exports.MistralInstructPrompt = exports.Llama2Prompt = exports.ChatMLPrompt = exports.AlpacaPrompt = void 0;
|
30
30
|
exports.AlpacaPrompt = __importStar(require("./AlpacaPromptTemplate.cjs"));
|
31
31
|
exports.ChatMLPrompt = __importStar(require("./ChatMLPromptTemplate.cjs"));
|
32
32
|
__exportStar(require("./ChatPrompt.cjs"), exports);
|
@@ -37,6 +37,7 @@ exports.Llama2Prompt = __importStar(require("./Llama2PromptTemplate.cjs"));
|
|
37
37
|
exports.MistralInstructPrompt = __importStar(require("./MistralInstructPromptTemplate.cjs"));
|
38
38
|
exports.NeuralChatPrompt = __importStar(require("./NeuralChatPromptTemplate.cjs"));
|
39
39
|
__exportStar(require("./PromptTemplateProvider.cjs"), exports);
|
40
|
+
exports.SynthiaPrompt = __importStar(require("./SynthiaPromptTemplate.cjs"));
|
40
41
|
exports.TextPrompt = __importStar(require("./TextPromptTemplate.cjs"));
|
41
42
|
exports.VicunaPrompt = __importStar(require("./VicunaPromptTemplate.cjs"));
|
42
43
|
__exportStar(require("./trimChatPrompt.cjs"), exports);
|
@@ -8,6 +8,7 @@ export * as Llama2Prompt from "./Llama2PromptTemplate.js";
|
|
8
8
|
export * as MistralInstructPrompt from "./MistralInstructPromptTemplate.js";
|
9
9
|
export * as NeuralChatPrompt from "./NeuralChatPromptTemplate.js";
|
10
10
|
export * from "./PromptTemplateProvider.js";
|
11
|
+
export * as SynthiaPrompt from "./SynthiaPromptTemplate.js";
|
11
12
|
export * as TextPrompt from "./TextPromptTemplate.js";
|
12
13
|
export * as VicunaPrompt from "./VicunaPromptTemplate.js";
|
13
14
|
export * from "./trimChatPrompt.js";
|
@@ -8,6 +8,7 @@ export * as Llama2Prompt from "./Llama2PromptTemplate.js";
|
|
8
8
|
export * as MistralInstructPrompt from "./MistralInstructPromptTemplate.js";
|
9
9
|
export * as NeuralChatPrompt from "./NeuralChatPromptTemplate.js";
|
10
10
|
export * from "./PromptTemplateProvider.js";
|
11
|
+
export * as SynthiaPrompt from "./SynthiaPromptTemplate.js";
|
11
12
|
export * as TextPrompt from "./TextPromptTemplate.js";
|
12
13
|
export * as VicunaPrompt from "./VicunaPromptTemplate.js";
|
13
14
|
export * from "./trimChatPrompt.js";
|
@@ -23,12 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.BakLLaVA1 = exports.Vicuna = exports.Alpaca = exports.NeuralChat = exports.Llama2 = exports.ChatML = exports.Mistral = exports.Text = exports.asLlamaCppTextPromptTemplateProvider = exports.asLlamaCppPromptTemplate = void 0;
|
26
|
+
exports.BakLLaVA1 = exports.Vicuna = exports.Synthia = exports.Alpaca = exports.NeuralChat = exports.Llama2 = exports.ChatML = exports.Mistral = exports.Text = exports.asLlamaCppTextPromptTemplateProvider = exports.asLlamaCppPromptTemplate = void 0;
|
27
27
|
const alpacaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/AlpacaPromptTemplate.cjs"));
|
28
28
|
const chatMlPrompt = __importStar(require("../../model-function/generate-text/prompt-template/ChatMLPromptTemplate.cjs"));
|
29
29
|
const llama2Prompt = __importStar(require("../../model-function/generate-text/prompt-template/Llama2PromptTemplate.cjs"));
|
30
30
|
const mistralPrompt = __importStar(require("../../model-function/generate-text/prompt-template/MistralInstructPromptTemplate.cjs"));
|
31
31
|
const neuralChatPrompt = __importStar(require("../../model-function/generate-text/prompt-template/NeuralChatPromptTemplate.cjs"));
|
32
|
+
const synthiaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/SynthiaPromptTemplate.cjs"));
|
32
33
|
const textPrompt = __importStar(require("../../model-function/generate-text/prompt-template/TextPromptTemplate.cjs"));
|
33
34
|
const vicunaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/VicunaPromptTemplate.cjs"));
|
34
35
|
const LlamaCppBakLLaVA1Prompt = __importStar(require("./LlamaCppBakLLaVA1PromptTemplate.cjs"));
|
@@ -87,5 +88,6 @@ exports.ChatML = asLlamaCppTextPromptTemplateProvider(chatMlPrompt);
|
|
87
88
|
exports.Llama2 = asLlamaCppTextPromptTemplateProvider(llama2Prompt);
|
88
89
|
exports.NeuralChat = asLlamaCppTextPromptTemplateProvider(neuralChatPrompt);
|
89
90
|
exports.Alpaca = asLlamaCppTextPromptTemplateProvider(alpacaPrompt);
|
91
|
+
exports.Synthia = asLlamaCppTextPromptTemplateProvider(synthiaPrompt);
|
90
92
|
exports.Vicuna = asLlamaCppTextPromptTemplateProvider(vicunaPrompt);
|
91
93
|
exports.BakLLaVA1 = LlamaCppBakLLaVA1Prompt;
|
@@ -42,5 +42,6 @@ export declare const ChatML: TextGenerationPromptTemplateProvider<LlamaCppComple
|
|
42
42
|
export declare const Llama2: TextGenerationPromptTemplateProvider<LlamaCppCompletionPrompt>;
|
43
43
|
export declare const NeuralChat: TextGenerationPromptTemplateProvider<LlamaCppCompletionPrompt>;
|
44
44
|
export declare const Alpaca: TextGenerationPromptTemplateProvider<LlamaCppCompletionPrompt>;
|
45
|
+
export declare const Synthia: TextGenerationPromptTemplateProvider<LlamaCppCompletionPrompt>;
|
45
46
|
export declare const Vicuna: TextGenerationPromptTemplateProvider<LlamaCppCompletionPrompt>;
|
46
47
|
export declare const BakLLaVA1: typeof LlamaCppBakLLaVA1Prompt;
|
@@ -3,6 +3,7 @@ import * as chatMlPrompt from "../../model-function/generate-text/prompt-templat
|
|
3
3
|
import * as llama2Prompt from "../../model-function/generate-text/prompt-template/Llama2PromptTemplate.js";
|
4
4
|
import * as mistralPrompt from "../../model-function/generate-text/prompt-template/MistralInstructPromptTemplate.js";
|
5
5
|
import * as neuralChatPrompt from "../../model-function/generate-text/prompt-template/NeuralChatPromptTemplate.js";
|
6
|
+
import * as synthiaPrompt from "../../model-function/generate-text/prompt-template/SynthiaPromptTemplate.js";
|
6
7
|
import * as textPrompt from "../../model-function/generate-text/prompt-template/TextPromptTemplate.js";
|
7
8
|
import * as vicunaPrompt from "../../model-function/generate-text/prompt-template/VicunaPromptTemplate.js";
|
8
9
|
import * as LlamaCppBakLLaVA1Prompt from "./LlamaCppBakLLaVA1PromptTemplate.js";
|
@@ -59,5 +60,6 @@ export const ChatML = asLlamaCppTextPromptTemplateProvider(chatMlPrompt);
|
|
59
60
|
export const Llama2 = asLlamaCppTextPromptTemplateProvider(llama2Prompt);
|
60
61
|
export const NeuralChat = asLlamaCppTextPromptTemplateProvider(neuralChatPrompt);
|
61
62
|
export const Alpaca = asLlamaCppTextPromptTemplateProvider(alpacaPrompt);
|
63
|
+
export const Synthia = asLlamaCppTextPromptTemplateProvider(synthiaPrompt);
|
62
64
|
export const Vicuna = asLlamaCppTextPromptTemplateProvider(vicunaPrompt);
|
63
65
|
export const BakLLaVA1 = LlamaCppBakLLaVA1Prompt;
|
@@ -23,12 +23,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
23
|
return result;
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.Vicuna = exports.Alpaca = exports.NeuralChat = exports.Llama2 = exports.ChatML = exports.Mistral = exports.Text = exports.asOllamaCompletionTextPromptTemplateProvider = exports.asOllamaCompletionPromptTemplate = void 0;
|
26
|
+
exports.Vicuna = exports.Synthia = exports.Alpaca = exports.NeuralChat = exports.Llama2 = exports.ChatML = exports.Mistral = exports.Text = exports.asOllamaCompletionTextPromptTemplateProvider = exports.asOllamaCompletionPromptTemplate = void 0;
|
27
27
|
const alpacaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/AlpacaPromptTemplate.cjs"));
|
28
28
|
const chatMlPrompt = __importStar(require("../../model-function/generate-text/prompt-template/ChatMLPromptTemplate.cjs"));
|
29
29
|
const llama2Prompt = __importStar(require("../../model-function/generate-text/prompt-template/Llama2PromptTemplate.cjs"));
|
30
30
|
const mistralPrompt = __importStar(require("../../model-function/generate-text/prompt-template/MistralInstructPromptTemplate.cjs"));
|
31
31
|
const neuralChatPrompt = __importStar(require("../../model-function/generate-text/prompt-template/NeuralChatPromptTemplate.cjs"));
|
32
|
+
const synthiaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/SynthiaPromptTemplate.cjs"));
|
32
33
|
const textPrompt = __importStar(require("../../model-function/generate-text/prompt-template/TextPromptTemplate.cjs"));
|
33
34
|
const vicunaPrompt = __importStar(require("../../model-function/generate-text/prompt-template/VicunaPromptTemplate.cjs"));
|
34
35
|
function asOllamaCompletionPromptTemplate(promptTemplate) {
|
@@ -86,4 +87,5 @@ exports.ChatML = asOllamaCompletionTextPromptTemplateProvider(chatMlPrompt);
|
|
86
87
|
exports.Llama2 = asOllamaCompletionTextPromptTemplateProvider(llama2Prompt);
|
87
88
|
exports.NeuralChat = asOllamaCompletionTextPromptTemplateProvider(neuralChatPrompt);
|
88
89
|
exports.Alpaca = asOllamaCompletionTextPromptTemplateProvider(alpacaPrompt);
|
90
|
+
exports.Synthia = asOllamaCompletionTextPromptTemplateProvider(synthiaPrompt);
|
89
91
|
exports.Vicuna = asOllamaCompletionTextPromptTemplateProvider(vicunaPrompt);
|
@@ -41,4 +41,5 @@ export declare const ChatML: TextGenerationPromptTemplateProvider<OllamaCompleti
|
|
41
41
|
export declare const Llama2: TextGenerationPromptTemplateProvider<OllamaCompletionPrompt>;
|
42
42
|
export declare const NeuralChat: TextGenerationPromptTemplateProvider<OllamaCompletionPrompt>;
|
43
43
|
export declare const Alpaca: TextGenerationPromptTemplateProvider<OllamaCompletionPrompt>;
|
44
|
+
export declare const Synthia: TextGenerationPromptTemplateProvider<OllamaCompletionPrompt>;
|
44
45
|
export declare const Vicuna: TextGenerationPromptTemplateProvider<OllamaCompletionPrompt>;
|
@@ -3,6 +3,7 @@ import * as chatMlPrompt from "../../model-function/generate-text/prompt-templat
|
|
3
3
|
import * as llama2Prompt from "../../model-function/generate-text/prompt-template/Llama2PromptTemplate.js";
|
4
4
|
import * as mistralPrompt from "../../model-function/generate-text/prompt-template/MistralInstructPromptTemplate.js";
|
5
5
|
import * as neuralChatPrompt from "../../model-function/generate-text/prompt-template/NeuralChatPromptTemplate.js";
|
6
|
+
import * as synthiaPrompt from "../../model-function/generate-text/prompt-template/SynthiaPromptTemplate.js";
|
6
7
|
import * as textPrompt from "../../model-function/generate-text/prompt-template/TextPromptTemplate.js";
|
7
8
|
import * as vicunaPrompt from "../../model-function/generate-text/prompt-template/VicunaPromptTemplate.js";
|
8
9
|
export function asOllamaCompletionPromptTemplate(promptTemplate) {
|
@@ -58,4 +59,5 @@ export const ChatML = asOllamaCompletionTextPromptTemplateProvider(chatMlPrompt)
|
|
58
59
|
export const Llama2 = asOllamaCompletionTextPromptTemplateProvider(llama2Prompt);
|
59
60
|
export const NeuralChat = asOllamaCompletionTextPromptTemplateProvider(neuralChatPrompt);
|
60
61
|
export const Alpaca = asOllamaCompletionTextPromptTemplateProvider(alpacaPrompt);
|
62
|
+
export const Synthia = asOllamaCompletionTextPromptTemplateProvider(synthiaPrompt);
|
61
63
|
export const Vicuna = asOllamaCompletionTextPromptTemplateProvider(vicunaPrompt);
|
package/package.json
CHANGED
package/tool/Tool.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { FunctionOptions } from "../core/FunctionOptions.js";
|
1
|
+
import { FunctionCallOptions, FunctionOptions } from "../core/FunctionOptions.js";
|
2
2
|
import { JsonSchemaProducer } from "../core/schema/JsonSchemaProducer.js";
|
3
3
|
import { Schema } from "../core/schema/Schema.js";
|
4
4
|
import { ToolDefinition } from "./ToolDefinition.js";
|
@@ -28,7 +28,7 @@ export declare class Tool<NAME extends string, PARAMETERS, RESULT> implements To
|
|
28
28
|
/**
|
29
29
|
* The actual execution function of the tool.
|
30
30
|
*/
|
31
|
-
readonly execute: (args: PARAMETERS, options
|
31
|
+
readonly execute: (args: PARAMETERS, options: FunctionCallOptions) => PromiseLike<RESULT>;
|
32
32
|
constructor({ name, description, parameters, returnType, execute, }: {
|
33
33
|
name: NAME;
|
34
34
|
description: string;
|
@@ -32,7 +32,7 @@ async function doExecuteTool(tool, args, options) {
|
|
32
32
|
const metadata = {
|
33
33
|
functionType: "execute-tool",
|
34
34
|
callId: `call-${(0, nanoid_1.nanoid)()}`,
|
35
|
-
parentCallId: options?.
|
35
|
+
parentCallId: options?.callId,
|
36
36
|
runId: run?.runId,
|
37
37
|
sessionId: run?.sessionId,
|
38
38
|
userId: run?.userId,
|
@@ -47,11 +47,12 @@ async function doExecuteTool(tool, args, options) {
|
|
47
47
|
startTimestamp: durationMeasurement.startDate,
|
48
48
|
});
|
49
49
|
const result = await (0, runSafe_js_1.runSafe)(() => tool.execute(args, {
|
50
|
+
functionType: metadata.functionType,
|
51
|
+
callId: metadata.callId,
|
50
52
|
functionId: options?.functionId,
|
51
53
|
logging: options?.logging,
|
52
54
|
observers: options?.observers,
|
53
55
|
run,
|
54
|
-
parentCallId: metadata.callId,
|
55
56
|
}));
|
56
57
|
const finishMetadata = {
|
57
58
|
...metadata,
|
@@ -28,7 +28,7 @@ async function doExecuteTool(tool, args, options) {
|
|
28
28
|
const metadata = {
|
29
29
|
functionType: "execute-tool",
|
30
30
|
callId: `call-${createId()}`,
|
31
|
-
parentCallId: options?.
|
31
|
+
parentCallId: options?.callId,
|
32
32
|
runId: run?.runId,
|
33
33
|
sessionId: run?.sessionId,
|
34
34
|
userId: run?.userId,
|
@@ -43,11 +43,12 @@ async function doExecuteTool(tool, args, options) {
|
|
43
43
|
startTimestamp: durationMeasurement.startDate,
|
44
44
|
});
|
45
45
|
const result = await runSafe(() => tool.execute(args, {
|
46
|
+
functionType: metadata.functionType,
|
47
|
+
callId: metadata.callId,
|
46
48
|
functionId: options?.functionId,
|
47
49
|
logging: options?.logging,
|
48
50
|
observers: options?.observers,
|
49
51
|
run,
|
50
|
-
parentCallId: metadata.callId,
|
51
52
|
}));
|
52
53
|
const finishMetadata = {
|
53
54
|
...metadata,
|