modelfusion 0.135.1 → 0.137.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 +2359 -0
- package/README.md +697 -0
- package/index.cjs +103 -305
- package/index.cjs.map +1 -1
- package/index.d.cts +112 -197
- package/index.d.ts +112 -197
- package/index.js +101 -292
- package/index.js.map +1 -1
- package/node/index.cjs +184 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +92 -0
- package/node/index.d.ts +92 -0
- package/node/index.js +147 -0
- package/node/index.js.map +1 -0
- package/package.json +11 -3
    
        package/index.js
    CHANGED
    
    | @@ -69,6 +69,11 @@ var DefaultRun = class { | |
| 69 69 | 
             
                  this.functionEventSource.notify(event);
         | 
| 70 70 | 
             
                }
         | 
| 71 71 | 
             
              };
         | 
| 72 | 
            +
              getSuccessfulModelCalls() {
         | 
| 73 | 
            +
                return this.events.filter(
         | 
| 74 | 
            +
                  (event) => "model" in event && "result" in event && "status" in event.result && event.result.status === "success"
         | 
| 75 | 
            +
                );
         | 
| 76 | 
            +
              }
         | 
| 72 77 | 
             
            };
         | 
| 73 78 |  | 
| 74 79 | 
             
            // src/core/ModelFusionConfiguration.ts
         | 
| @@ -8185,134 +8190,45 @@ async function countOpenAIChatPromptTokens({ | |
| 8185 8190 | 
             
            }
         | 
| 8186 8191 |  | 
| 8187 8192 | 
             
            // src/model-provider/openai/OpenAIChatModel.ts
         | 
| 8188 | 
            -
            var  | 
| 8189 | 
            -
              "gpt-4":  | 
| 8190 | 
            -
             | 
| 8191 | 
            -
             | 
| 8192 | 
            -
             | 
| 8193 | 
            -
               | 
| 8194 | 
            -
              "gpt-4- | 
| 8195 | 
            -
             | 
| 8196 | 
            -
             | 
| 8197 | 
            -
             | 
| 8198 | 
            -
               | 
| 8199 | 
            -
              "gpt- | 
| 8200 | 
            -
             | 
| 8201 | 
            -
             | 
| 8202 | 
            -
             | 
| 8203 | 
            -
             | 
| 8204 | 
            -
             | 
| 8205 | 
            -
               | 
| 8206 | 
            -
              "gpt-4-turbo-preview": {
         | 
| 8207 | 
            -
                contextWindowSize: 128e3,
         | 
| 8208 | 
            -
                promptTokenCostInMillicents: 1,
         | 
| 8209 | 
            -
                completionTokenCostInMillicents: 3
         | 
| 8210 | 
            -
              },
         | 
| 8211 | 
            -
              "gpt-4-1106-preview": {
         | 
| 8212 | 
            -
                contextWindowSize: 128e3,
         | 
| 8213 | 
            -
                promptTokenCostInMillicents: 1,
         | 
| 8214 | 
            -
                completionTokenCostInMillicents: 3
         | 
| 8215 | 
            -
              },
         | 
| 8216 | 
            -
              "gpt-4-0125-preview": {
         | 
| 8217 | 
            -
                contextWindowSize: 128e3,
         | 
| 8218 | 
            -
                promptTokenCostInMillicents: 1,
         | 
| 8219 | 
            -
                completionTokenCostInMillicents: 3
         | 
| 8220 | 
            -
              },
         | 
| 8221 | 
            -
              "gpt-4-vision-preview": {
         | 
| 8222 | 
            -
                contextWindowSize: 128e3,
         | 
| 8223 | 
            -
                promptTokenCostInMillicents: 1,
         | 
| 8224 | 
            -
                completionTokenCostInMillicents: 3
         | 
| 8225 | 
            -
              },
         | 
| 8226 | 
            -
              "gpt-4-32k": {
         | 
| 8227 | 
            -
                contextWindowSize: 32768,
         | 
| 8228 | 
            -
                promptTokenCostInMillicents: 6,
         | 
| 8229 | 
            -
                completionTokenCostInMillicents: 12
         | 
| 8230 | 
            -
              },
         | 
| 8231 | 
            -
              "gpt-4-32k-0314": {
         | 
| 8232 | 
            -
                contextWindowSize: 32768,
         | 
| 8233 | 
            -
                promptTokenCostInMillicents: 6,
         | 
| 8234 | 
            -
                completionTokenCostInMillicents: 12
         | 
| 8235 | 
            -
              },
         | 
| 8236 | 
            -
              "gpt-4-32k-0613": {
         | 
| 8237 | 
            -
                contextWindowSize: 32768,
         | 
| 8238 | 
            -
                promptTokenCostInMillicents: 6,
         | 
| 8239 | 
            -
                completionTokenCostInMillicents: 12
         | 
| 8240 | 
            -
              },
         | 
| 8241 | 
            -
              "gpt-3.5-turbo": {
         | 
| 8242 | 
            -
                contextWindowSize: 4096,
         | 
| 8243 | 
            -
                promptTokenCostInMillicents: 0.15,
         | 
| 8244 | 
            -
                completionTokenCostInMillicents: 0.2,
         | 
| 8245 | 
            -
                fineTunedPromptTokenCostInMillicents: 0.3,
         | 
| 8246 | 
            -
                fineTunedCompletionTokenCostInMillicents: 0.6
         | 
| 8247 | 
            -
              },
         | 
| 8248 | 
            -
              "gpt-3.5-turbo-0125": {
         | 
| 8249 | 
            -
                contextWindowSize: 16385,
         | 
| 8250 | 
            -
                promptTokenCostInMillicents: 0.05,
         | 
| 8251 | 
            -
                completionTokenCostInMillicents: 0.15
         | 
| 8252 | 
            -
              },
         | 
| 8253 | 
            -
              "gpt-3.5-turbo-1106": {
         | 
| 8254 | 
            -
                contextWindowSize: 16385,
         | 
| 8255 | 
            -
                promptTokenCostInMillicents: 0.1,
         | 
| 8256 | 
            -
                completionTokenCostInMillicents: 0.2
         | 
| 8257 | 
            -
              },
         | 
| 8258 | 
            -
              "gpt-3.5-turbo-0301": {
         | 
| 8259 | 
            -
                contextWindowSize: 4096,
         | 
| 8260 | 
            -
                promptTokenCostInMillicents: 0.15,
         | 
| 8261 | 
            -
                completionTokenCostInMillicents: 0.2
         | 
| 8262 | 
            -
              },
         | 
| 8263 | 
            -
              "gpt-3.5-turbo-0613": {
         | 
| 8264 | 
            -
                contextWindowSize: 4096,
         | 
| 8265 | 
            -
                promptTokenCostInMillicents: 0.15,
         | 
| 8266 | 
            -
                completionTokenCostInMillicents: 0.2,
         | 
| 8267 | 
            -
                fineTunedPromptTokenCostInMillicents: 1.2,
         | 
| 8268 | 
            -
                fineTunedCompletionTokenCostInMillicents: 1.6
         | 
| 8269 | 
            -
              },
         | 
| 8270 | 
            -
              "gpt-3.5-turbo-16k": {
         | 
| 8271 | 
            -
                contextWindowSize: 16384,
         | 
| 8272 | 
            -
                promptTokenCostInMillicents: 0.3,
         | 
| 8273 | 
            -
                completionTokenCostInMillicents: 0.4
         | 
| 8274 | 
            -
              },
         | 
| 8275 | 
            -
              "gpt-3.5-turbo-16k-0613": {
         | 
| 8276 | 
            -
                contextWindowSize: 16384,
         | 
| 8277 | 
            -
                promptTokenCostInMillicents: 0.3,
         | 
| 8278 | 
            -
                completionTokenCostInMillicents: 0.4
         | 
| 8279 | 
            -
              }
         | 
| 8193 | 
            +
            var CHAT_MODEL_CONTEXT_WINDOW_SIZES = {
         | 
| 8194 | 
            +
              "gpt-4": 8192,
         | 
| 8195 | 
            +
              "gpt-4-0314": 8192,
         | 
| 8196 | 
            +
              "gpt-4-0613": 8192,
         | 
| 8197 | 
            +
              "gpt-4-turbo-preview": 128e3,
         | 
| 8198 | 
            +
              "gpt-4-1106-preview": 128e3,
         | 
| 8199 | 
            +
              "gpt-4-0125-preview": 128e3,
         | 
| 8200 | 
            +
              "gpt-4-vision-preview": 128e3,
         | 
| 8201 | 
            +
              "gpt-4-32k": 32768,
         | 
| 8202 | 
            +
              "gpt-4-32k-0314": 32768,
         | 
| 8203 | 
            +
              "gpt-4-32k-0613": 32768,
         | 
| 8204 | 
            +
              "gpt-3.5-turbo": 4096,
         | 
| 8205 | 
            +
              "gpt-3.5-turbo-0125": 16385,
         | 
| 8206 | 
            +
              "gpt-3.5-turbo-1106": 16385,
         | 
| 8207 | 
            +
              "gpt-3.5-turbo-0301": 4096,
         | 
| 8208 | 
            +
              "gpt-3.5-turbo-0613": 4096,
         | 
| 8209 | 
            +
              "gpt-3.5-turbo-16k": 16384,
         | 
| 8210 | 
            +
              "gpt-3.5-turbo-16k-0613": 16384
         | 
| 8280 8211 | 
             
            };
         | 
| 8281 8212 | 
             
            function getOpenAIChatModelInformation(model) {
         | 
| 8282 | 
            -
              if (model in  | 
| 8283 | 
            -
                const  | 
| 8213 | 
            +
              if (model in CHAT_MODEL_CONTEXT_WINDOW_SIZES) {
         | 
| 8214 | 
            +
                const contextWindowSize = CHAT_MODEL_CONTEXT_WINDOW_SIZES[model];
         | 
| 8284 8215 | 
             
                return {
         | 
| 8285 8216 | 
             
                  baseModel: model,
         | 
| 8286 8217 | 
             
                  isFineTuned: false,
         | 
| 8287 | 
            -
                  contextWindowSize | 
| 8288 | 
            -
                  promptTokenCostInMillicents: baseModelInformation.promptTokenCostInMillicents,
         | 
| 8289 | 
            -
                  completionTokenCostInMillicents: baseModelInformation.completionTokenCostInMillicents
         | 
| 8218 | 
            +
                  contextWindowSize
         | 
| 8290 8219 | 
             
                };
         | 
| 8291 8220 | 
             
              }
         | 
| 8292 8221 | 
             
              const [_, baseModel, ___, ____, _____] = model.split(":");
         | 
| 8293 8222 | 
             
              if (["gpt-3.5-turbo", "gpt-3.5-turbo-0613", "gpt-4-0613"].includes(baseModel)) {
         | 
| 8294 | 
            -
                const  | 
| 8223 | 
            +
                const contextWindowSize = CHAT_MODEL_CONTEXT_WINDOW_SIZES[baseModel];
         | 
| 8295 8224 | 
             
                return {
         | 
| 8296 8225 | 
             
                  baseModel,
         | 
| 8297 8226 | 
             
                  isFineTuned: true,
         | 
| 8298 | 
            -
                  contextWindowSize | 
| 8299 | 
            -
                  promptTokenCostInMillicents: baseModelInformation.fineTunedPromptTokenCostInMillicents,
         | 
| 8300 | 
            -
                  completionTokenCostInMillicents: baseModelInformation.fineTunedCompletionTokenCostInMillicents
         | 
| 8227 | 
            +
                  contextWindowSize
         | 
| 8301 8228 | 
             
                };
         | 
| 8302 8229 | 
             
              }
         | 
| 8303 8230 | 
             
              throw new Error(`Unknown OpenAI chat base model ${baseModel}.`);
         | 
| 8304 8231 | 
             
            }
         | 
| 8305 | 
            -
            var isOpenAIChatModel = (model) => model in OPENAI_CHAT_MODELS || model.startsWith("ft:gpt-3.5-turbo-0613:") || model.startsWith("ft:gpt-3.5-turbo:");
         | 
| 8306 | 
            -
            var calculateOpenAIChatCostInMillicents = ({
         | 
| 8307 | 
            -
              model,
         | 
| 8308 | 
            -
              response
         | 
| 8309 | 
            -
            }) => {
         | 
| 8310 | 
            -
              const { promptTokenCostInMillicents, completionTokenCostInMillicents } = getOpenAIChatModelInformation(model);
         | 
| 8311 | 
            -
              if (promptTokenCostInMillicents == null || completionTokenCostInMillicents == null) {
         | 
| 8312 | 
            -
                return null;
         | 
| 8313 | 
            -
              }
         | 
| 8314 | 
            -
              return response.usage.prompt_tokens * promptTokenCostInMillicents + response.usage.completion_tokens * completionTokenCostInMillicents;
         | 
| 8315 | 
            -
            };
         | 
| 8316 8232 | 
             
            var OpenAIChatModel = class _OpenAIChatModel extends AbstractOpenAIChatModel {
         | 
| 8317 8233 | 
             
              constructor(settings) {
         | 
| 8318 8234 | 
             
                super(settings);
         | 
| @@ -8410,22 +8326,12 @@ var OpenAIChatModel = class _OpenAIChatModel extends AbstractOpenAIChatModel { | |
| 8410 8326 | 
             
            // src/model-provider/openai/OpenAICompletionModel.ts
         | 
| 8411 8327 | 
             
            var OPENAI_TEXT_GENERATION_MODELS = {
         | 
| 8412 8328 | 
             
              "gpt-3.5-turbo-instruct": {
         | 
| 8413 | 
            -
                contextWindowSize: 4097 | 
| 8414 | 
            -
                promptTokenCostInMillicents: 0.15,
         | 
| 8415 | 
            -
                completionTokenCostInMillicents: 0.2
         | 
| 8329 | 
            +
                contextWindowSize: 4097
         | 
| 8416 8330 | 
             
              }
         | 
| 8417 8331 | 
             
            };
         | 
| 8418 8332 | 
             
            function getOpenAICompletionModelInformation(model) {
         | 
| 8419 8333 | 
             
              return OPENAI_TEXT_GENERATION_MODELS[model];
         | 
| 8420 8334 | 
             
            }
         | 
| 8421 | 
            -
            var isOpenAICompletionModel = (model) => model in OPENAI_TEXT_GENERATION_MODELS;
         | 
| 8422 | 
            -
            var calculateOpenAICompletionCostInMillicents = ({
         | 
| 8423 | 
            -
              model,
         | 
| 8424 | 
            -
              response
         | 
| 8425 | 
            -
            }) => {
         | 
| 8426 | 
            -
              const modelInformation = getOpenAICompletionModelInformation(model);
         | 
| 8427 | 
            -
              return response.usage.prompt_tokens * modelInformation.promptTokenCostInMillicents + response.usage.completion_tokens * modelInformation.completionTokenCostInMillicents;
         | 
| 8428 | 
            -
            };
         | 
| 8429 8335 | 
             
            var OpenAICompletionModel = class _OpenAICompletionModel extends AbstractOpenAICompletionModel {
         | 
| 8430 8336 | 
             
              constructor(settings) {
         | 
| 8431 8337 | 
             
                super(settings);
         | 
| @@ -8510,60 +8416,6 @@ __export(OpenAIFacade_exports, { | |
| 8510 8416 |  | 
| 8511 8417 | 
             
            // src/model-provider/openai/OpenAIImageGenerationModel.ts
         | 
| 8512 8418 | 
             
            import { z as z27 } from "zod";
         | 
| 8513 | 
            -
            var OPENAI_IMAGE_MODELS = {
         | 
| 8514 | 
            -
              "dall-e-2": {
         | 
| 8515 | 
            -
                getCost(settings) {
         | 
| 8516 | 
            -
                  switch (settings.size ?? "1024x1024") {
         | 
| 8517 | 
            -
                    case "1024x1024":
         | 
| 8518 | 
            -
                      return 2e3;
         | 
| 8519 | 
            -
                    case "512x512":
         | 
| 8520 | 
            -
                      return 1800;
         | 
| 8521 | 
            -
                    case "256x256":
         | 
| 8522 | 
            -
                      return 1600;
         | 
| 8523 | 
            -
                    default:
         | 
| 8524 | 
            -
                      return null;
         | 
| 8525 | 
            -
                  }
         | 
| 8526 | 
            -
                }
         | 
| 8527 | 
            -
              },
         | 
| 8528 | 
            -
              "dall-e-3": {
         | 
| 8529 | 
            -
                getCost(settings) {
         | 
| 8530 | 
            -
                  switch (settings.quality ?? "standard") {
         | 
| 8531 | 
            -
                    case "standard": {
         | 
| 8532 | 
            -
                      switch (settings.size ?? "1024x1024") {
         | 
| 8533 | 
            -
                        case "1024x1024":
         | 
| 8534 | 
            -
                          return 4e3;
         | 
| 8535 | 
            -
                        case "1024x1792":
         | 
| 8536 | 
            -
                        case "1792x1024":
         | 
| 8537 | 
            -
                          return 8e3;
         | 
| 8538 | 
            -
                        default:
         | 
| 8539 | 
            -
                          return null;
         | 
| 8540 | 
            -
                      }
         | 
| 8541 | 
            -
                    }
         | 
| 8542 | 
            -
                    case "hd": {
         | 
| 8543 | 
            -
                      switch (settings.size ?? "1024x1024") {
         | 
| 8544 | 
            -
                        case "1024x1024":
         | 
| 8545 | 
            -
                          return 8e3;
         | 
| 8546 | 
            -
                        case "1024x1792":
         | 
| 8547 | 
            -
                        case "1792x1024":
         | 
| 8548 | 
            -
                          return 12e3;
         | 
| 8549 | 
            -
                        default:
         | 
| 8550 | 
            -
                          return null;
         | 
| 8551 | 
            -
                      }
         | 
| 8552 | 
            -
                    }
         | 
| 8553 | 
            -
                  }
         | 
| 8554 | 
            -
                }
         | 
| 8555 | 
            -
              }
         | 
| 8556 | 
            -
            };
         | 
| 8557 | 
            -
            var calculateOpenAIImageGenerationCostInMillicents = ({
         | 
| 8558 | 
            -
              model,
         | 
| 8559 | 
            -
              settings
         | 
| 8560 | 
            -
            }) => {
         | 
| 8561 | 
            -
              const cost = OPENAI_IMAGE_MODELS[model]?.getCost(settings);
         | 
| 8562 | 
            -
              if (cost == null) {
         | 
| 8563 | 
            -
                return null;
         | 
| 8564 | 
            -
              }
         | 
| 8565 | 
            -
              return (settings.numberOfGenerations ?? 1) * cost;
         | 
| 8566 | 
            -
            };
         | 
| 8567 8419 | 
             
            var OpenAIImageGenerationModel = class _OpenAIImageGenerationModel extends AbstractModel {
         | 
| 8568 8420 | 
             
              constructor(settings) {
         | 
| 8569 8421 | 
             
                super({ settings });
         | 
| @@ -8667,25 +8519,6 @@ var OpenAIImageGenerationResponseFormat = { | |
| 8667 8519 | 
             
            };
         | 
| 8668 8520 |  | 
| 8669 8521 | 
             
            // src/model-provider/openai/OpenAISpeechModel.ts
         | 
| 8670 | 
            -
            var OPENAI_SPEECH_MODELS = {
         | 
| 8671 | 
            -
              "tts-1": {
         | 
| 8672 | 
            -
                costInMillicentsPerCharacter: 1.5
         | 
| 8673 | 
            -
                // = 1500 / 1000,
         | 
| 8674 | 
            -
              },
         | 
| 8675 | 
            -
              "tts-1-hd": {
         | 
| 8676 | 
            -
                costInMillicentsPerCharacter: 3
         | 
| 8677 | 
            -
                // = 3000 / 1000
         | 
| 8678 | 
            -
              }
         | 
| 8679 | 
            -
            };
         | 
| 8680 | 
            -
            var calculateOpenAISpeechCostInMillicents = ({
         | 
| 8681 | 
            -
              model,
         | 
| 8682 | 
            -
              input
         | 
| 8683 | 
            -
            }) => {
         | 
| 8684 | 
            -
              if (!OPENAI_SPEECH_MODELS[model]) {
         | 
| 8685 | 
            -
                return null;
         | 
| 8686 | 
            -
              }
         | 
| 8687 | 
            -
              return input.length * OPENAI_SPEECH_MODELS[model].costInMillicentsPerCharacter;
         | 
| 8688 | 
            -
            };
         | 
| 8689 8522 | 
             
            var OpenAISpeechModel = class _OpenAISpeechModel extends AbstractModel {
         | 
| 8690 8523 | 
             
              constructor(settings) {
         | 
| 8691 8524 | 
             
                super({ settings });
         | 
| @@ -8744,34 +8577,37 @@ var OpenAISpeechModel = class _OpenAISpeechModel extends AbstractModel { | |
| 8744 8577 | 
             
            };
         | 
| 8745 8578 |  | 
| 8746 8579 | 
             
            // src/model-provider/openai/OpenAITextEmbeddingModel.ts
         | 
| 8580 | 
            +
            import z28 from "zod";
         | 
| 8747 8581 | 
             
            var OPENAI_TEXT_EMBEDDING_MODELS = {
         | 
| 8748 8582 | 
             
              "text-embedding-3-small": {
         | 
| 8749 8583 | 
             
                contextWindowSize: 8192,
         | 
| 8750 | 
            -
                dimensions: 1536 | 
| 8751 | 
            -
                tokenCostInMillicents: 2e-3
         | 
| 8584 | 
            +
                dimensions: 1536
         | 
| 8752 8585 | 
             
              },
         | 
| 8753 8586 | 
             
              "text-embedding-3-large": {
         | 
| 8754 8587 | 
             
                contextWindowSize: 8192,
         | 
| 8755 | 
            -
                dimensions: 3072 | 
| 8756 | 
            -
                tokenCostInMillicents: 0.013
         | 
| 8588 | 
            +
                dimensions: 3072
         | 
| 8757 8589 | 
             
              },
         | 
| 8758 8590 | 
             
              "text-embedding-ada-002": {
         | 
| 8759 8591 | 
             
                contextWindowSize: 8192,
         | 
| 8760 | 
            -
                dimensions: 1536 | 
| 8761 | 
            -
                tokenCostInMillicents: 0.01
         | 
| 8762 | 
            -
              }
         | 
| 8763 | 
            -
            };
         | 
| 8764 | 
            -
            var isOpenAIEmbeddingModel = (model) => model in OPENAI_TEXT_EMBEDDING_MODELS;
         | 
| 8765 | 
            -
            var calculateOpenAIEmbeddingCostInMillicents = ({
         | 
| 8766 | 
            -
              model,
         | 
| 8767 | 
            -
              responses
         | 
| 8768 | 
            -
            }) => {
         | 
| 8769 | 
            -
              let amountInMilliseconds = 0;
         | 
| 8770 | 
            -
              for (const response of responses) {
         | 
| 8771 | 
            -
                amountInMilliseconds += response.usage.total_tokens * OPENAI_TEXT_EMBEDDING_MODELS[model].tokenCostInMillicents;
         | 
| 8592 | 
            +
                dimensions: 1536
         | 
| 8772 8593 | 
             
              }
         | 
| 8773 | 
            -
              return amountInMilliseconds;
         | 
| 8774 8594 | 
             
            };
         | 
| 8595 | 
            +
            var openAITextEmbeddingResponseSchema2 = z28.object({
         | 
| 8596 | 
            +
              object: z28.literal("list"),
         | 
| 8597 | 
            +
              data: z28.array(
         | 
| 8598 | 
            +
                z28.object({
         | 
| 8599 | 
            +
                  object: z28.literal("embedding"),
         | 
| 8600 | 
            +
                  embedding: z28.array(z28.number()),
         | 
| 8601 | 
            +
                  index: z28.number()
         | 
| 8602 | 
            +
                })
         | 
| 8603 | 
            +
              ),
         | 
| 8604 | 
            +
              model: z28.string(),
         | 
| 8605 | 
            +
              usage: z28.object({
         | 
| 8606 | 
            +
                prompt_tokens: z28.number(),
         | 
| 8607 | 
            +
                total_tokens: z28.number()
         | 
| 8608 | 
            +
              }).optional()
         | 
| 8609 | 
            +
              // for openai-compatible models
         | 
| 8610 | 
            +
            });
         | 
| 8775 8611 | 
             
            var OpenAITextEmbeddingModel = class _OpenAITextEmbeddingModel extends AbstractOpenAITextEmbeddingModel {
         | 
| 8776 8612 | 
             
              constructor(settings) {
         | 
| 8777 8613 | 
             
                super(settings);
         | 
| @@ -8800,7 +8636,7 @@ var OpenAITextEmbeddingModel = class _OpenAITextEmbeddingModel extends AbstractO | |
| 8800 8636 | 
             
            };
         | 
| 8801 8637 |  | 
| 8802 8638 | 
             
            // src/model-provider/openai/OpenAITranscriptionModel.ts
         | 
| 8803 | 
            -
            import { z as  | 
| 8639 | 
            +
            import { z as z29 } from "zod";
         | 
| 8804 8640 |  | 
| 8805 8641 | 
             
            // src/util/audio/getAudioFileExtension.ts
         | 
| 8806 8642 | 
             
            function getAudioFileExtension(mimeType) {
         | 
| @@ -8830,22 +8666,6 @@ function getAudioFileExtension(mimeType) { | |
| 8830 8666 | 
             
            }
         | 
| 8831 8667 |  | 
| 8832 8668 | 
             
            // src/model-provider/openai/OpenAITranscriptionModel.ts
         | 
| 8833 | 
            -
            var OPENAI_TRANSCRIPTION_MODELS = {
         | 
| 8834 | 
            -
              "whisper-1": {
         | 
| 8835 | 
            -
                costInMillicentsPerSecond: 10
         | 
| 8836 | 
            -
                // = 600 / 60,
         | 
| 8837 | 
            -
              }
         | 
| 8838 | 
            -
            };
         | 
| 8839 | 
            -
            var calculateOpenAITranscriptionCostInMillicents = ({
         | 
| 8840 | 
            -
              model,
         | 
| 8841 | 
            -
              response
         | 
| 8842 | 
            -
            }) => {
         | 
| 8843 | 
            -
              if (model !== "whisper-1") {
         | 
| 8844 | 
            -
                return null;
         | 
| 8845 | 
            -
              }
         | 
| 8846 | 
            -
              const durationInSeconds = response.duration;
         | 
| 8847 | 
            -
              return Math.ceil(durationInSeconds) * OPENAI_TRANSCRIPTION_MODELS[model].costInMillicentsPerSecond;
         | 
| 8848 | 
            -
            };
         | 
| 8849 8669 | 
             
            var OpenAITranscriptionModel = class _OpenAITranscriptionModel extends AbstractModel {
         | 
| 8850 8670 | 
             
              constructor(settings) {
         | 
| 8851 8671 | 
             
                super({ settings });
         | 
| @@ -8931,29 +8751,29 @@ var OpenAITranscriptionModel = class _OpenAITranscriptionModel extends AbstractM | |
| 8931 8751 | 
             
                );
         | 
| 8932 8752 | 
             
              }
         | 
| 8933 8753 | 
             
            };
         | 
| 8934 | 
            -
            var openAITranscriptionJsonSchema =  | 
| 8935 | 
            -
              text:  | 
| 8754 | 
            +
            var openAITranscriptionJsonSchema = z29.object({
         | 
| 8755 | 
            +
              text: z29.string()
         | 
| 8936 8756 | 
             
            });
         | 
| 8937 | 
            -
            var openAITranscriptionVerboseJsonSchema =  | 
| 8938 | 
            -
              task:  | 
| 8939 | 
            -
              language:  | 
| 8940 | 
            -
              duration:  | 
| 8941 | 
            -
              segments:  | 
| 8942 | 
            -
                 | 
| 8943 | 
            -
                  id:  | 
| 8944 | 
            -
                  seek:  | 
| 8945 | 
            -
                  start:  | 
| 8946 | 
            -
                  end:  | 
| 8947 | 
            -
                  text:  | 
| 8948 | 
            -
                  tokens:  | 
| 8949 | 
            -
                  temperature:  | 
| 8950 | 
            -
                  avg_logprob:  | 
| 8951 | 
            -
                  compression_ratio:  | 
| 8952 | 
            -
                  no_speech_prob:  | 
| 8953 | 
            -
                  transient:  | 
| 8757 | 
            +
            var openAITranscriptionVerboseJsonSchema = z29.object({
         | 
| 8758 | 
            +
              task: z29.literal("transcribe"),
         | 
| 8759 | 
            +
              language: z29.string(),
         | 
| 8760 | 
            +
              duration: z29.number(),
         | 
| 8761 | 
            +
              segments: z29.array(
         | 
| 8762 | 
            +
                z29.object({
         | 
| 8763 | 
            +
                  id: z29.number(),
         | 
| 8764 | 
            +
                  seek: z29.number(),
         | 
| 8765 | 
            +
                  start: z29.number(),
         | 
| 8766 | 
            +
                  end: z29.number(),
         | 
| 8767 | 
            +
                  text: z29.string(),
         | 
| 8768 | 
            +
                  tokens: z29.array(z29.number()),
         | 
| 8769 | 
            +
                  temperature: z29.number(),
         | 
| 8770 | 
            +
                  avg_logprob: z29.number(),
         | 
| 8771 | 
            +
                  compression_ratio: z29.number(),
         | 
| 8772 | 
            +
                  no_speech_prob: z29.number(),
         | 
| 8773 | 
            +
                  transient: z29.boolean().optional()
         | 
| 8954 8774 | 
             
                })
         | 
| 8955 8775 | 
             
              ),
         | 
| 8956 | 
            -
              text:  | 
| 8776 | 
            +
              text: z29.string()
         | 
| 8957 8777 | 
             
            });
         | 
| 8958 8778 | 
             
            var OpenAITranscriptionResponseFormat = {
         | 
| 8959 8779 | 
             
              json: {
         | 
| @@ -9293,9 +9113,9 @@ var StabilityApiConfiguration = class extends BaseUrlApiConfigurationWithDefault | |
| 9293 9113 | 
             
            };
         | 
| 9294 9114 |  | 
| 9295 9115 | 
             
            // src/model-provider/stability/StabilityError.ts
         | 
| 9296 | 
            -
            import { z as  | 
| 9297 | 
            -
            var stabilityErrorDataSchema =  | 
| 9298 | 
            -
              message:  | 
| 9116 | 
            +
            import { z as z30 } from "zod";
         | 
| 9117 | 
            +
            var stabilityErrorDataSchema = z30.object({
         | 
| 9118 | 
            +
              message: z30.string()
         | 
| 9299 9119 | 
             
            });
         | 
| 9300 9120 | 
             
            var failedStabilityCallResponseHandler = createJsonErrorResponseHandler({
         | 
| 9301 9121 | 
             
              errorSchema: zodSchema(stabilityErrorDataSchema),
         | 
| @@ -9310,7 +9130,7 @@ __export(StabilityFacade_exports, { | |
| 9310 9130 | 
             
            });
         | 
| 9311 9131 |  | 
| 9312 9132 | 
             
            // src/model-provider/stability/StabilityImageGenerationModel.ts
         | 
| 9313 | 
            -
            import { z as  | 
| 9133 | 
            +
            import { z as z31 } from "zod";
         | 
| 9314 9134 |  | 
| 9315 9135 | 
             
            // src/model-provider/stability/StabilityImageGenerationPrompt.ts
         | 
| 9316 9136 | 
             
            function mapBasicPromptToStabilityFormat() {
         | 
| @@ -9399,12 +9219,12 @@ var StabilityImageGenerationModel = class _StabilityImageGenerationModel extends | |
| 9399 9219 | 
             
                );
         | 
| 9400 9220 | 
             
              }
         | 
| 9401 9221 | 
             
            };
         | 
| 9402 | 
            -
            var stabilityImageGenerationResponseSchema =  | 
| 9403 | 
            -
              artifacts:  | 
| 9404 | 
            -
                 | 
| 9405 | 
            -
                  base64:  | 
| 9406 | 
            -
                  seed:  | 
| 9407 | 
            -
                  finishReason:  | 
| 9222 | 
            +
            var stabilityImageGenerationResponseSchema = z31.object({
         | 
| 9223 | 
            +
              artifacts: z31.array(
         | 
| 9224 | 
            +
                z31.object({
         | 
| 9225 | 
            +
                  base64: z31.string(),
         | 
| 9226 | 
            +
                  seed: z31.number(),
         | 
| 9227 | 
            +
                  finishReason: z31.enum(["SUCCESS", "ERROR", "CONTENT_FILTERED"])
         | 
| 9408 9228 | 
             
                })
         | 
| 9409 9229 | 
             
              )
         | 
| 9410 9230 | 
             
            });
         | 
| @@ -9440,7 +9260,7 @@ __export(WhisperCppFacade_exports, { | |
| 9440 9260 | 
             
            });
         | 
| 9441 9261 |  | 
| 9442 9262 | 
             
            // src/model-provider/whispercpp/WhisperCppTranscriptionModel.ts
         | 
| 9443 | 
            -
            import { z as  | 
| 9263 | 
            +
            import { z as z32 } from "zod";
         | 
| 9444 9264 | 
             
            var WhisperCppTranscriptionModel = class _WhisperCppTranscriptionModel extends AbstractModel {
         | 
| 9445 9265 | 
             
              constructor(settings) {
         | 
| 9446 9266 | 
             
                super({ settings });
         | 
| @@ -9511,9 +9331,9 @@ var WhisperCppTranscriptionModel = class _WhisperCppTranscriptionModel extends A | |
| 9511 9331 | 
             
                );
         | 
| 9512 9332 | 
             
              }
         | 
| 9513 9333 | 
             
            };
         | 
| 9514 | 
            -
            var whisperCppTranscriptionJsonSchema =  | 
| 9515 | 
            -
               | 
| 9516 | 
            -
               | 
| 9334 | 
            +
            var whisperCppTranscriptionJsonSchema = z32.union([
         | 
| 9335 | 
            +
              z32.object({ text: z32.string() }),
         | 
| 9336 | 
            +
              z32.object({ error: z32.string() })
         | 
| 9517 9337 | 
             
            ]);
         | 
| 9518 9338 | 
             
            var successfulResponseHandler = async ({ response, url, requestBodyValues }) => {
         | 
| 9519 9339 | 
             
              const responseBody = await response.text();
         | 
| @@ -9872,14 +9692,14 @@ var ToolExecutionError = class extends Error { | |
| 9872 9692 | 
             
            };
         | 
| 9873 9693 |  | 
| 9874 9694 | 
             
            // src/tool/WebSearchTool.ts
         | 
| 9875 | 
            -
            import { z as  | 
| 9695 | 
            +
            import { z as z33 } from "zod";
         | 
| 9876 9696 | 
             
            var RETURN_TYPE_SCHEMA = zodSchema(
         | 
| 9877 | 
            -
               | 
| 9878 | 
            -
                results:  | 
| 9879 | 
            -
                   | 
| 9880 | 
            -
                    title:  | 
| 9881 | 
            -
                    link:  | 
| 9882 | 
            -
                    snippet:  | 
| 9697 | 
            +
              z33.object({
         | 
| 9698 | 
            +
                results: z33.array(
         | 
| 9699 | 
            +
                  z33.object({
         | 
| 9700 | 
            +
                    title: z33.string(),
         | 
| 9701 | 
            +
                    link: z33.string().url(),
         | 
| 9702 | 
            +
                    snippet: z33.string()
         | 
| 9883 9703 | 
             
                  })
         | 
| 9884 9704 | 
             
                )
         | 
| 9885 9705 | 
             
              })
         | 
| @@ -9887,8 +9707,8 @@ var RETURN_TYPE_SCHEMA = zodSchema( | |
| 9887 9707 | 
             
            var createParameters = (description) => (
         | 
| 9888 9708 | 
             
              // same schema, but with description:
         | 
| 9889 9709 | 
             
              zodSchema(
         | 
| 9890 | 
            -
                 | 
| 9891 | 
            -
                  query:  | 
| 9710 | 
            +
                z33.object({
         | 
| 9711 | 
            +
                  query: z33.string().describe(description)
         | 
| 9892 9712 | 
             
                })
         | 
| 9893 9713 | 
             
              )
         | 
| 9894 9714 | 
             
            );
         | 
| @@ -10362,13 +10182,13 @@ var VectorIndexRetriever = class _VectorIndexRetriever { | |
| 10362 10182 | 
             
            };
         | 
| 10363 10183 |  | 
| 10364 10184 | 
             
            // src/vector-index/memory/MemoryVectorIndex.ts
         | 
| 10365 | 
            -
            import { z as  | 
| 10185 | 
            +
            import { z as z34 } from "zod";
         | 
| 10366 10186 | 
             
            var jsonDataSchema = zodSchema(
         | 
| 10367 | 
            -
               | 
| 10368 | 
            -
                 | 
| 10369 | 
            -
                  id:  | 
| 10370 | 
            -
                  vector:  | 
| 10371 | 
            -
                  data:  | 
| 10187 | 
            +
              z34.array(
         | 
| 10188 | 
            +
                z34.object({
         | 
| 10189 | 
            +
                  id: z34.string(),
         | 
| 10190 | 
            +
                  vector: z34.array(z34.number()),
         | 
| 10191 | 
            +
                  data: z34.unknown()
         | 
| 10372 10192 | 
             
                })
         | 
| 10373 10193 | 
             
              )
         | 
| 10374 10194 | 
             
            );
         | 
| @@ -10466,6 +10286,7 @@ export { | |
| 10466 10286 | 
             
              AzureOpenAIApiConfiguration,
         | 
| 10467 10287 | 
             
              BaseUrlApiConfiguration,
         | 
| 10468 10288 | 
             
              BaseUrlApiConfigurationWithDefaults,
         | 
| 10289 | 
            +
              CHAT_MODEL_CONTEXT_WINDOW_SIZES,
         | 
| 10469 10290 | 
             
              COHERE_TEXT_EMBEDDING_MODELS,
         | 
| 10470 10291 | 
             
              COHERE_TEXT_GENERATION_MODELS,
         | 
| 10471 10292 | 
             
              ChatMLPromptTemplate_exports as ChatMLPrompt,
         | 
| @@ -10505,13 +10326,9 @@ export { | |
| 10505 10326 | 
             
              NeuralChatPromptTemplate_exports as NeuralChatPrompt,
         | 
| 10506 10327 | 
             
              NoSuchToolDefinitionError,
         | 
| 10507 10328 | 
             
              OPENAI_CHAT_MESSAGE_BASE_TOKEN_COUNT,
         | 
| 10508 | 
            -
              OPENAI_CHAT_MODELS,
         | 
| 10509 10329 | 
             
              OPENAI_CHAT_PROMPT_BASE_TOKEN_COUNT,
         | 
| 10510 | 
            -
              OPENAI_IMAGE_MODELS,
         | 
| 10511 | 
            -
              OPENAI_SPEECH_MODELS,
         | 
| 10512 10330 | 
             
              OPENAI_TEXT_EMBEDDING_MODELS,
         | 
| 10513 10331 | 
             
              OPENAI_TEXT_GENERATION_MODELS,
         | 
| 10514 | 
            -
              OPENAI_TRANSCRIPTION_MODELS,
         | 
| 10515 10332 | 
             
              ObjectFromTextGenerationModel,
         | 
| 10516 10333 | 
             
              ObjectFromTextStreamingModel,
         | 
| 10517 10334 | 
             
              ObjectGeneratorTool,
         | 
| @@ -10571,12 +10388,6 @@ export { | |
| 10571 10388 | 
             
              ZodSchema,
         | 
| 10572 10389 | 
             
              ApiFacade_exports as api,
         | 
| 10573 10390 | 
             
              Automatic1111Facade_exports as automatic1111,
         | 
| 10574 | 
            -
              calculateOpenAIChatCostInMillicents,
         | 
| 10575 | 
            -
              calculateOpenAICompletionCostInMillicents,
         | 
| 10576 | 
            -
              calculateOpenAIEmbeddingCostInMillicents,
         | 
| 10577 | 
            -
              calculateOpenAIImageGenerationCostInMillicents,
         | 
| 10578 | 
            -
              calculateOpenAISpeechCostInMillicents,
         | 
| 10579 | 
            -
              calculateOpenAITranscriptionCostInMillicents,
         | 
| 10580 10391 | 
             
              classify,
         | 
| 10581 10392 | 
             
              CohereFacade_exports as cohere,
         | 
| 10582 10393 | 
             
              convertDataContentToBase64String,
         | 
| @@ -10607,9 +10418,6 @@ export { | |
| 10607 10418 | 
             
              getOpenAICompletionModelInformation,
         | 
| 10608 10419 | 
             
              getRun,
         | 
| 10609 10420 | 
             
              HuggingFaceFacade_exports as huggingface,
         | 
| 10610 | 
            -
              isOpenAIChatModel,
         | 
| 10611 | 
            -
              isOpenAICompletionModel,
         | 
| 10612 | 
            -
              isOpenAIEmbeddingModel,
         | 
| 10613 10421 | 
             
              isPromptFunction,
         | 
| 10614 10422 | 
             
              jsonObjectPrompt,
         | 
| 10615 10423 | 
             
              jsonToolCallPrompt,
         | 
| @@ -10621,6 +10429,7 @@ export { | |
| 10621 10429 | 
             
              MistralFacade_exports as mistral,
         | 
| 10622 10430 | 
             
              ModelFusionConfiguration_exports as modelfusion,
         | 
| 10623 10431 | 
             
              OllamaFacade_exports as ollama,
         | 
| 10432 | 
            +
              openAITextEmbeddingResponseSchema2 as openAITextEmbeddingResponseSchema,
         | 
| 10624 10433 | 
             
              OpenAIFacade_exports as openai,
         | 
| 10625 10434 | 
             
              OpenAICompatibleFacade_exports as openaicompatible,
         | 
| 10626 10435 | 
             
              parseJSON,
         |