modelfusion 0.103.0 → 0.104.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/model-function/generate-text/prompt-template/AlpacaPromptTemplate.cjs +2 -1
  3. package/model-function/generate-text/prompt-template/AlpacaPromptTemplate.d.ts +2 -2
  4. package/model-function/generate-text/prompt-template/AlpacaPromptTemplate.js +2 -1
  5. package/model-function/generate-text/prompt-template/ChatMLPromptTemplate.cjs +5 -4
  6. package/model-function/generate-text/prompt-template/ChatMLPromptTemplate.d.ts +4 -4
  7. package/model-function/generate-text/prompt-template/ChatMLPromptTemplate.js +5 -4
  8. package/model-function/generate-text/prompt-template/ChatPrompt.cjs +0 -24
  9. package/model-function/generate-text/prompt-template/ChatPrompt.d.ts +11 -34
  10. package/model-function/generate-text/prompt-template/ChatPrompt.js +1 -22
  11. package/model-function/generate-text/prompt-template/Content.cjs +9 -0
  12. package/model-function/generate-text/prompt-template/Content.d.ts +9 -4
  13. package/model-function/generate-text/prompt-template/Content.js +7 -1
  14. package/model-function/generate-text/prompt-template/InstructionPrompt.d.ts +6 -22
  15. package/model-function/generate-text/prompt-template/Llama2PromptTemplate.cjs +36 -5
  16. package/model-function/generate-text/prompt-template/Llama2PromptTemplate.d.ts +16 -4
  17. package/model-function/generate-text/prompt-template/Llama2PromptTemplate.js +34 -4
  18. package/model-function/generate-text/prompt-template/NeuralChatPromptTemplate.cjs +5 -4
  19. package/model-function/generate-text/prompt-template/NeuralChatPromptTemplate.d.ts +4 -4
  20. package/model-function/generate-text/prompt-template/NeuralChatPromptTemplate.js +5 -4
  21. package/model-function/generate-text/prompt-template/TextPromptTemplate.cjs +3 -4
  22. package/model-function/generate-text/prompt-template/TextPromptTemplate.d.ts +4 -4
  23. package/model-function/generate-text/prompt-template/TextPromptTemplate.js +3 -4
  24. package/model-function/generate-text/prompt-template/VicunaPromptTemplate.cjs +3 -3
  25. package/model-function/generate-text/prompt-template/VicunaPromptTemplate.d.ts +2 -2
  26. package/model-function/generate-text/prompt-template/VicunaPromptTemplate.js +3 -3
  27. package/model-function/generate-text/prompt-template/trimChatPrompt.cjs +0 -2
  28. package/model-function/generate-text/prompt-template/trimChatPrompt.d.ts +4 -4
  29. package/model-function/generate-text/prompt-template/trimChatPrompt.js +0 -2
  30. package/model-provider/anthropic/AnthropicPromptTemplate.cjs +5 -4
  31. package/model-provider/anthropic/AnthropicPromptTemplate.d.ts +4 -4
  32. package/model-provider/anthropic/AnthropicPromptTemplate.js +5 -4
  33. package/model-provider/anthropic/AnthropicTextGenerationModel.d.ts +2 -2
  34. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +1 -1
  35. package/model-provider/cohere/CohereTextGenerationModel.d.ts +2 -2
  36. package/model-provider/llamacpp/LlamaCppBakLLaVA1PromptTemplate.cjs +23 -16
  37. package/model-provider/llamacpp/LlamaCppBakLLaVA1PromptTemplate.d.ts +4 -4
  38. package/model-provider/llamacpp/LlamaCppBakLLaVA1PromptTemplate.js +23 -16
  39. package/model-provider/mistral/MistralChatModel.d.ts +2 -2
  40. package/model-provider/mistral/MistralPromptTemplate.cjs +5 -4
  41. package/model-provider/mistral/MistralPromptTemplate.d.ts +4 -4
  42. package/model-provider/mistral/MistralPromptTemplate.js +5 -4
  43. package/model-provider/ollama/OllamaChatModel.d.ts +2 -2
  44. package/model-provider/ollama/OllamaChatPromptTemplate.cjs +9 -13
  45. package/model-provider/ollama/OllamaChatPromptTemplate.d.ts +4 -4
  46. package/model-provider/ollama/OllamaChatPromptTemplate.js +9 -13
  47. package/model-provider/openai/OpenAICompletionModel.d.ts +2 -2
  48. package/model-provider/openai/chat/OpenAIChatFunctionCallStructureGenerationModel.d.ts +2 -2
  49. package/model-provider/openai/chat/OpenAIChatMessage.d.ts +2 -2
  50. package/model-provider/openai/chat/OpenAIChatModel.d.ts +2 -2
  51. package/model-provider/openai/chat/OpenAIChatPromptTemplate.cjs +0 -2
  52. package/model-provider/openai/chat/OpenAIChatPromptTemplate.d.ts +4 -4
  53. package/model-provider/openai/chat/OpenAIChatPromptTemplate.js +0 -2
  54. package/model-provider/openai-compatible/OpenAICompatibleChatModel.d.ts +2 -2
  55. package/model-provider/stability/StabilityImageGenerationModel.d.ts +1 -1
  56. package/package.json +1 -1
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chat = exports.instruction = exports.text = exports.identity = void 0;
4
- const ChatPrompt_js_1 = require("../../model-function/generate-text/prompt-template/ChatPrompt.cjs");
5
4
  /**
6
5
  * OllamaChatPrompt identity chat format.
7
6
  */
@@ -42,7 +41,6 @@ exports.instruction = instruction;
42
41
  function chat() {
43
42
  return {
44
43
  format(prompt) {
45
- (0, ChatPrompt_js_1.validateChatPrompt)(prompt);
46
44
  const messages = [];
47
45
  if (prompt.system != null) {
48
46
  messages.push({ role: "system", content: prompt.system });
@@ -60,17 +58,15 @@ function extractContent(input) {
60
58
  if (typeof input === "string") {
61
59
  return { content: input, images: undefined };
62
60
  }
63
- else {
64
- const images = [];
65
- let content = "";
66
- for (const part of input) {
67
- if (part.type === "text") {
68
- content += part.text;
69
- }
70
- else {
71
- images.push(part.base64Image);
72
- }
61
+ const images = [];
62
+ let content = "";
63
+ for (const part of input) {
64
+ if (part.type === "text") {
65
+ content += part.text;
66
+ }
67
+ else {
68
+ images.push(part.base64Image);
73
69
  }
74
- return { content, images };
75
70
  }
71
+ return { content, images };
76
72
  }
@@ -1,6 +1,6 @@
1
1
  import { TextGenerationPromptTemplate } from "../../model-function/generate-text/TextGenerationPromptTemplate.js";
2
- import { MultiModalChatPrompt, TextChatPrompt } from "../../model-function/generate-text/prompt-template/ChatPrompt.js";
3
- import { MultiModalInstructionPrompt, TextInstructionPrompt } from "../../model-function/generate-text/prompt-template/InstructionPrompt.js";
2
+ import { ChatPrompt } from "../../model-function/generate-text/prompt-template/ChatPrompt.js";
3
+ import { InstructionPrompt } from "../../model-function/generate-text/prompt-template/InstructionPrompt.js";
4
4
  import { OllamaChatPrompt } from "./OllamaChatModel.js";
5
5
  /**
6
6
  * OllamaChatPrompt identity chat format.
@@ -13,8 +13,8 @@ export declare function text(): TextGenerationPromptTemplate<string, OllamaChatP
13
13
  /**
14
14
  * Formats an instruction prompt as an Ollama chat prompt.
15
15
  */
16
- export declare function instruction(): TextGenerationPromptTemplate<MultiModalInstructionPrompt | TextInstructionPrompt, OllamaChatPrompt>;
16
+ export declare function instruction(): TextGenerationPromptTemplate<InstructionPrompt, OllamaChatPrompt>;
17
17
  /**
18
18
  * Formats a chat prompt as an Ollama chat prompt.
19
19
  */
20
- export declare function chat(): TextGenerationPromptTemplate<MultiModalChatPrompt | TextChatPrompt, OllamaChatPrompt>;
20
+ export declare function chat(): TextGenerationPromptTemplate<ChatPrompt, OllamaChatPrompt>;
@@ -1,4 +1,3 @@
1
- import { validateChatPrompt, } from "../../model-function/generate-text/prompt-template/ChatPrompt.js";
2
1
  /**
3
2
  * OllamaChatPrompt identity chat format.
4
3
  */
@@ -36,7 +35,6 @@ export function instruction() {
36
35
  export function chat() {
37
36
  return {
38
37
  format(prompt) {
39
- validateChatPrompt(prompt);
40
38
  const messages = [];
41
39
  if (prompt.system != null) {
42
40
  messages.push({ role: "system", content: prompt.system });
@@ -53,17 +51,15 @@ function extractContent(input) {
53
51
  if (typeof input === "string") {
54
52
  return { content: input, images: undefined };
55
53
  }
56
- else {
57
- const images = [];
58
- let content = "";
59
- for (const part of input) {
60
- if (part.type === "text") {
61
- content += part.text;
62
- }
63
- else {
64
- images.push(part.base64Image);
65
- }
54
+ const images = [];
55
+ let content = "";
56
+ for (const part of input) {
57
+ if (part.type === "text") {
58
+ content += part.text;
59
+ }
60
+ else {
61
+ images.push(part.base64Image);
66
62
  }
67
- return { content, images };
68
63
  }
64
+ return { content, images };
69
65
  }
@@ -178,14 +178,14 @@ export declare class OpenAICompletionModel extends AbstractModel<OpenAICompletio
178
178
  /**
179
179
  * Returns this model with an instruction prompt template.
180
180
  */
181
- withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").TextInstructionPrompt, string, OpenAICompletionModelSettings, this>;
181
+ withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").InstructionPrompt, string, OpenAICompletionModelSettings, this>;
182
182
  /**
183
183
  * Returns this model with a chat prompt template.
184
184
  */
185
185
  withChatPrompt(options?: {
186
186
  user?: string;
187
187
  assistant?: string;
188
- }): PromptTemplateTextStreamingModel<import("../../index.js").TextChatPrompt, string, OpenAICompletionModelSettings, this>;
188
+ }): PromptTemplateTextStreamingModel<import("../../index.js").ChatPrompt, string, OpenAICompletionModelSettings, this>;
189
189
  withPromptTemplate<INPUT_PROMPT>(promptTemplate: TextGenerationPromptTemplate<INPUT_PROMPT, string>): PromptTemplateTextStreamingModel<INPUT_PROMPT, string, OpenAICompletionModelSettings, this>;
190
190
  withSettings(additionalSettings: Partial<OpenAICompletionModelSettings>): this;
191
191
  }
@@ -27,11 +27,11 @@ OpenAIChatSettings> {
27
27
  /**
28
28
  * Returns this model with an instruction prompt template.
29
29
  */
30
- withInstructionPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptTemplate<import("../../../index.js").MultiModalInstructionPrompt | import("../../../index.js").TextInstructionPrompt, OpenAIChatPrompt>>;
30
+ withInstructionPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptTemplate<import("../../../index.js").InstructionPrompt, OpenAIChatPrompt>>;
31
31
  /**
32
32
  * Returns this model with a chat prompt template.
33
33
  */
34
- withChatPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptTemplate<import("../../../index.js").TextChatPrompt | import("../../../index.js").MultiModalChatPrompt, OpenAIChatPrompt>>;
34
+ withChatPrompt(): OpenAIChatFunctionCallStructureGenerationModel<TextGenerationPromptTemplate<import("../../../index.js").ChatPrompt, OpenAIChatPrompt>>;
35
35
  withPromptTemplate<TARGET_PROMPT_FORMAT extends TextGenerationPromptTemplate<unknown, OpenAIChatPrompt>>(promptTemplate: TARGET_PROMPT_FORMAT): OpenAIChatFunctionCallStructureGenerationModel<TARGET_PROMPT_FORMAT>;
36
36
  withSettings(additionalSettings: Partial<OpenAIChatSettings>): this;
37
37
  /**
@@ -1,4 +1,4 @@
1
- import { MultiModalInput } from "../../../model-function/generate-text/prompt-template/Content.js";
1
+ import { Content } from "../../../model-function/generate-text/prompt-template/Content.js";
2
2
  import { ToolCall } from "../../../tool/ToolCall.js";
3
3
  export type OpenAIChatMessage = {
4
4
  role: "system";
@@ -50,7 +50,7 @@ export declare const OpenAIChatMessage: {
50
50
  /**
51
51
  * Creates a user chat message. The message can be a string or a multi-modal input.
52
52
  */
53
- user(content: string | MultiModalInput, options?: {
53
+ user(content: Content, options?: {
54
54
  name?: string;
55
55
  }): OpenAIChatMessage;
56
56
  /**
@@ -151,11 +151,11 @@ export declare class OpenAIChatModel extends AbstractOpenAIChatModel<OpenAIChatS
151
151
  /**
152
152
  * Returns this model with an instruction prompt template.
153
153
  */
154
- withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../../index.js").MultiModalInstructionPrompt | import("../../../index.js").TextInstructionPrompt, OpenAIChatPrompt, OpenAIChatSettings, this>;
154
+ withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../../index.js").InstructionPrompt, OpenAIChatPrompt, OpenAIChatSettings, this>;
155
155
  /**
156
156
  * Returns this model with a chat prompt template.
157
157
  */
158
- withChatPrompt(): PromptTemplateTextStreamingModel<import("../../../index.js").TextChatPrompt | import("../../../index.js").MultiModalChatPrompt, OpenAIChatPrompt, OpenAIChatSettings, this>;
158
+ withChatPrompt(): PromptTemplateTextStreamingModel<import("../../../index.js").ChatPrompt, OpenAIChatPrompt, OpenAIChatSettings, this>;
159
159
  withPromptTemplate<INPUT_PROMPT>(promptTemplate: TextGenerationPromptTemplate<INPUT_PROMPT, OpenAIChatPrompt>): PromptTemplateTextStreamingModel<INPUT_PROMPT, OpenAIChatPrompt, OpenAIChatSettings, this>;
160
160
  withSettings(additionalSettings: Partial<OpenAIChatSettings>): this;
161
161
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.chat = exports.instruction = exports.text = exports.identity = void 0;
4
- const ChatPrompt_js_1 = require("../../../model-function/generate-text/prompt-template/ChatPrompt.cjs");
5
4
  const OpenAIChatMessage_js_1 = require("./OpenAIChatMessage.cjs");
6
5
  /**
7
6
  * OpenAIMessage[] identity chat format.
@@ -43,7 +42,6 @@ exports.instruction = instruction;
43
42
  function chat() {
44
43
  return {
45
44
  format(prompt) {
46
- (0, ChatPrompt_js_1.validateChatPrompt)(prompt);
47
45
  const messages = [];
48
46
  if (prompt.system != null) {
49
47
  messages.push(OpenAIChatMessage_js_1.OpenAIChatMessage.system(prompt.system));
@@ -1,6 +1,6 @@
1
1
  import { TextGenerationPromptTemplate } from "../../../model-function/generate-text/TextGenerationPromptTemplate.js";
2
- import { MultiModalChatPrompt, TextChatPrompt } from "../../../model-function/generate-text/prompt-template/ChatPrompt.js";
3
- import { MultiModalInstructionPrompt, TextInstructionPrompt } from "../../../model-function/generate-text/prompt-template/InstructionPrompt.js";
2
+ import { ChatPrompt } from "../../../model-function/generate-text/prompt-template/ChatPrompt.js";
3
+ import { InstructionPrompt } from "../../../model-function/generate-text/prompt-template/InstructionPrompt.js";
4
4
  import { OpenAIChatPrompt } from "./AbstractOpenAIChatModel.js";
5
5
  /**
6
6
  * OpenAIMessage[] identity chat format.
@@ -13,8 +13,8 @@ export declare function text(): TextGenerationPromptTemplate<string, OpenAIChatP
13
13
  /**
14
14
  * Formats an instruction prompt as an OpenAI chat prompt.
15
15
  */
16
- export declare function instruction(): TextGenerationPromptTemplate<MultiModalInstructionPrompt | TextInstructionPrompt, OpenAIChatPrompt>;
16
+ export declare function instruction(): TextGenerationPromptTemplate<InstructionPrompt, OpenAIChatPrompt>;
17
17
  /**
18
18
  * Formats a chat prompt as an OpenAI chat prompt.
19
19
  */
20
- export declare function chat(): TextGenerationPromptTemplate<MultiModalChatPrompt | TextChatPrompt, OpenAIChatPrompt>;
20
+ export declare function chat(): TextGenerationPromptTemplate<ChatPrompt, OpenAIChatPrompt>;
@@ -1,4 +1,3 @@
1
- import { validateChatPrompt, } from "../../../model-function/generate-text/prompt-template/ChatPrompt.js";
2
1
  import { OpenAIChatMessage } from "./OpenAIChatMessage.js";
3
2
  /**
4
3
  * OpenAIMessage[] identity chat format.
@@ -37,7 +36,6 @@ export function instruction() {
37
36
  export function chat() {
38
37
  return {
39
38
  format(prompt) {
40
- validateChatPrompt(prompt);
41
39
  const messages = [];
42
40
  if (prompt.system != null) {
43
41
  messages.push(OpenAIChatMessage.system(prompt.system));
@@ -35,11 +35,11 @@ export declare class OpenAICompatibleChatModel extends AbstractOpenAIChatModel<O
35
35
  /**
36
36
  * Returns this model with an instruction prompt template.
37
37
  */
38
- withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").MultiModalInstructionPrompt | import("../../index.js").TextInstructionPrompt, OpenAIChatPrompt, OpenAICompatibleChatSettings, this>;
38
+ withInstructionPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").InstructionPrompt, OpenAIChatPrompt, OpenAICompatibleChatSettings, this>;
39
39
  /**
40
40
  * Returns this model with a chat prompt template.
41
41
  */
42
- withChatPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").TextChatPrompt | import("../../index.js").MultiModalChatPrompt, OpenAIChatPrompt, OpenAICompatibleChatSettings, this>;
42
+ withChatPrompt(): PromptTemplateTextStreamingModel<import("../../index.js").ChatPrompt, OpenAIChatPrompt, OpenAICompatibleChatSettings, this>;
43
43
  withPromptTemplate<INPUT_PROMPT>(promptTemplate: TextGenerationPromptTemplate<INPUT_PROMPT, OpenAIChatPrompt>): PromptTemplateTextStreamingModel<INPUT_PROMPT, OpenAIChatPrompt, OpenAICompatibleChatSettings, this>;
44
44
  withSettings(additionalSettings: Partial<OpenAICompatibleChatSettings>): this;
45
45
  }
@@ -78,7 +78,7 @@ export declare class StabilityImageGenerationModel extends AbstractModel<Stabili
78
78
  }>;
79
79
  withTextPrompt(): PromptTemplateImageGenerationModel<string, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, this>;
80
80
  withPromptTemplate<INPUT_PROMPT>(promptTemplate: PromptTemplate<INPUT_PROMPT, StabilityImageGenerationPrompt>): PromptTemplateImageGenerationModel<INPUT_PROMPT, StabilityImageGenerationPrompt, StabilityImageGenerationSettings, this>;
81
- withSettings(additionalSettings: StabilityImageGenerationSettings): this;
81
+ withSettings(additionalSettings: Partial<StabilityImageGenerationSettings>): this;
82
82
  }
83
83
  declare const stabilityImageGenerationResponseSchema: z.ZodObject<{
84
84
  artifacts: z.ZodArray<z.ZodObject<{
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "The TypeScript library for building multi-modal AI applications.",
4
- "version": "0.103.0",
4
+ "version": "0.104.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [