modelfusion 0.45.3 → 0.47.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 (134) hide show
  1. package/README.md +92 -65
  2. package/index.cjs +0 -1
  3. package/index.d.ts +0 -1
  4. package/index.js +0 -1
  5. package/model-function/ModelFunctionPromise.cjs +37 -0
  6. package/model-function/ModelFunctionPromise.d.ts +18 -0
  7. package/model-function/ModelFunctionPromise.js +33 -0
  8. package/{prompt → model-function}/PromptFormat.d.ts +0 -5
  9. package/model-function/describe-image/describeImage.cjs +3 -2
  10. package/model-function/describe-image/describeImage.d.ts +1 -1
  11. package/model-function/describe-image/describeImage.js +3 -2
  12. package/model-function/embed/embed.cjs +5 -4
  13. package/model-function/embed/embed.d.ts +1 -1
  14. package/model-function/embed/embed.js +5 -4
  15. package/model-function/executeCall.cjs +3 -46
  16. package/model-function/executeCall.d.ts +5 -18
  17. package/model-function/executeCall.js +1 -43
  18. package/model-function/generate-image/ImageGenerationModel.d.ts +2 -0
  19. package/model-function/generate-image/ImageGenerationPromise.cjs +50 -0
  20. package/model-function/generate-image/ImageGenerationPromise.d.ts +22 -0
  21. package/model-function/generate-image/ImageGenerationPromise.js +46 -0
  22. package/model-function/generate-image/PromptFormatImageGenerationModel.cjs +44 -0
  23. package/model-function/generate-image/PromptFormatImageGenerationModel.d.ts +20 -0
  24. package/model-function/generate-image/PromptFormatImageGenerationModel.js +40 -0
  25. package/model-function/generate-image/generateImage.cjs +3 -2
  26. package/model-function/generate-image/generateImage.d.ts +2 -2
  27. package/model-function/generate-image/generateImage.js +3 -2
  28. package/model-function/generate-structure/generateStructure.cjs +3 -2
  29. package/model-function/generate-structure/generateStructure.d.ts +1 -1
  30. package/model-function/generate-structure/generateStructure.js +3 -2
  31. package/model-function/generate-structure/generateStructureOrText.cjs +3 -2
  32. package/model-function/generate-structure/generateStructureOrText.d.ts +1 -1
  33. package/model-function/generate-structure/generateStructureOrText.js +3 -2
  34. package/{prompt → model-function/generate-text}/AlpacaPromptFormat.d.ts +2 -2
  35. package/{prompt → model-function/generate-text}/Llama2PromptFormat.cjs +1 -1
  36. package/model-function/generate-text/Llama2PromptFormat.d.ts +13 -0
  37. package/{prompt → model-function/generate-text}/Llama2PromptFormat.js +1 -1
  38. package/{prompt → model-function/generate-text}/PromptFormatTextGenerationModel.d.ts +7 -7
  39. package/{prompt → model-function/generate-text}/PromptFormatTextStreamingModel.d.ts +6 -6
  40. package/model-function/generate-text/TextGenerationModel.d.ts +10 -3
  41. package/model-function/generate-text/TextGenerationPromptFormat.cjs +2 -0
  42. package/model-function/generate-text/TextGenerationPromptFormat.d.ts +11 -0
  43. package/model-function/generate-text/TextGenerationPromptFormat.js +1 -0
  44. package/{prompt → model-function/generate-text}/TextPromptFormat.cjs +2 -2
  45. package/model-function/generate-text/TextPromptFormat.d.ts +17 -0
  46. package/{prompt → model-function/generate-text}/TextPromptFormat.js +2 -2
  47. package/{prompt → model-function/generate-text}/VicunaPromptFormat.cjs +1 -1
  48. package/{prompt → model-function/generate-text}/VicunaPromptFormat.d.ts +3 -3
  49. package/{prompt → model-function/generate-text}/VicunaPromptFormat.js +1 -1
  50. package/model-function/generate-text/generateText.cjs +6 -3
  51. package/model-function/generate-text/generateText.d.ts +1 -1
  52. package/model-function/generate-text/generateText.js +6 -3
  53. package/{prompt → model-function/generate-text}/index.cjs +9 -4
  54. package/model-function/generate-text/index.d.ts +16 -0
  55. package/model-function/generate-text/index.js +16 -0
  56. package/{prompt/chat → model-function/generate-text}/trimChatPrompt.d.ts +2 -5
  57. package/model-function/index.cjs +3 -5
  58. package/model-function/index.d.ts +3 -5
  59. package/model-function/index.js +3 -5
  60. package/model-function/synthesize-speech/synthesizeSpeech.cjs +3 -2
  61. package/model-function/synthesize-speech/synthesizeSpeech.d.ts +1 -1
  62. package/model-function/synthesize-speech/synthesizeSpeech.js +3 -2
  63. package/model-function/transcribe-speech/transcribe.cjs +3 -2
  64. package/model-function/transcribe-speech/transcribe.d.ts +1 -1
  65. package/model-function/transcribe-speech/transcribe.js +3 -2
  66. package/model-provider/anthropic/AnthropicPromptFormat.cjs +1 -1
  67. package/model-provider/anthropic/AnthropicPromptFormat.d.ts +5 -5
  68. package/model-provider/anthropic/AnthropicPromptFormat.js +1 -1
  69. package/model-provider/anthropic/AnthropicTextGenerationModel.cjs +14 -1
  70. package/model-provider/anthropic/AnthropicTextGenerationModel.d.ts +11 -3
  71. package/model-provider/anthropic/AnthropicTextGenerationModel.js +14 -1
  72. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +11 -0
  73. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +12 -12
  74. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +11 -0
  75. package/model-provider/automatic1111/Automatic1111ImageGenerationPrompt.cjs +12 -0
  76. package/model-provider/automatic1111/Automatic1111ImageGenerationPrompt.d.ts +10 -0
  77. package/model-provider/automatic1111/Automatic1111ImageGenerationPrompt.js +8 -0
  78. package/model-provider/automatic1111/index.cjs +1 -0
  79. package/model-provider/automatic1111/index.d.ts +1 -0
  80. package/model-provider/automatic1111/index.js +1 -0
  81. package/model-provider/cohere/CohereTextGenerationModel.cjs +14 -1
  82. package/model-provider/cohere/CohereTextGenerationModel.d.ts +14 -3
  83. package/model-provider/cohere/CohereTextGenerationModel.js +14 -1
  84. package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +2 -2
  85. package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +5 -5
  86. package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +2 -2
  87. package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +1 -1
  88. package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +3 -3
  89. package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +1 -1
  90. package/model-provider/openai/OpenAIImageGenerationModel.cjs +8 -1
  91. package/model-provider/openai/OpenAIImageGenerationModel.d.ts +6 -3
  92. package/model-provider/openai/OpenAIImageGenerationModel.js +8 -1
  93. package/model-provider/openai/OpenAITextGenerationModel.cjs +14 -1
  94. package/model-provider/openai/OpenAITextGenerationModel.d.ts +14 -3
  95. package/model-provider/openai/OpenAITextGenerationModel.js +14 -1
  96. package/model-provider/openai/chat/OpenAIChatModel.cjs +14 -1
  97. package/model-provider/openai/chat/OpenAIChatModel.d.ts +11 -3
  98. package/model-provider/openai/chat/OpenAIChatModel.js +14 -1
  99. package/model-provider/openai/chat/OpenAIChatPromptFormat.cjs +1 -1
  100. package/model-provider/openai/chat/OpenAIChatPromptFormat.d.ts +5 -5
  101. package/model-provider/openai/chat/OpenAIChatPromptFormat.js +1 -1
  102. package/model-provider/stability/StabilityImageGenerationModel.cjs +11 -0
  103. package/model-provider/stability/StabilityImageGenerationModel.d.ts +15 -14
  104. package/model-provider/stability/StabilityImageGenerationModel.js +11 -0
  105. package/model-provider/stability/StabilityImageGenerationPrompt.cjs +12 -0
  106. package/model-provider/stability/StabilityImageGenerationPrompt.d.ts +9 -0
  107. package/model-provider/stability/StabilityImageGenerationPrompt.js +8 -0
  108. package/model-provider/stability/index.cjs +1 -0
  109. package/model-provider/stability/index.d.ts +1 -0
  110. package/model-provider/stability/index.js +1 -0
  111. package/package.json +1 -1
  112. package/prompt/Llama2PromptFormat.d.ts +0 -13
  113. package/prompt/TextPromptFormat.d.ts +0 -17
  114. package/prompt/index.d.ts +0 -11
  115. package/prompt/index.js +0 -11
  116. /package/{prompt → model-function}/PromptFormat.cjs +0 -0
  117. /package/{prompt → model-function}/PromptFormat.js +0 -0
  118. /package/{prompt → model-function/generate-text}/AlpacaPromptFormat.cjs +0 -0
  119. /package/{prompt → model-function/generate-text}/AlpacaPromptFormat.js +0 -0
  120. /package/{prompt/chat → model-function/generate-text}/ChatPrompt.cjs +0 -0
  121. /package/{prompt/chat → model-function/generate-text}/ChatPrompt.d.ts +0 -0
  122. /package/{prompt/chat → model-function/generate-text}/ChatPrompt.js +0 -0
  123. /package/{prompt → model-function/generate-text}/InstructionPrompt.cjs +0 -0
  124. /package/{prompt → model-function/generate-text}/InstructionPrompt.d.ts +0 -0
  125. /package/{prompt → model-function/generate-text}/InstructionPrompt.js +0 -0
  126. /package/{prompt → model-function/generate-text}/PromptFormatTextGenerationModel.cjs +0 -0
  127. /package/{prompt → model-function/generate-text}/PromptFormatTextGenerationModel.js +0 -0
  128. /package/{prompt → model-function/generate-text}/PromptFormatTextStreamingModel.cjs +0 -0
  129. /package/{prompt → model-function/generate-text}/PromptFormatTextStreamingModel.js +0 -0
  130. /package/{prompt/chat → model-function/generate-text}/trimChatPrompt.cjs +0 -0
  131. /package/{prompt/chat → model-function/generate-text}/trimChatPrompt.js +0 -0
  132. /package/{prompt/chat → model-function/generate-text}/validateChatPrompt.cjs +0 -0
  133. /package/{prompt/chat → model-function/generate-text}/validateChatPrompt.d.ts +0 -0
  134. /package/{prompt/chat → model-function/generate-text}/validateChatPrompt.js +0 -0
@@ -2,8 +2,10 @@ import { z } from "zod";
2
2
  import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
3
3
  import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
4
4
  import { AbstractModel } from "../../model-function/AbstractModel.js";
5
+ import { PromptFormatImageGenerationModel } from "../../model-function/generate-image/PromptFormatImageGenerationModel.js";
5
6
  import { StabilityApiConfiguration } from "./StabilityApiConfiguration.js";
6
7
  import { failedStabilityCallResponseHandler } from "./StabilityError.js";
8
+ import { mapBasicPromptToStabilityFormat, } from "./StabilityImageGenerationPrompt.js";
7
9
  /**
8
10
  * Create an image generation model that calls the Stability AI image generation API.
9
11
  *
@@ -73,6 +75,15 @@ export class StabilityImageGenerationModel extends AbstractModel {
73
75
  base64Image: response.artifacts[0].base64,
74
76
  };
75
77
  }
78
+ withBasicPrompt() {
79
+ return this.withPromptFormat(mapBasicPromptToStabilityFormat());
80
+ }
81
+ withPromptFormat(promptFormat) {
82
+ return new PromptFormatImageGenerationModel({
83
+ model: this,
84
+ promptFormat,
85
+ });
86
+ }
76
87
  withSettings(additionalSettings) {
77
88
  return new StabilityImageGenerationModel(Object.assign({}, this.settings, additionalSettings));
78
89
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapBasicPromptToStabilityFormat = void 0;
4
+ /**
5
+ * Formats a basic text prompt as a Stability prompt.
6
+ */
7
+ function mapBasicPromptToStabilityFormat() {
8
+ return {
9
+ format: (description) => [{ text: description }],
10
+ };
11
+ }
12
+ exports.mapBasicPromptToStabilityFormat = mapBasicPromptToStabilityFormat;
@@ -0,0 +1,9 @@
1
+ import { PromptFormat } from "../../model-function/PromptFormat.js";
2
+ export type StabilityImageGenerationPrompt = Array<{
3
+ text: string;
4
+ weight?: number;
5
+ }>;
6
+ /**
7
+ * Formats a basic text prompt as a Stability prompt.
8
+ */
9
+ export declare function mapBasicPromptToStabilityFormat(): PromptFormat<string, StabilityImageGenerationPrompt>;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Formats a basic text prompt as a Stability prompt.
3
+ */
4
+ export function mapBasicPromptToStabilityFormat() {
5
+ return {
6
+ format: (description) => [{ text: description }],
7
+ };
8
+ }
@@ -19,3 +19,4 @@ __exportStar(require("./StabilityApiConfiguration.cjs"), exports);
19
19
  var StabilityError_js_1 = require("./StabilityError.cjs");
20
20
  Object.defineProperty(exports, "StabilityError", { enumerable: true, get: function () { return StabilityError_js_1.StabilityError; } });
21
21
  __exportStar(require("./StabilityImageGenerationModel.cjs"), exports);
22
+ __exportStar(require("./StabilityImageGenerationPrompt.cjs"), exports);
@@ -1,3 +1,4 @@
1
1
  export * from "./StabilityApiConfiguration.js";
2
2
  export { StabilityError, StabilityErrorData } from "./StabilityError.js";
3
3
  export * from "./StabilityImageGenerationModel.js";
4
+ export * from "./StabilityImageGenerationPrompt.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./StabilityApiConfiguration.js";
2
2
  export { StabilityError } from "./StabilityError.js";
3
3
  export * from "./StabilityImageGenerationModel.js";
4
+ export * from "./StabilityImageGenerationPrompt.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modelfusion",
3
3
  "description": "Build multimodal applications, chatbots, and agents with JavaScript and TypeScript.",
4
- "version": "0.45.3",
4
+ "version": "0.47.0",
5
5
  "author": "Lars Grammel",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -1,13 +0,0 @@
1
- import { PromptFormat } from "./PromptFormat.js";
2
- import { InstructionPrompt } from "./InstructionPrompt.js";
3
- import { ChatPrompt } from "./chat/ChatPrompt.js";
4
- /**
5
- * Formats an instruction prompt as a Llama 2 prompt.
6
- *
7
- * @see https://www.philschmid.de/llama-2#how-to-prompt-llama-2-chat
8
- */
9
- export declare function mapInstructionPromptToLlama2Format(): PromptFormat<InstructionPrompt, string>;
10
- /**
11
- * Formats a chat prompt as a Llama 2 prompt.
12
- */
13
- export declare function mapChatPromptToLlama2Format(): PromptFormat<ChatPrompt, string>;
@@ -1,17 +0,0 @@
1
- import { PromptFormat } from "./PromptFormat.js";
2
- import { InstructionPrompt } from "./InstructionPrompt.js";
3
- import { ChatPrompt } from "./chat/ChatPrompt.js";
4
- /**
5
- * Formats an instruction prompt as a basic text prompt.
6
- */
7
- export declare const mapInstructionPromptToTextFormat: () => PromptFormat<InstructionPrompt, string>;
8
- /**
9
- * Formats a chat prompt as a basic text prompt.
10
- *
11
- * @param user The label of the user in the chat.
12
- * @param ai The name of the AI in the chat.
13
- */
14
- export declare const mapChatPromptToTextFormat: ({ user, ai, }: {
15
- user: string;
16
- ai: string;
17
- }) => PromptFormat<ChatPrompt, string>;
package/prompt/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- export * from "./AlpacaPromptFormat.js";
2
- export * from "./InstructionPrompt.js";
3
- export * from "./Llama2PromptFormat.js";
4
- export * from "./PromptFormat.js";
5
- export * from "./PromptFormatTextGenerationModel.js";
6
- export * from "./PromptFormatTextStreamingModel.js";
7
- export * from "./TextPromptFormat.js";
8
- export * from "./VicunaPromptFormat.js";
9
- export * from "./chat/ChatPrompt.js";
10
- export * from "./chat/trimChatPrompt.js";
11
- export * from "./chat/validateChatPrompt.js";
package/prompt/index.js DELETED
@@ -1,11 +0,0 @@
1
- export * from "./AlpacaPromptFormat.js";
2
- export * from "./InstructionPrompt.js";
3
- export * from "./Llama2PromptFormat.js";
4
- export * from "./PromptFormat.js";
5
- export * from "./PromptFormatTextGenerationModel.js";
6
- export * from "./PromptFormatTextStreamingModel.js";
7
- export * from "./TextPromptFormat.js";
8
- export * from "./VicunaPromptFormat.js";
9
- export * from "./chat/ChatPrompt.js";
10
- export * from "./chat/trimChatPrompt.js";
11
- export * from "./chat/validateChatPrompt.js";
File without changes
File without changes