modelfusion 0.82.0 → 0.83.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 +10 -7
- package/core/schema/UncheckedSchema.cjs +5 -1
- package/core/schema/UncheckedSchema.d.ts +1 -0
- package/core/schema/UncheckedSchema.js +3 -0
- package/model-function/generate-text/prompt-format/InstructionPrompt.d.ts +1 -1
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +1 -1
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +1 -1
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +1 -1
- package/model-provider/llamacpp/LlamaCppBakLLaVA1Format.d.ts +2 -2
- package/model-provider/openai/chat/OpenAIChatFunctionCallStructureGenerationModel.d.ts +1 -1
- package/model-provider/openai/chat/OpenAIChatModel.d.ts +1 -1
- package/model-provider/openai/chat/OpenAIChatPromptFormat.d.ts +2 -2
- package/model-provider/stability/StabilityImageGenerationModel.cjs +1 -1
- package/model-provider/stability/StabilityImageGenerationModel.d.ts +1 -1
- package/model-provider/stability/StabilityImageGenerationModel.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -196,6 +196,7 @@ Generate a structure that matches a schema.
|
|
196
196
|
import { zodSchema, generateStructure, openai } from "modelfusion";
|
197
197
|
|
198
198
|
const sentiment = await generateStructure(
|
199
|
+
// model:
|
199
200
|
openai
|
200
201
|
.ChatTextGenerator({
|
201
202
|
model: "gpt-3.5-turbo",
|
@@ -205,6 +206,7 @@ const sentiment = await generateStructure(
|
|
205
206
|
.asFunctionCallStructureGenerationModel({ fnName: "sentiment" })
|
206
207
|
.withInstructionPrompt(),
|
207
208
|
|
209
|
+
// schema:
|
208
210
|
zodSchema(
|
209
211
|
z.object({
|
210
212
|
sentiment: z
|
@@ -213,6 +215,7 @@ const sentiment = await generateStructure(
|
|
213
215
|
})
|
214
216
|
),
|
215
217
|
|
218
|
+
// prompt:
|
216
219
|
{
|
217
220
|
system:
|
218
221
|
"You are a sentiment evaluator. " +
|
@@ -224,7 +227,7 @@ const sentiment = await generateStructure(
|
|
224
227
|
);
|
225
228
|
```
|
226
229
|
|
227
|
-
Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai)
|
230
|
+
Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai), [Ollama](https://modelfusion.dev//integration/model-provider/ollama)
|
228
231
|
|
229
232
|
#### streamStructure
|
230
233
|
|
@@ -270,7 +273,7 @@ for await (const part of structureStream) {
|
|
270
273
|
}
|
271
274
|
```
|
272
275
|
|
273
|
-
Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai)
|
276
|
+
Providers: [OpenAI](https://modelfusion.dev/integration/model-provider/openai), [Ollama](https://modelfusion.dev//integration/model-provider/ollama)
|
274
277
|
|
275
278
|
### [Embed Value](https://modelfusion.dev/guide/function/embed)
|
276
279
|
|
@@ -591,15 +594,15 @@ const image = await generateImage(
|
|
591
594
|
.ImageGenerator({
|
592
595
|
//...
|
593
596
|
})
|
594
|
-
.
|
597
|
+
.withTextPrompt(),
|
595
598
|
"the wicked witch of the west in the style of early 19th century painting"
|
596
599
|
);
|
597
600
|
```
|
598
601
|
|
599
|
-
| Prompt Format |
|
600
|
-
| ------------- |
|
601
|
-
| Automatic1111 | ✅
|
602
|
-
| Stability | ✅
|
602
|
+
| Prompt Format | Text Prompt |
|
603
|
+
| ------------- | ----------- |
|
604
|
+
| Automatic1111 | ✅ |
|
605
|
+
| Stability | ✅ |
|
603
606
|
|
604
607
|
### Metadata and original responses
|
605
608
|
|
@@ -1,6 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.UncheckedSchema = void 0;
|
3
|
+
exports.UncheckedSchema = exports.uncheckedSchema = void 0;
|
4
|
+
function uncheckedSchema(jsonSchema) {
|
5
|
+
return new UncheckedSchema(jsonSchema);
|
6
|
+
}
|
7
|
+
exports.uncheckedSchema = uncheckedSchema;
|
4
8
|
class UncheckedSchema {
|
5
9
|
constructor(jsonSchema) {
|
6
10
|
Object.defineProperty(this, "jsonSchema", {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { JsonSchemaProducer } from "./JsonSchemaProducer.js";
|
2
2
|
import { Schema } from "./Schema.js";
|
3
|
+
export declare function uncheckedSchema<STRUCTURE>(jsonSchema?: unknown): UncheckedSchema<STRUCTURE>;
|
3
4
|
export declare class UncheckedSchema<STRUCTURE> implements Schema<STRUCTURE>, JsonSchemaProducer {
|
4
5
|
private readonly jsonSchema?;
|
5
6
|
constructor(jsonSchema?: unknown);
|
@@ -4,7 +4,7 @@ import { MultiModalInput } from "./Content.js";
|
|
4
4
|
* the role and behavior of the language model.
|
5
5
|
* The instruction is a multi-model input (`array` of content).
|
6
6
|
*/
|
7
|
-
export interface
|
7
|
+
export interface MultiModalInstructionPrompt {
|
8
8
|
/**
|
9
9
|
* Optional system message to provide context for the language model. Note that for some models,
|
10
10
|
* changing the system message can impact the results, because the model may be trained on the default system message.
|
@@ -53,7 +53,7 @@ class Automatic1111ImageGenerationModel extends AbstractModel_js_1.AbstractModel
|
|
53
53
|
base64Image: response.images[0],
|
54
54
|
};
|
55
55
|
}
|
56
|
-
|
56
|
+
withTextPrompt() {
|
57
57
|
return this.withPromptFormat((0, Automatic1111ImageGenerationPrompt_js_1.mapBasicPromptToAutomatic1111Format)());
|
58
58
|
}
|
59
59
|
withPromptFormat(promptFormat) {
|
@@ -25,7 +25,7 @@ export declare class Automatic1111ImageGenerationModel extends AbstractModel<Aut
|
|
25
25
|
};
|
26
26
|
base64Image: string;
|
27
27
|
}>;
|
28
|
-
|
28
|
+
withTextPrompt(): PromptFormatImageGenerationModel<string, Automatic1111ImageGenerationPrompt, Automatic1111ImageGenerationSettings, this>;
|
29
29
|
withPromptFormat<INPUT_PROMPT>(promptFormat: PromptFormat<INPUT_PROMPT, Automatic1111ImageGenerationPrompt>): PromptFormatImageGenerationModel<INPUT_PROMPT, Automatic1111ImageGenerationPrompt, Automatic1111ImageGenerationSettings, this>;
|
30
30
|
withSettings(additionalSettings: Automatic1111ImageGenerationSettings): this;
|
31
31
|
}
|
@@ -50,7 +50,7 @@ export class Automatic1111ImageGenerationModel extends AbstractModel {
|
|
50
50
|
base64Image: response.images[0],
|
51
51
|
};
|
52
52
|
}
|
53
|
-
|
53
|
+
withTextPrompt() {
|
54
54
|
return this.withPromptFormat(mapBasicPromptToAutomatic1111Format());
|
55
55
|
}
|
56
56
|
withPromptFormat(promptFormat) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { MultiModalInstructionPrompt } from "../../model-function/generate-text/prompt-format/InstructionPrompt.js";
|
2
2
|
import { TextGenerationPromptFormat } from "../../model-function/generate-text/TextGenerationPromptFormat.js";
|
3
3
|
import { LlamaCppTextGenerationPrompt } from "./LlamaCppTextGenerationModel.js";
|
4
4
|
/**
|
@@ -6,4 +6,4 @@ import { LlamaCppTextGenerationPrompt } from "./LlamaCppTextGenerationModel.js";
|
|
6
6
|
*
|
7
7
|
* @see https://github.com/SkunkworksAI/BakLLaVA
|
8
8
|
*/
|
9
|
-
export declare function instruction(): TextGenerationPromptFormat<
|
9
|
+
export declare function instruction(): TextGenerationPromptFormat<MultiModalInstructionPrompt, LlamaCppTextGenerationPrompt>;
|
@@ -27,7 +27,7 @@ OpenAIChatSettings> {
|
|
27
27
|
/**
|
28
28
|
* Returns this model with an instruction prompt format.
|
29
29
|
*/
|
30
|
-
withInstructionPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptFormat<import("../../../index.js").
|
30
|
+
withInstructionPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptFormat<import("../../../index.js").MultiModalInstructionPrompt | import("../../../index.js").TextInstructionPrompt, OpenAIChatMessage[]>>;
|
31
31
|
/**
|
32
32
|
* Returns this model with a chat prompt format.
|
33
33
|
*/
|
@@ -338,7 +338,7 @@ export declare class OpenAIChatModel extends AbstractModel<OpenAIChatSettings> i
|
|
338
338
|
/**
|
339
339
|
* Returns this model with an instruction prompt format.
|
340
340
|
*/
|
341
|
-
withInstructionPrompt(): PromptFormatTextStreamingModel<import("../../../index.js").
|
341
|
+
withInstructionPrompt(): PromptFormatTextStreamingModel<import("../../../index.js").MultiModalInstructionPrompt | import("../../../index.js").TextInstructionPrompt, OpenAIChatMessage[], OpenAIChatSettings, this>;
|
342
342
|
/**
|
343
343
|
* Returns this model with a chat prompt format.
|
344
344
|
*/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { TextGenerationPromptFormat } from "../../../model-function/generate-text/TextGenerationPromptFormat.js";
|
2
2
|
import { ChatPrompt } from "../../../model-function/generate-text/prompt-format/ChatPrompt.js";
|
3
|
-
import {
|
3
|
+
import { MultiModalInstructionPrompt, TextInstructionPrompt } from "../../../model-function/generate-text/prompt-format/InstructionPrompt.js";
|
4
4
|
import { OpenAIChatMessage } from "./OpenAIChatMessage.js";
|
5
5
|
/**
|
6
6
|
* OpenAIMessage[] identity chat format.
|
@@ -13,7 +13,7 @@ export declare function text(): TextGenerationPromptFormat<string, Array<OpenAIC
|
|
13
13
|
/**
|
14
14
|
* Formats an instruction prompt as an OpenAI chat prompt.
|
15
15
|
*/
|
16
|
-
export declare function instruction(): TextGenerationPromptFormat<
|
16
|
+
export declare function instruction(): TextGenerationPromptFormat<MultiModalInstructionPrompt | TextInstructionPrompt, Array<OpenAIChatMessage>>;
|
17
17
|
/**
|
18
18
|
* Formats a chat prompt as an OpenAI chat prompt.
|
19
19
|
*/
|
@@ -78,7 +78,7 @@ class StabilityImageGenerationModel extends AbstractModel_js_1.AbstractModel {
|
|
78
78
|
base64Image: response.artifacts[0].base64,
|
79
79
|
};
|
80
80
|
}
|
81
|
-
|
81
|
+
withTextPrompt() {
|
82
82
|
return this.withPromptFormat((0, StabilityImageGenerationPrompt_js_1.mapBasicPromptToStabilityFormat)());
|
83
83
|
}
|
84
84
|
withPromptFormat(promptFormat) {
|
@@ -44,7 +44,7 @@ export declare class StabilityImageGenerationModel extends AbstractModel<Stabili
|
|
44
44
|
};
|
45
45
|
base64Image: string;
|
46
46
|
}>;
|
47
|
-
|
47
|
+
withTextPrompt(): PromptFormatImageGenerationModel<string, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, this>;
|
48
48
|
withPromptFormat<INPUT_PROMPT>(promptFormat: PromptFormat<INPUT_PROMPT, StabilityImageGenerationPrompt>): PromptFormatImageGenerationModel<INPUT_PROMPT, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, this>;
|
49
49
|
withSettings(additionalSettings: StabilityImageGenerationSettings): this;
|
50
50
|
}
|
@@ -75,7 +75,7 @@ export class StabilityImageGenerationModel extends AbstractModel {
|
|
75
75
|
base64Image: response.artifacts[0].base64,
|
76
76
|
};
|
77
77
|
}
|
78
|
-
|
78
|
+
withTextPrompt() {
|
79
79
|
return this.withPromptFormat(mapBasicPromptToStabilityFormat());
|
80
80
|
}
|
81
81
|
withPromptFormat(promptFormat) {
|