modelfusion 0.27.2 → 0.28.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 (173) hide show
  1. package/README.md +6 -5
  2. package/{model-function/BasicApiConfiguration.js → core/api/AbstractApiConfiguration.cjs} +6 -15
  3. package/core/api/AbstractApiConfiguration.d.ts +13 -0
  4. package/core/api/AbstractApiConfiguration.js +18 -0
  5. package/core/api/ApiConfiguration.d.ts +32 -0
  6. package/core/api/BaseUrlApiConfiguration.cjs +32 -0
  7. package/core/api/BaseUrlApiConfiguration.d.ts +19 -0
  8. package/core/api/BaseUrlApiConfiguration.js +28 -0
  9. package/core/api/index.cjs +27 -0
  10. package/core/api/index.d.ts +11 -0
  11. package/core/api/index.js +11 -0
  12. package/core/index.cjs +1 -0
  13. package/core/index.d.ts +1 -0
  14. package/core/index.js +1 -0
  15. package/model-function/executeCall.cjs +1 -1
  16. package/model-function/executeCall.js +1 -1
  17. package/model-function/generate-text/streamText.cjs +1 -1
  18. package/model-function/generate-text/streamText.js +1 -1
  19. package/model-function/index.cjs +0 -2
  20. package/model-function/index.d.ts +0 -2
  21. package/model-function/index.js +0 -2
  22. package/model-provider/automatic1111/Automatic1111ApiConfiguration.cjs +3 -2
  23. package/model-provider/automatic1111/Automatic1111ApiConfiguration.d.ts +4 -4
  24. package/model-provider/automatic1111/Automatic1111ApiConfiguration.js +3 -2
  25. package/model-provider/automatic1111/Automatic1111Error.cjs +1 -1
  26. package/model-provider/automatic1111/Automatic1111Error.d.ts +2 -2
  27. package/model-provider/automatic1111/Automatic1111Error.js +1 -1
  28. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +2 -2
  29. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +1 -1
  30. package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +2 -2
  31. package/model-provider/cohere/CohereApiConfiguration.cjs +10 -17
  32. package/model-provider/cohere/CohereApiConfiguration.d.ts +4 -6
  33. package/model-provider/cohere/CohereApiConfiguration.js +10 -17
  34. package/model-provider/cohere/CohereError.cjs +1 -1
  35. package/model-provider/cohere/CohereError.d.ts +2 -2
  36. package/model-provider/cohere/CohereError.js +1 -1
  37. package/model-provider/cohere/CohereTextEmbeddingModel.cjs +2 -2
  38. package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +1 -1
  39. package/model-provider/cohere/CohereTextEmbeddingModel.js +2 -2
  40. package/model-provider/cohere/CohereTextGenerationModel.cjs +2 -2
  41. package/model-provider/cohere/CohereTextGenerationModel.d.ts +2 -2
  42. package/model-provider/cohere/CohereTextGenerationModel.js +2 -2
  43. package/model-provider/cohere/CohereTokenizer.cjs +2 -2
  44. package/model-provider/cohere/CohereTokenizer.d.ts +1 -1
  45. package/model-provider/cohere/CohereTokenizer.js +2 -2
  46. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.cjs +10 -17
  47. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.d.ts +4 -6
  48. package/model-provider/elevenlabs/ElevenLabsApiConfiguration.js +10 -17
  49. package/model-provider/elevenlabs/ElevenLabsError.cjs +1 -1
  50. package/model-provider/elevenlabs/ElevenLabsError.d.ts +2 -2
  51. package/model-provider/elevenlabs/ElevenLabsError.js +1 -1
  52. package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.cjs +2 -2
  53. package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.d.ts +1 -1
  54. package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.js +2 -2
  55. package/model-provider/huggingface/HuggingFaceApiConfiguration.cjs +10 -17
  56. package/model-provider/huggingface/HuggingFaceApiConfiguration.d.ts +4 -6
  57. package/model-provider/huggingface/HuggingFaceApiConfiguration.js +10 -17
  58. package/model-provider/huggingface/HuggingFaceError.cjs +1 -1
  59. package/model-provider/huggingface/HuggingFaceError.d.ts +2 -2
  60. package/model-provider/huggingface/HuggingFaceError.js +1 -1
  61. package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +2 -2
  62. package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.d.ts +1 -1
  63. package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +2 -2
  64. package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +2 -2
  65. package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +1 -1
  66. package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +2 -2
  67. package/model-provider/llamacpp/LlamaCppApiConfiguration.cjs +3 -2
  68. package/model-provider/llamacpp/LlamaCppApiConfiguration.d.ts +4 -4
  69. package/model-provider/llamacpp/LlamaCppApiConfiguration.js +3 -2
  70. package/model-provider/llamacpp/LlamaCppError.cjs +1 -1
  71. package/model-provider/llamacpp/LlamaCppError.d.ts +2 -2
  72. package/model-provider/llamacpp/LlamaCppError.js +1 -1
  73. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +2 -2
  74. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +1 -1
  75. package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +2 -2
  76. package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +2 -2
  77. package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +2 -2
  78. package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +2 -2
  79. package/model-provider/llamacpp/LlamaCppTokenizer.cjs +2 -2
  80. package/model-provider/llamacpp/LlamaCppTokenizer.d.ts +1 -1
  81. package/model-provider/llamacpp/LlamaCppTokenizer.js +2 -2
  82. package/model-provider/lmnt/LmntApiConfiguration.cjs +10 -17
  83. package/model-provider/lmnt/LmntApiConfiguration.d.ts +4 -6
  84. package/model-provider/lmnt/LmntApiConfiguration.js +10 -17
  85. package/model-provider/lmnt/LmntError.cjs +1 -1
  86. package/model-provider/lmnt/LmntError.d.ts +2 -2
  87. package/model-provider/lmnt/LmntError.js +1 -1
  88. package/model-provider/lmnt/LmntSpeechSynthesisModel.cjs +2 -2
  89. package/model-provider/lmnt/LmntSpeechSynthesisModel.d.ts +1 -1
  90. package/model-provider/lmnt/LmntSpeechSynthesisModel.js +2 -2
  91. package/model-provider/openai/AzureOpenAIApiConfiguration.cjs +28 -24
  92. package/model-provider/openai/AzureOpenAIApiConfiguration.d.ts +11 -12
  93. package/model-provider/openai/AzureOpenAIApiConfiguration.js +28 -24
  94. package/model-provider/openai/OpenAIApiConfiguration.cjs +10 -19
  95. package/model-provider/openai/OpenAIApiConfiguration.d.ts +4 -6
  96. package/model-provider/openai/OpenAIApiConfiguration.js +10 -19
  97. package/model-provider/openai/OpenAIError.cjs +1 -1
  98. package/model-provider/openai/OpenAIError.d.ts +6 -6
  99. package/model-provider/openai/OpenAIError.js +1 -1
  100. package/model-provider/openai/OpenAIImageGenerationModel.cjs +2 -2
  101. package/model-provider/openai/OpenAIImageGenerationModel.d.ts +2 -2
  102. package/model-provider/openai/OpenAIImageGenerationModel.js +2 -2
  103. package/model-provider/openai/OpenAITextEmbeddingModel.cjs +2 -2
  104. package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +1 -1
  105. package/model-provider/openai/OpenAITextEmbeddingModel.js +2 -2
  106. package/model-provider/openai/OpenAITextGenerationModel.cjs +2 -2
  107. package/model-provider/openai/OpenAITextGenerationModel.d.ts +2 -2
  108. package/model-provider/openai/OpenAITextGenerationModel.js +2 -2
  109. package/model-provider/openai/OpenAITranscriptionModel.cjs +2 -2
  110. package/model-provider/openai/OpenAITranscriptionModel.d.ts +2 -2
  111. package/model-provider/openai/OpenAITranscriptionModel.js +2 -2
  112. package/model-provider/openai/chat/OpenAIChatModel.cjs +2 -2
  113. package/model-provider/openai/chat/OpenAIChatModel.d.ts +2 -2
  114. package/model-provider/openai/chat/OpenAIChatModel.js +2 -2
  115. package/model-provider/stability/StabilityApiConfiguration.cjs +10 -19
  116. package/model-provider/stability/StabilityApiConfiguration.d.ts +4 -6
  117. package/model-provider/stability/StabilityApiConfiguration.js +10 -19
  118. package/model-provider/stability/StabilityError.cjs +1 -1
  119. package/model-provider/stability/StabilityError.d.ts +2 -2
  120. package/model-provider/stability/StabilityError.js +1 -1
  121. package/model-provider/stability/StabilityImageGenerationModel.cjs +2 -2
  122. package/model-provider/stability/StabilityImageGenerationModel.d.ts +1 -1
  123. package/model-provider/stability/StabilityImageGenerationModel.js +2 -2
  124. package/observability/helicone/HeliconeOpenAIApiConfiguration.cjs +17 -33
  125. package/observability/helicone/HeliconeOpenAIApiConfiguration.d.ts +4 -7
  126. package/observability/helicone/HeliconeOpenAIApiConfiguration.js +17 -33
  127. package/package.json +1 -1
  128. package/tool/executeTool.cjs +1 -1
  129. package/tool/executeTool.js +1 -1
  130. package/util/index.cjs +0 -9
  131. package/util/index.d.ts +0 -9
  132. package/util/index.js +0 -9
  133. package/model-function/ApiConfiguration.d.ts +0 -14
  134. package/model-function/BasicApiConfiguration.cjs +0 -35
  135. package/model-function/BasicApiConfiguration.d.ts +0 -15
  136. /package/{util → core}/api/AbortError.cjs +0 -0
  137. /package/{util → core}/api/AbortError.d.ts +0 -0
  138. /package/{util → core}/api/AbortError.js +0 -0
  139. /package/{util → core}/api/ApiCallError.cjs +0 -0
  140. /package/{util → core}/api/ApiCallError.d.ts +0 -0
  141. /package/{util → core}/api/ApiCallError.js +0 -0
  142. /package/{model-function → core/api}/ApiConfiguration.cjs +0 -0
  143. /package/{model-function → core/api}/ApiConfiguration.js +0 -0
  144. /package/{util → core}/api/RetryError.cjs +0 -0
  145. /package/{util → core}/api/RetryError.d.ts +0 -0
  146. /package/{util → core}/api/RetryError.js +0 -0
  147. /package/{util → core}/api/RetryFunction.cjs +0 -0
  148. /package/{util → core}/api/RetryFunction.d.ts +0 -0
  149. /package/{util → core}/api/RetryFunction.js +0 -0
  150. /package/{util → core}/api/ThrottleFunction.cjs +0 -0
  151. /package/{util → core}/api/ThrottleFunction.d.ts +0 -0
  152. /package/{util → core}/api/ThrottleFunction.js +0 -0
  153. /package/{util → core}/api/callWithRetryAndThrottle.cjs +0 -0
  154. /package/{util → core}/api/callWithRetryAndThrottle.d.ts +0 -0
  155. /package/{util → core}/api/callWithRetryAndThrottle.js +0 -0
  156. /package/{util → core}/api/loadApiKey.cjs +0 -0
  157. /package/{util → core}/api/loadApiKey.d.ts +0 -0
  158. /package/{util → core}/api/loadApiKey.js +0 -0
  159. /package/{util → core}/api/postToApi.cjs +0 -0
  160. /package/{util → core}/api/postToApi.d.ts +0 -0
  161. /package/{util → core}/api/postToApi.js +0 -0
  162. /package/{util → core}/api/retryNever.cjs +0 -0
  163. /package/{util → core}/api/retryNever.d.ts +0 -0
  164. /package/{util → core}/api/retryNever.js +0 -0
  165. /package/{util → core}/api/retryWithExponentialBackoff.cjs +0 -0
  166. /package/{util → core}/api/retryWithExponentialBackoff.d.ts +0 -0
  167. /package/{util → core}/api/retryWithExponentialBackoff.js +0 -0
  168. /package/{util → core}/api/throttleMaxConcurrency.cjs +0 -0
  169. /package/{util → core}/api/throttleMaxConcurrency.d.ts +0 -0
  170. /package/{util → core}/api/throttleMaxConcurrency.js +0 -0
  171. /package/{util → core}/api/throttleUnlimitedConcurrency.cjs +0 -0
  172. /package/{util → core}/api/throttleUnlimitedConcurrency.d.ts +0 -0
  173. /package/{util → core}/api/throttleUnlimitedConcurrency.js +0 -0
package/README.md CHANGED
@@ -417,11 +417,12 @@ Integrations: [Helicone](https://modelfusion.dev/integration/observability/helic
417
417
  - [Text Chunks](https://modelfusion.dev/guide/text-chunk/)
418
418
  - [Split Text](https://modelfusion.dev/guide/text-chunk/split)
419
419
  - [Utilities](https://modelfusion.dev/guide/util/)
420
- - [Function Logging](https://modelfusion.dev/guide/util/logging)
421
- - [Function observers](https://modelfusion.dev/guide/util/observer)
422
- - [Retry strategies](https://modelfusion.dev/guide/util/retry)
423
- - [Throttling strategies](https://modelfusion.dev/guide/util/throttle)
424
- - [Run abstraction](https://modelfusion.dev/guide/util/run)
420
+ - [API Configuration](https://modelfusion.dev/guide/util/api-configuration)
421
+ - [Retry strategies](https://modelfusion.dev/guide/util/api-configuration/retry)
422
+ - [Throttling strategies](https://modelfusion.dev/guide/util/api-configuration/throttle)
423
+ - [Logging](https://modelfusion.dev/guide/util/logging)
424
+ - [Observers](https://modelfusion.dev/guide/util/observer)
425
+ - [Runs](https://modelfusion.dev/guide/util/run)
425
426
  - [Abort signals](https://modelfusion.dev/guide/util/abort)
426
427
  - [Cost calculation](https://modelfusion.dev/guide/util/cost-calculation)
427
428
 
@@ -1,11 +1,8 @@
1
- export class BasicApiConfiguration {
2
- constructor({ baseUrl, retry, throttle, }) {
3
- Object.defineProperty(this, "baseUrl", {
4
- enumerable: true,
5
- configurable: true,
6
- writable: true,
7
- value: void 0
8
- });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractApiConfiguration = void 0;
4
+ class AbstractApiConfiguration {
5
+ constructor({ retry, throttle, }) {
9
6
  Object.defineProperty(this, "retry", {
10
7
  enumerable: true,
11
8
  configurable: true,
@@ -18,14 +15,8 @@ export class BasicApiConfiguration {
18
15
  writable: true,
19
16
  value: void 0
20
17
  });
21
- this.baseUrl = baseUrl;
22
18
  this.retry = retry;
23
19
  this.throttle = throttle;
24
20
  }
25
- get headers() {
26
- return {};
27
- }
28
- assembleUrl(path) {
29
- return `${this.baseUrl}${path}`;
30
- }
31
21
  }
22
+ exports.AbstractApiConfiguration = AbstractApiConfiguration;
@@ -0,0 +1,13 @@
1
+ import { RetryFunction } from "./RetryFunction.js";
2
+ import { ThrottleFunction } from "./ThrottleFunction.js";
3
+ import { ApiConfiguration } from "./ApiConfiguration.js";
4
+ export declare abstract class AbstractApiConfiguration implements ApiConfiguration {
5
+ readonly retry?: RetryFunction;
6
+ readonly throttle?: ThrottleFunction;
7
+ constructor({ retry, throttle, }: {
8
+ retry?: RetryFunction;
9
+ throttle?: ThrottleFunction;
10
+ });
11
+ abstract assembleUrl(path: string): string;
12
+ abstract readonly headers: Record<string, string>;
13
+ }
@@ -0,0 +1,18 @@
1
+ export class AbstractApiConfiguration {
2
+ constructor({ retry, throttle, }) {
3
+ Object.defineProperty(this, "retry", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: void 0
8
+ });
9
+ Object.defineProperty(this, "throttle", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: void 0
14
+ });
15
+ this.retry = retry;
16
+ this.throttle = throttle;
17
+ }
18
+ }
@@ -0,0 +1,32 @@
1
+ import { RetryFunction } from "./RetryFunction.js";
2
+ import { ThrottleFunction } from "./ThrottleFunction.js";
3
+ /**
4
+ * Settings for how to call an API, e.g. OpenAI.
5
+ *
6
+ * This interfaces enables creating pre-defined API configuration for certain API (e.g., OpenAI),
7
+ * pre-defined proxy configurations (e.g. Helicone OpenAI),
8
+ * and fully custom setups (e.g. your own internal OpenAI proxy with custom headers).
9
+ */
10
+ export interface ApiConfiguration {
11
+ /**
12
+ * Creates a full URL given a inner path.
13
+ *
14
+ * The inner path always starts with a slash, e.g. `/generate`.
15
+ */
16
+ assembleUrl(path: string): string;
17
+ /**
18
+ * Returns the headers that should be included in every request to the API.
19
+ * This is intended for authentication headers and proxy settings.
20
+ *
21
+ * The model may add additional headers, in particular "Content-Type"."
22
+ */
23
+ readonly headers: Record<string, string>;
24
+ /**
25
+ * Defines how failed API calls should be retried.
26
+ */
27
+ readonly retry?: RetryFunction;
28
+ /**
29
+ * Defines how API calls should be rate limited.
30
+ */
31
+ readonly throttle?: ThrottleFunction;
32
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseUrlApiConfiguration = void 0;
4
+ const AbstractApiConfiguration_js_1 = require("./AbstractApiConfiguration.cjs");
5
+ /**
6
+ * An API configuration that uses a base URL and a set of headers.
7
+ *
8
+ * You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
9
+ */
10
+ class BaseUrlApiConfiguration extends AbstractApiConfiguration_js_1.AbstractApiConfiguration {
11
+ constructor({ baseUrl, headers, retry, throttle, }) {
12
+ super({ retry, throttle });
13
+ Object.defineProperty(this, "baseUrl", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: void 0
18
+ });
19
+ Object.defineProperty(this, "headers", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: void 0
24
+ });
25
+ this.baseUrl = baseUrl;
26
+ this.headers = headers;
27
+ }
28
+ assembleUrl(path) {
29
+ return `${this.baseUrl}${path}`;
30
+ }
31
+ }
32
+ exports.BaseUrlApiConfiguration = BaseUrlApiConfiguration;
@@ -0,0 +1,19 @@
1
+ import { AbstractApiConfiguration } from "./AbstractApiConfiguration.js";
2
+ import { RetryFunction } from "./RetryFunction.js";
3
+ import { ThrottleFunction } from "./ThrottleFunction.js";
4
+ /**
5
+ * An API configuration that uses a base URL and a set of headers.
6
+ *
7
+ * You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
8
+ */
9
+ export declare class BaseUrlApiConfiguration extends AbstractApiConfiguration {
10
+ readonly baseUrl: string;
11
+ readonly headers: Record<string, string>;
12
+ constructor({ baseUrl, headers, retry, throttle, }: {
13
+ baseUrl: string;
14
+ headers: Record<string, string>;
15
+ retry?: RetryFunction;
16
+ throttle?: ThrottleFunction;
17
+ });
18
+ assembleUrl(path: string): string;
19
+ }
@@ -0,0 +1,28 @@
1
+ import { AbstractApiConfiguration } from "./AbstractApiConfiguration.js";
2
+ /**
3
+ * An API configuration that uses a base URL and a set of headers.
4
+ *
5
+ * You can use it to configure custom APIs for models, e.g. your own internal OpenAI proxy with custom headers.
6
+ */
7
+ export class BaseUrlApiConfiguration extends AbstractApiConfiguration {
8
+ constructor({ baseUrl, headers, retry, throttle, }) {
9
+ super({ retry, throttle });
10
+ Object.defineProperty(this, "baseUrl", {
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true,
14
+ value: void 0
15
+ });
16
+ Object.defineProperty(this, "headers", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ this.baseUrl = baseUrl;
23
+ this.headers = headers;
24
+ }
25
+ assembleUrl(path) {
26
+ return `${this.baseUrl}${path}`;
27
+ }
28
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AbortError.cjs"), exports);
18
+ __exportStar(require("./ApiCallError.cjs"), exports);
19
+ __exportStar(require("./ApiConfiguration.cjs"), exports);
20
+ __exportStar(require("./BaseUrlApiConfiguration.cjs"), exports);
21
+ __exportStar(require("./RetryError.cjs"), exports);
22
+ __exportStar(require("./RetryFunction.cjs"), exports);
23
+ __exportStar(require("./ThrottleFunction.cjs"), exports);
24
+ __exportStar(require("./retryNever.cjs"), exports);
25
+ __exportStar(require("./retryWithExponentialBackoff.cjs"), exports);
26
+ __exportStar(require("./throttleMaxConcurrency.cjs"), exports);
27
+ __exportStar(require("./throttleUnlimitedConcurrency.cjs"), exports);
@@ -0,0 +1,11 @@
1
+ export * from "./AbortError.js";
2
+ export * from "./ApiCallError.js";
3
+ export * from "./ApiConfiguration.js";
4
+ export * from "./BaseUrlApiConfiguration.js";
5
+ export * from "./RetryError.js";
6
+ export * from "./RetryFunction.js";
7
+ export * from "./ThrottleFunction.js";
8
+ export * from "./retryNever.js";
9
+ export * from "./retryWithExponentialBackoff.js";
10
+ export * from "./throttleMaxConcurrency.js";
11
+ export * from "./throttleUnlimitedConcurrency.js";
@@ -0,0 +1,11 @@
1
+ export * from "./AbortError.js";
2
+ export * from "./ApiCallError.js";
3
+ export * from "./ApiConfiguration.js";
4
+ export * from "./BaseUrlApiConfiguration.js";
5
+ export * from "./RetryError.js";
6
+ export * from "./RetryFunction.js";
7
+ export * from "./ThrottleFunction.js";
8
+ export * from "./retryNever.js";
9
+ export * from "./retryWithExponentialBackoff.js";
10
+ export * from "./throttleMaxConcurrency.js";
11
+ export * from "./throttleUnlimitedConcurrency.js";
package/core/index.cjs CHANGED
@@ -23,3 +23,4 @@ __exportStar(require("./GlobalFunctionLogging.cjs"), exports);
23
23
  __exportStar(require("./GlobalFunctionObservers.cjs"), exports);
24
24
  __exportStar(require("./Run.cjs"), exports);
25
25
  __exportStar(require("./Vector.cjs"), exports);
26
+ __exportStar(require("./api/index.cjs"), exports);
package/core/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./GlobalFunctionLogging.js";
7
7
  export * from "./GlobalFunctionObservers.js";
8
8
  export * from "./Run.js";
9
9
  export * from "./Vector.js";
10
+ export * from "./api/index.js";
package/core/index.js CHANGED
@@ -7,3 +7,4 @@ export * from "./GlobalFunctionLogging.js";
7
7
  export * from "./GlobalFunctionObservers.js";
8
8
  export * from "./Run.js";
9
9
  export * from "./Vector.js";
10
+ export * from "./api/index.js";
@@ -7,7 +7,7 @@ const GlobalFunctionLogging_js_1 = require("../core/GlobalFunctionLogging.cjs");
7
7
  const GlobalFunctionObservers_js_1 = require("../core/GlobalFunctionObservers.cjs");
8
8
  const getFunctionCallLogger_js_1 = require("../core/getFunctionCallLogger.cjs");
9
9
  const DurationMeasurement_js_1 = require("../util/DurationMeasurement.cjs");
10
- const AbortError_js_1 = require("../util/api/AbortError.cjs");
10
+ const AbortError_js_1 = require("../core/api/AbortError.cjs");
11
11
  const runSafe_js_1 = require("../util/runSafe.cjs");
12
12
  class ModelFunctionPromise extends Promise {
13
13
  constructor(fullPromise) {
@@ -4,7 +4,7 @@ import { getGlobalFunctionLogging } from "../core/GlobalFunctionLogging.js";
4
4
  import { getGlobalFunctionObservers } from "../core/GlobalFunctionObservers.js";
5
5
  import { getFunctionCallLogger } from "../core/getFunctionCallLogger.js";
6
6
  import { startDurationMeasurement } from "../util/DurationMeasurement.js";
7
- import { AbortError } from "../util/api/AbortError.js";
7
+ import { AbortError } from "../core/api/AbortError.js";
8
8
  import { runSafe } from "../util/runSafe.js";
9
9
  export class ModelFunctionPromise extends Promise {
10
10
  constructor(fullPromise) {
@@ -7,7 +7,7 @@ const GlobalFunctionLogging_js_1 = require("../../core/GlobalFunctionLogging.cjs
7
7
  const GlobalFunctionObservers_js_1 = require("../../core/GlobalFunctionObservers.cjs");
8
8
  const getFunctionCallLogger_js_1 = require("../../core/getFunctionCallLogger.cjs");
9
9
  const DurationMeasurement_js_1 = require("../../util/DurationMeasurement.cjs");
10
- const AbortError_js_1 = require("../../util/api/AbortError.cjs");
10
+ const AbortError_js_1 = require("../../core/api/AbortError.cjs");
11
11
  const runSafe_js_1 = require("../../util/runSafe.cjs");
12
12
  const extractTextDeltas_js_1 = require("./extractTextDeltas.cjs");
13
13
  class StreamTextPromise extends Promise {
@@ -4,7 +4,7 @@ import { getGlobalFunctionLogging } from "../../core/GlobalFunctionLogging.js";
4
4
  import { getGlobalFunctionObservers } from "../../core/GlobalFunctionObservers.js";
5
5
  import { getFunctionCallLogger } from "../../core/getFunctionCallLogger.js";
6
6
  import { startDurationMeasurement } from "../../util/DurationMeasurement.js";
7
- import { AbortError } from "../../util/api/AbortError.js";
7
+ import { AbortError } from "../../core/api/AbortError.js";
8
8
  import { runSafe } from "../../util/runSafe.js";
9
9
  import { extractTextDeltas } from "./extractTextDeltas.js";
10
10
  export class StreamTextPromise extends Promise {
@@ -14,8 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./ApiConfiguration.cjs"), exports);
18
- __exportStar(require("./BasicApiConfiguration.cjs"), exports);
19
17
  __exportStar(require("./Model.cjs"), exports);
20
18
  __exportStar(require("./ModelCallEvent.cjs"), exports);
21
19
  __exportStar(require("./ModelFunctionOptions.cjs"), exports);
@@ -1,5 +1,3 @@
1
- export * from "./ApiConfiguration.js";
2
- export * from "./BasicApiConfiguration.js";
3
1
  export * from "./Model.js";
4
2
  export * from "./ModelCallEvent.js";
5
3
  export * from "./ModelFunctionOptions.js";
@@ -1,5 +1,3 @@
1
- export * from "./ApiConfiguration.js";
2
- export * from "./BasicApiConfiguration.js";
3
1
  export * from "./Model.js";
4
2
  export * from "./ModelCallEvent.js";
5
3
  export * from "./ModelFunctionOptions.js";
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Automatic1111ApiConfiguration = void 0;
4
- const BasicApiConfiguration_js_1 = require("../../model-function/BasicApiConfiguration.cjs");
5
- class Automatic1111ApiConfiguration extends BasicApiConfiguration_js_1.BasicApiConfiguration {
4
+ const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
5
+ class Automatic1111ApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfiguration {
6
6
  constructor({ baseUrl = "http://127.0.0.1:7860/sdapi/v1", retry, throttle, } = {}) {
7
7
  super({
8
8
  baseUrl,
9
+ headers: {},
9
10
  retry,
10
11
  throttle,
11
12
  });
@@ -1,7 +1,7 @@
1
- import { BasicApiConfiguration } from "../../model-function/BasicApiConfiguration.js";
2
- import { RetryFunction } from "../../util/api/RetryFunction.js";
3
- import { ThrottleFunction } from "../../util/api/ThrottleFunction.js";
4
- export declare class Automatic1111ApiConfiguration extends BasicApiConfiguration {
1
+ import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ import { RetryFunction } from "../../core/api/RetryFunction.js";
3
+ import { ThrottleFunction } from "../../core/api/ThrottleFunction.js";
4
+ export declare class Automatic1111ApiConfiguration extends BaseUrlApiConfiguration {
5
5
  constructor({ baseUrl, retry, throttle, }?: {
6
6
  baseUrl?: string;
7
7
  retry?: RetryFunction;
@@ -1,8 +1,9 @@
1
- import { BasicApiConfiguration } from "../../model-function/BasicApiConfiguration.js";
2
- export class Automatic1111ApiConfiguration extends BasicApiConfiguration {
1
+ import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ export class Automatic1111ApiConfiguration extends BaseUrlApiConfiguration {
3
3
  constructor({ baseUrl = "http://127.0.0.1:7860/sdapi/v1", retry, throttle, } = {}) {
4
4
  super({
5
5
  baseUrl,
6
+ headers: {},
6
7
  retry,
7
8
  throttle,
8
9
  });
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.failedAutomatic1111CallResponseHandler = exports.Automatic1111Error = exports.automatic1111ErrorDataSchema = void 0;
7
7
  const zod_1 = require("zod");
8
8
  const secure_json_parse_1 = __importDefault(require("secure-json-parse"));
9
- const ApiCallError_js_1 = require("../../util/api/ApiCallError.cjs");
9
+ const ApiCallError_js_1 = require("../../core/api/ApiCallError.cjs");
10
10
  exports.automatic1111ErrorDataSchema = zod_1.z.object({
11
11
  error: zod_1.z.string(),
12
12
  detail: zod_1.z.string(),
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { ResponseHandler } from "../../util/api/postToApi.js";
3
- import { ApiCallError } from "../../util/api/ApiCallError.js";
2
+ import { ResponseHandler } from "../../core/api/postToApi.js";
3
+ import { ApiCallError } from "../../core/api/ApiCallError.js";
4
4
  export declare const automatic1111ErrorDataSchema: z.ZodObject<{
5
5
  error: z.ZodString;
6
6
  detail: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import SecureJSON from "secure-json-parse";
3
- import { ApiCallError } from "../../util/api/ApiCallError.js";
3
+ import { ApiCallError } from "../../core/api/ApiCallError.js";
4
4
  export const automatic1111ErrorDataSchema = z.object({
5
5
  error: z.string(),
6
6
  detail: z.string(),
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Automatic1111ImageGenerationModel = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const AbstractModel_js_1 = require("../../model-function/AbstractModel.cjs");
6
- const callWithRetryAndThrottle_js_1 = require("../../util/api/callWithRetryAndThrottle.cjs");
7
- const postToApi_js_1 = require("../../util/api/postToApi.cjs");
6
+ const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
7
+ const postToApi_js_1 = require("../../core/api/postToApi.cjs");
8
8
  const Automatic1111ApiConfiguration_js_1 = require("./Automatic1111ApiConfiguration.cjs");
9
9
  const Automatic1111Error_js_1 = require("./Automatic1111Error.cjs");
10
10
  /**
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { AbstractModel } from "../../model-function/AbstractModel.js";
3
- import { ApiConfiguration } from "../../model-function/ApiConfiguration.js";
3
+ import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
4
4
  import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
5
5
  import { ImageGenerationModel, ImageGenerationModelSettings } from "../../model-function/generate-image/ImageGenerationModel.js";
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { AbstractModel } from "../../model-function/AbstractModel.js";
3
- import { callWithRetryAndThrottle } from "../../util/api/callWithRetryAndThrottle.js";
4
- import { createJsonResponseHandler, postJsonToApi, } from "../../util/api/postToApi.js";
3
+ import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
4
+ import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
5
5
  import { Automatic1111ApiConfiguration } from "./Automatic1111ApiConfiguration.js";
6
6
  import { failedAutomatic1111CallResponseHandler } from "./Automatic1111Error.js";
7
7
  /**
@@ -1,29 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CohereApiConfiguration = void 0;
4
- const BasicApiConfiguration_js_1 = require("../../model-function/BasicApiConfiguration.cjs");
5
- const loadApiKey_js_1 = require("../../util/api/loadApiKey.cjs");
6
- class CohereApiConfiguration extends BasicApiConfiguration_js_1.BasicApiConfiguration {
4
+ const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
5
+ const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
6
+ class CohereApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfiguration {
7
7
  constructor({ baseUrl = "https://api.cohere.ai/v1", apiKey, retry, throttle, } = {}) {
8
8
  super({
9
9
  baseUrl,
10
+ headers: {
11
+ Authorization: `Bearer ${(0, loadApiKey_js_1.loadApiKey)({
12
+ apiKey,
13
+ environmentVariableName: "COHERE_API_KEY",
14
+ description: "Cohere",
15
+ })}`,
16
+ },
10
17
  retry,
11
18
  throttle,
12
19
  });
13
- Object.defineProperty(this, "apiKey", {
14
- enumerable: true,
15
- configurable: true,
16
- writable: true,
17
- value: void 0
18
- });
19
- this.apiKey = (0, loadApiKey_js_1.loadApiKey)({
20
- apiKey,
21
- environmentVariableName: "COHERE_API_KEY",
22
- description: "Cohere",
23
- });
24
- }
25
- get headers() {
26
- return { Authorization: `Bearer ${this.apiKey}` };
27
20
  }
28
21
  }
29
22
  exports.CohereApiConfiguration = CohereApiConfiguration;
@@ -1,13 +1,11 @@
1
- import { BasicApiConfiguration } from "../../model-function/BasicApiConfiguration.js";
2
- import { RetryFunction } from "../../util/api/RetryFunction.js";
3
- import { ThrottleFunction } from "../../util/api/ThrottleFunction.js";
4
- export declare class CohereApiConfiguration extends BasicApiConfiguration {
5
- readonly apiKey: string;
1
+ import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ import { RetryFunction } from "../../core/api/RetryFunction.js";
3
+ import { ThrottleFunction } from "../../core/api/ThrottleFunction.js";
4
+ export declare class CohereApiConfiguration extends BaseUrlApiConfiguration {
6
5
  constructor({ baseUrl, apiKey, retry, throttle, }?: {
7
6
  baseUrl?: string;
8
7
  apiKey?: string;
9
8
  retry?: RetryFunction;
10
9
  throttle?: ThrottleFunction;
11
10
  });
12
- get headers(): Record<string, string>;
13
11
  }
@@ -1,25 +1,18 @@
1
- import { BasicApiConfiguration } from "../../model-function/BasicApiConfiguration.js";
2
- import { loadApiKey } from "../../util/api/loadApiKey.js";
3
- export class CohereApiConfiguration extends BasicApiConfiguration {
1
+ import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
2
+ import { loadApiKey } from "../../core/api/loadApiKey.js";
3
+ export class CohereApiConfiguration extends BaseUrlApiConfiguration {
4
4
  constructor({ baseUrl = "https://api.cohere.ai/v1", apiKey, retry, throttle, } = {}) {
5
5
  super({
6
6
  baseUrl,
7
+ headers: {
8
+ Authorization: `Bearer ${loadApiKey({
9
+ apiKey,
10
+ environmentVariableName: "COHERE_API_KEY",
11
+ description: "Cohere",
12
+ })}`,
13
+ },
7
14
  retry,
8
15
  throttle,
9
16
  });
10
- Object.defineProperty(this, "apiKey", {
11
- enumerable: true,
12
- configurable: true,
13
- writable: true,
14
- value: void 0
15
- });
16
- this.apiKey = loadApiKey({
17
- apiKey,
18
- environmentVariableName: "COHERE_API_KEY",
19
- description: "Cohere",
20
- });
21
- }
22
- get headers() {
23
- return { Authorization: `Bearer ${this.apiKey}` };
24
17
  }
25
18
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.failedCohereCallResponseHandler = exports.CohereError = exports.cohereErrorDataSchema = void 0;
7
7
  const secure_json_parse_1 = __importDefault(require("secure-json-parse"));
8
8
  const zod_1 = require("zod");
9
- const ApiCallError_js_1 = require("../../util/api/ApiCallError.cjs");
9
+ const ApiCallError_js_1 = require("../../core/api/ApiCallError.cjs");
10
10
  exports.cohereErrorDataSchema = zod_1.z.object({
11
11
  message: zod_1.z.string(),
12
12
  });
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import { ApiCallError } from "../../util/api/ApiCallError.js";
3
- import { ResponseHandler } from "../../util/api/postToApi.js";
2
+ import { ApiCallError } from "../../core/api/ApiCallError.js";
3
+ import { ResponseHandler } from "../../core/api/postToApi.js";
4
4
  export declare const cohereErrorDataSchema: z.ZodObject<{
5
5
  message: z.ZodString;
6
6
  }, "strip", z.ZodTypeAny, {
@@ -1,6 +1,6 @@
1
1
  import SecureJSON from "secure-json-parse";
2
2
  import { z } from "zod";
3
- import { ApiCallError } from "../../util/api/ApiCallError.js";
3
+ import { ApiCallError } from "../../core/api/ApiCallError.js";
4
4
  export const cohereErrorDataSchema = z.object({
5
5
  message: z.string(),
6
6
  });
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CohereTextEmbeddingModel = exports.COHERE_TEXT_EMBEDDING_MODELS = void 0;
7
7
  const zod_1 = __importDefault(require("zod"));
8
8
  const AbstractModel_js_1 = require("../../model-function/AbstractModel.cjs");
9
- const callWithRetryAndThrottle_js_1 = require("../../util/api/callWithRetryAndThrottle.cjs");
10
- const postToApi_js_1 = require("../../util/api/postToApi.cjs");
9
+ const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
10
+ const postToApi_js_1 = require("../../core/api/postToApi.cjs");
11
11
  const CohereApiConfiguration_js_1 = require("./CohereApiConfiguration.cjs");
12
12
  const CohereError_js_1 = require("./CohereError.cjs");
13
13
  const CohereTokenizer_js_1 = require("./CohereTokenizer.cjs");
@@ -1,6 +1,6 @@
1
1
  import z from "zod";
2
2
  import { AbstractModel } from "../../model-function/AbstractModel.js";
3
- import { ApiConfiguration } from "../../model-function/ApiConfiguration.js";
3
+ import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
4
4
  import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
5
5
  import { TextEmbeddingModel, TextEmbeddingModelSettings } from "../../model-function/embed-text/TextEmbeddingModel.js";
6
6
  import { FullTokenizer } from "../../model-function/tokenize-text/Tokenizer.js";
@@ -1,7 +1,7 @@
1
1
  import z from "zod";
2
2
  import { AbstractModel } from "../../model-function/AbstractModel.js";
3
- import { callWithRetryAndThrottle } from "../../util/api/callWithRetryAndThrottle.js";
4
- import { createJsonResponseHandler, postJsonToApi, } from "../../util/api/postToApi.js";
3
+ import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
4
+ import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
5
5
  import { CohereApiConfiguration } from "./CohereApiConfiguration.js";
6
6
  import { failedCohereCallResponseHandler } from "./CohereError.js";
7
7
  import { CohereTokenizer } from "./CohereTokenizer.js";
@@ -10,8 +10,8 @@ const AbstractModel_js_1 = require("../../model-function/AbstractModel.cjs");
10
10
  const AsyncQueue_js_1 = require("../../model-function/generate-text/AsyncQueue.cjs");
11
11
  const countTokens_js_1 = require("../../model-function/tokenize-text/countTokens.cjs");
12
12
  const PromptFormatTextGenerationModel_js_1 = require("../../prompt/PromptFormatTextGenerationModel.cjs");
13
- const callWithRetryAndThrottle_js_1 = require("../../util/api/callWithRetryAndThrottle.cjs");
14
- const postToApi_js_1 = require("../../util/api/postToApi.cjs");
13
+ const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
14
+ const postToApi_js_1 = require("../../core/api/postToApi.cjs");
15
15
  const CohereApiConfiguration_js_1 = require("./CohereApiConfiguration.cjs");
16
16
  const CohereError_js_1 = require("./CohereError.cjs");
17
17
  const CohereTokenizer_js_1 = require("./CohereTokenizer.cjs");