modelfusion 0.27.3 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -6
- package/{model-function/BasicApiConfiguration.js → core/api/AbstractApiConfiguration.cjs} +6 -15
- package/core/api/AbstractApiConfiguration.d.ts +13 -0
- package/core/api/AbstractApiConfiguration.js +18 -0
- package/core/api/ApiConfiguration.d.ts +32 -0
- package/core/api/BaseUrlApiConfiguration.cjs +32 -0
- package/core/api/BaseUrlApiConfiguration.d.ts +19 -0
- package/core/api/BaseUrlApiConfiguration.js +28 -0
- package/core/api/index.cjs +27 -0
- package/core/api/index.d.ts +11 -0
- package/core/api/index.js +11 -0
- package/{util → core}/api/postToApi.d.ts +1 -1
- package/core/index.cjs +1 -0
- package/core/index.d.ts +1 -0
- package/core/index.js +1 -0
- package/model-function/ModelCallEvent.d.ts +3 -2
- package/model-function/SuccessfulModelCall.d.ts +1 -1
- package/model-function/describe-image/ImageDescriptionEvent.cjs +2 -0
- package/model-function/describe-image/ImageDescriptionEvent.d.ts +18 -0
- package/model-function/describe-image/ImageDescriptionEvent.js +1 -0
- package/model-function/describe-image/ImageDescriptionModel.cjs +2 -0
- package/model-function/describe-image/ImageDescriptionModel.d.ts +8 -0
- package/model-function/describe-image/ImageDescriptionModel.js +1 -0
- package/model-function/describe-image/describeImage.cjs +20 -0
- package/model-function/describe-image/describeImage.d.ts +9 -0
- package/model-function/describe-image/describeImage.js +16 -0
- package/model-function/executeCall.cjs +1 -1
- package/model-function/executeCall.js +1 -1
- package/model-function/generate-text/streamText.cjs +1 -1
- package/model-function/generate-text/streamText.js +1 -1
- package/model-function/index.cjs +3 -2
- package/model-function/index.d.ts +3 -2
- package/model-function/index.js +3 -2
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.cjs +3 -2
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.d.ts +4 -4
- package/model-provider/automatic1111/Automatic1111ApiConfiguration.js +3 -2
- package/model-provider/automatic1111/Automatic1111Error.cjs +1 -1
- package/model-provider/automatic1111/Automatic1111Error.d.ts +2 -2
- package/model-provider/automatic1111/Automatic1111Error.js +1 -1
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.cjs +2 -2
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.d.ts +1 -1
- package/model-provider/automatic1111/Automatic1111ImageGenerationModel.js +2 -2
- package/model-provider/cohere/CohereApiConfiguration.cjs +10 -17
- package/model-provider/cohere/CohereApiConfiguration.d.ts +4 -6
- package/model-provider/cohere/CohereApiConfiguration.js +10 -17
- package/model-provider/cohere/CohereError.cjs +1 -1
- package/model-provider/cohere/CohereError.d.ts +2 -2
- package/model-provider/cohere/CohereError.js +1 -1
- package/model-provider/cohere/CohereTextEmbeddingModel.cjs +2 -2
- package/model-provider/cohere/CohereTextEmbeddingModel.d.ts +1 -1
- package/model-provider/cohere/CohereTextEmbeddingModel.js +2 -2
- package/model-provider/cohere/CohereTextGenerationModel.cjs +2 -2
- package/model-provider/cohere/CohereTextGenerationModel.d.ts +2 -2
- package/model-provider/cohere/CohereTextGenerationModel.js +2 -2
- package/model-provider/cohere/CohereTokenizer.cjs +2 -2
- package/model-provider/cohere/CohereTokenizer.d.ts +1 -1
- package/model-provider/cohere/CohereTokenizer.js +2 -2
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.cjs +10 -17
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.d.ts +4 -6
- package/model-provider/elevenlabs/ElevenLabsApiConfiguration.js +10 -17
- package/model-provider/elevenlabs/ElevenLabsError.cjs +1 -1
- package/model-provider/elevenlabs/ElevenLabsError.d.ts +2 -2
- package/model-provider/elevenlabs/ElevenLabsError.js +1 -1
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.cjs +2 -2
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.d.ts +1 -1
- package/model-provider/elevenlabs/ElevenLabsSpeechSynthesisModel.js +2 -2
- package/model-provider/huggingface/HuggingFaceApiConfiguration.cjs +10 -17
- package/model-provider/huggingface/HuggingFaceApiConfiguration.d.ts +4 -6
- package/model-provider/huggingface/HuggingFaceApiConfiguration.js +10 -17
- package/model-provider/huggingface/HuggingFaceError.cjs +5 -3
- package/model-provider/huggingface/HuggingFaceError.d.ts +5 -5
- package/model-provider/huggingface/HuggingFaceError.js +5 -3
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.cjs +81 -0
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.d.ts +37 -0
- package/model-provider/huggingface/HuggingFaceImageDescriptionModel.js +74 -0
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.cjs +2 -2
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.d.ts +1 -1
- package/model-provider/huggingface/HuggingFaceTextEmbeddingModel.js +2 -2
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.cjs +2 -2
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.d.ts +1 -1
- package/model-provider/huggingface/HuggingFaceTextGenerationModel.js +2 -2
- package/model-provider/huggingface/index.cjs +1 -0
- package/model-provider/huggingface/index.d.ts +1 -0
- package/model-provider/huggingface/index.js +1 -0
- package/model-provider/llamacpp/LlamaCppApiConfiguration.cjs +3 -2
- package/model-provider/llamacpp/LlamaCppApiConfiguration.d.ts +4 -4
- package/model-provider/llamacpp/LlamaCppApiConfiguration.js +3 -2
- package/model-provider/llamacpp/LlamaCppError.cjs +1 -1
- package/model-provider/llamacpp/LlamaCppError.d.ts +2 -2
- package/model-provider/llamacpp/LlamaCppError.js +1 -1
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.cjs +2 -2
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.d.ts +1 -1
- package/model-provider/llamacpp/LlamaCppTextEmbeddingModel.js +2 -2
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.cjs +2 -2
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.d.ts +2 -2
- package/model-provider/llamacpp/LlamaCppTextGenerationModel.js +2 -2
- package/model-provider/llamacpp/LlamaCppTokenizer.cjs +2 -2
- package/model-provider/llamacpp/LlamaCppTokenizer.d.ts +1 -1
- package/model-provider/llamacpp/LlamaCppTokenizer.js +2 -2
- package/model-provider/lmnt/LmntApiConfiguration.cjs +10 -17
- package/model-provider/lmnt/LmntApiConfiguration.d.ts +4 -6
- package/model-provider/lmnt/LmntApiConfiguration.js +10 -17
- package/model-provider/lmnt/LmntError.cjs +1 -1
- package/model-provider/lmnt/LmntError.d.ts +2 -2
- package/model-provider/lmnt/LmntError.js +1 -1
- package/model-provider/lmnt/LmntSpeechSynthesisModel.cjs +2 -2
- package/model-provider/lmnt/LmntSpeechSynthesisModel.d.ts +1 -1
- package/model-provider/lmnt/LmntSpeechSynthesisModel.js +2 -2
- package/model-provider/openai/AzureOpenAIApiConfiguration.cjs +13 -20
- package/model-provider/openai/AzureOpenAIApiConfiguration.d.ts +5 -6
- package/model-provider/openai/AzureOpenAIApiConfiguration.js +13 -20
- package/model-provider/openai/OpenAIApiConfiguration.cjs +10 -19
- package/model-provider/openai/OpenAIApiConfiguration.d.ts +4 -6
- package/model-provider/openai/OpenAIApiConfiguration.js +10 -19
- package/model-provider/openai/OpenAIError.cjs +1 -1
- package/model-provider/openai/OpenAIError.d.ts +6 -6
- package/model-provider/openai/OpenAIError.js +1 -1
- package/model-provider/openai/OpenAIImageGenerationModel.cjs +2 -2
- package/model-provider/openai/OpenAIImageGenerationModel.d.ts +2 -2
- package/model-provider/openai/OpenAIImageGenerationModel.js +2 -2
- package/model-provider/openai/OpenAITextEmbeddingModel.cjs +2 -2
- package/model-provider/openai/OpenAITextEmbeddingModel.d.ts +1 -1
- package/model-provider/openai/OpenAITextEmbeddingModel.js +2 -2
- package/model-provider/openai/OpenAITextGenerationModel.cjs +2 -2
- package/model-provider/openai/OpenAITextGenerationModel.d.ts +2 -2
- package/model-provider/openai/OpenAITextGenerationModel.js +2 -2
- package/model-provider/openai/OpenAITranscriptionModel.cjs +2 -2
- package/model-provider/openai/OpenAITranscriptionModel.d.ts +2 -2
- package/model-provider/openai/OpenAITranscriptionModel.js +2 -2
- package/model-provider/openai/chat/OpenAIChatModel.cjs +2 -2
- package/model-provider/openai/chat/OpenAIChatModel.d.ts +2 -2
- package/model-provider/openai/chat/OpenAIChatModel.js +2 -2
- package/model-provider/stability/StabilityApiConfiguration.cjs +10 -19
- package/model-provider/stability/StabilityApiConfiguration.d.ts +4 -6
- package/model-provider/stability/StabilityApiConfiguration.js +10 -19
- package/model-provider/stability/StabilityError.cjs +1 -1
- package/model-provider/stability/StabilityError.d.ts +2 -2
- package/model-provider/stability/StabilityError.js +1 -1
- package/model-provider/stability/StabilityImageGenerationModel.cjs +2 -2
- package/model-provider/stability/StabilityImageGenerationModel.d.ts +1 -1
- package/model-provider/stability/StabilityImageGenerationModel.js +2 -2
- package/observability/helicone/HeliconeOpenAIApiConfiguration.cjs +17 -33
- package/observability/helicone/HeliconeOpenAIApiConfiguration.d.ts +4 -7
- package/observability/helicone/HeliconeOpenAIApiConfiguration.js +17 -33
- package/package.json +1 -1
- package/tool/executeTool.cjs +1 -1
- package/tool/executeTool.js +1 -1
- package/util/index.cjs +0 -9
- package/util/index.d.ts +0 -9
- package/util/index.js +0 -9
- package/model-function/ApiConfiguration.d.ts +0 -14
- package/model-function/BasicApiConfiguration.cjs +0 -35
- package/model-function/BasicApiConfiguration.d.ts +0 -15
- /package/{util → core}/api/AbortError.cjs +0 -0
- /package/{util → core}/api/AbortError.d.ts +0 -0
- /package/{util → core}/api/AbortError.js +0 -0
- /package/{util → core}/api/ApiCallError.cjs +0 -0
- /package/{util → core}/api/ApiCallError.d.ts +0 -0
- /package/{util → core}/api/ApiCallError.js +0 -0
- /package/{model-function → core/api}/ApiConfiguration.cjs +0 -0
- /package/{model-function → core/api}/ApiConfiguration.js +0 -0
- /package/{util → core}/api/RetryError.cjs +0 -0
- /package/{util → core}/api/RetryError.d.ts +0 -0
- /package/{util → core}/api/RetryError.js +0 -0
- /package/{util → core}/api/RetryFunction.cjs +0 -0
- /package/{util → core}/api/RetryFunction.d.ts +0 -0
- /package/{util → core}/api/RetryFunction.js +0 -0
- /package/{util → core}/api/ThrottleFunction.cjs +0 -0
- /package/{util → core}/api/ThrottleFunction.d.ts +0 -0
- /package/{util → core}/api/ThrottleFunction.js +0 -0
- /package/{util → core}/api/callWithRetryAndThrottle.cjs +0 -0
- /package/{util → core}/api/callWithRetryAndThrottle.d.ts +0 -0
- /package/{util → core}/api/callWithRetryAndThrottle.js +0 -0
- /package/{util → core}/api/loadApiKey.cjs +0 -0
- /package/{util → core}/api/loadApiKey.d.ts +0 -0
- /package/{util → core}/api/loadApiKey.js +0 -0
- /package/{util → core}/api/postToApi.cjs +0 -0
- /package/{util → core}/api/postToApi.js +0 -0
- /package/{util → core}/api/retryNever.cjs +0 -0
- /package/{util → core}/api/retryNever.d.ts +0 -0
- /package/{util → core}/api/retryNever.js +0 -0
- /package/{util → core}/api/retryWithExponentialBackoff.cjs +0 -0
- /package/{util → core}/api/retryWithExponentialBackoff.d.ts +0 -0
- /package/{util → core}/api/retryWithExponentialBackoff.js +0 -0
- /package/{util → core}/api/throttleMaxConcurrency.cjs +0 -0
- /package/{util → core}/api/throttleMaxConcurrency.d.ts +0 -0
- /package/{util → core}/api/throttleMaxConcurrency.js +0 -0
- /package/{util → core}/api/throttleUnlimitedConcurrency.cjs +0 -0
- /package/{util → core}/api/throttleUnlimitedConcurrency.d.ts +0 -0
- /package/{util → core}/api/throttleUnlimitedConcurrency.js +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.AzureOpenAIApiConfiguration = void 0;
|
4
|
-
const
|
5
|
-
const loadApiKey_js_1 = require("../../
|
4
|
+
const AbstractApiConfiguration_js_1 = require("../../core/api/AbstractApiConfiguration.cjs");
|
5
|
+
const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
|
6
6
|
/**
|
7
7
|
* Cconfiguration for the Azure OpenAI API. This class is responsible for constructing URLs specific to the Azure OpenAI deployment.
|
8
8
|
* It creates URLs of the form
|
@@ -10,13 +10,9 @@ const loadApiKey_js_1 = require("../../util/api/loadApiKey.cjs");
|
|
10
10
|
*
|
11
11
|
* @see https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
|
12
12
|
*/
|
13
|
-
class AzureOpenAIApiConfiguration extends
|
13
|
+
class AzureOpenAIApiConfiguration extends AbstractApiConfiguration_js_1.AbstractApiConfiguration {
|
14
14
|
constructor({ resourceName, deploymentId, apiVersion, apiKey, retry, throttle, }) {
|
15
|
-
super({
|
16
|
-
baseUrl: `https://${resourceName}.openai.azure.com/openai/deployments/${deploymentId}`,
|
17
|
-
retry,
|
18
|
-
throttle,
|
19
|
-
});
|
15
|
+
super({ retry, throttle });
|
20
16
|
Object.defineProperty(this, "resourceName", {
|
21
17
|
enumerable: true,
|
22
18
|
configurable: true,
|
@@ -35,7 +31,7 @@ class AzureOpenAIApiConfiguration extends BasicApiConfiguration_js_1.BasicApiCon
|
|
35
31
|
writable: true,
|
36
32
|
value: void 0
|
37
33
|
});
|
38
|
-
Object.defineProperty(this, "
|
34
|
+
Object.defineProperty(this, "headers", {
|
39
35
|
enumerable: true,
|
40
36
|
configurable: true,
|
41
37
|
writable: true,
|
@@ -44,19 +40,16 @@ class AzureOpenAIApiConfiguration extends BasicApiConfiguration_js_1.BasicApiCon
|
|
44
40
|
this.resourceName = resourceName;
|
45
41
|
this.deploymentId = deploymentId;
|
46
42
|
this.apiVersion = apiVersion;
|
47
|
-
this.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
this.headers = {
|
44
|
+
"api-key": (0, loadApiKey_js_1.loadApiKey)({
|
45
|
+
apiKey,
|
46
|
+
environmentVariableName: "AZURE_OPENAI_API_KEY",
|
47
|
+
description: "Azure OpenAI",
|
48
|
+
}),
|
49
|
+
};
|
52
50
|
}
|
53
51
|
assembleUrl(path) {
|
54
|
-
return
|
55
|
-
}
|
56
|
-
get headers() {
|
57
|
-
return {
|
58
|
-
"api-key": this.apiKey,
|
59
|
-
};
|
52
|
+
return `https://${this.resourceName}.openai.azure.com/openai/deployments/${this.deploymentId}${path}?api-version=${this.apiVersion}`;
|
60
53
|
}
|
61
54
|
}
|
62
55
|
exports.AzureOpenAIApiConfiguration = AzureOpenAIApiConfiguration;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import { RetryFunction } from "../../
|
3
|
-
import { ThrottleFunction } from "../../
|
1
|
+
import { AbstractApiConfiguration } from "../../core/api/AbstractApiConfiguration.js";
|
2
|
+
import { RetryFunction } from "../../core/api/RetryFunction.js";
|
3
|
+
import { ThrottleFunction } from "../../core/api/ThrottleFunction.js";
|
4
4
|
/**
|
5
5
|
* Cconfiguration for the Azure OpenAI API. This class is responsible for constructing URLs specific to the Azure OpenAI deployment.
|
6
6
|
* It creates URLs of the form
|
@@ -8,11 +8,11 @@ import { ThrottleFunction } from "../../util/api/ThrottleFunction.js";
|
|
8
8
|
*
|
9
9
|
* @see https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
|
10
10
|
*/
|
11
|
-
export declare class AzureOpenAIApiConfiguration extends
|
11
|
+
export declare class AzureOpenAIApiConfiguration extends AbstractApiConfiguration {
|
12
12
|
readonly resourceName: string;
|
13
13
|
readonly deploymentId: string;
|
14
14
|
readonly apiVersion: string;
|
15
|
-
readonly
|
15
|
+
readonly headers: Record<string, string>;
|
16
16
|
constructor({ resourceName, deploymentId, apiVersion, apiKey, retry, throttle, }: {
|
17
17
|
resourceName: string;
|
18
18
|
deploymentId: string;
|
@@ -22,5 +22,4 @@ export declare class AzureOpenAIApiConfiguration extends BasicApiConfiguration {
|
|
22
22
|
throttle?: ThrottleFunction;
|
23
23
|
});
|
24
24
|
assembleUrl(path: string): string;
|
25
|
-
get headers(): Record<string, string>;
|
26
25
|
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import { loadApiKey } from "../../
|
1
|
+
import { AbstractApiConfiguration } from "../../core/api/AbstractApiConfiguration.js";
|
2
|
+
import { loadApiKey } from "../../core/api/loadApiKey.js";
|
3
3
|
/**
|
4
4
|
* Cconfiguration for the Azure OpenAI API. This class is responsible for constructing URLs specific to the Azure OpenAI deployment.
|
5
5
|
* It creates URLs of the form
|
@@ -7,13 +7,9 @@ import { loadApiKey } from "../../util/api/loadApiKey.js";
|
|
7
7
|
*
|
8
8
|
* @see https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
|
9
9
|
*/
|
10
|
-
export class AzureOpenAIApiConfiguration extends
|
10
|
+
export class AzureOpenAIApiConfiguration extends AbstractApiConfiguration {
|
11
11
|
constructor({ resourceName, deploymentId, apiVersion, apiKey, retry, throttle, }) {
|
12
|
-
super({
|
13
|
-
baseUrl: `https://${resourceName}.openai.azure.com/openai/deployments/${deploymentId}`,
|
14
|
-
retry,
|
15
|
-
throttle,
|
16
|
-
});
|
12
|
+
super({ retry, throttle });
|
17
13
|
Object.defineProperty(this, "resourceName", {
|
18
14
|
enumerable: true,
|
19
15
|
configurable: true,
|
@@ -32,7 +28,7 @@ export class AzureOpenAIApiConfiguration extends BasicApiConfiguration {
|
|
32
28
|
writable: true,
|
33
29
|
value: void 0
|
34
30
|
});
|
35
|
-
Object.defineProperty(this, "
|
31
|
+
Object.defineProperty(this, "headers", {
|
36
32
|
enumerable: true,
|
37
33
|
configurable: true,
|
38
34
|
writable: true,
|
@@ -41,18 +37,15 @@ export class AzureOpenAIApiConfiguration extends BasicApiConfiguration {
|
|
41
37
|
this.resourceName = resourceName;
|
42
38
|
this.deploymentId = deploymentId;
|
43
39
|
this.apiVersion = apiVersion;
|
44
|
-
this.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
this.headers = {
|
41
|
+
"api-key": loadApiKey({
|
42
|
+
apiKey,
|
43
|
+
environmentVariableName: "AZURE_OPENAI_API_KEY",
|
44
|
+
description: "Azure OpenAI",
|
45
|
+
}),
|
46
|
+
};
|
49
47
|
}
|
50
48
|
assembleUrl(path) {
|
51
|
-
return
|
52
|
-
}
|
53
|
-
get headers() {
|
54
|
-
return {
|
55
|
-
"api-key": this.apiKey,
|
56
|
-
};
|
49
|
+
return `https://${this.resourceName}.openai.azure.com/openai/deployments/${this.deploymentId}${path}?api-version=${this.apiVersion}`;
|
57
50
|
}
|
58
51
|
}
|
@@ -1,31 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.OpenAIApiConfiguration = void 0;
|
4
|
-
const
|
5
|
-
const loadApiKey_js_1 = require("../../
|
6
|
-
class OpenAIApiConfiguration extends
|
4
|
+
const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
|
5
|
+
const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
|
6
|
+
class OpenAIApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfiguration {
|
7
7
|
constructor({ baseUrl = "https://api.openai.com/v1", apiKey, retry, throttle, } = {}) {
|
8
8
|
super({
|
9
9
|
baseUrl,
|
10
|
+
headers: {
|
11
|
+
Authorization: `Bearer ${(0, loadApiKey_js_1.loadApiKey)({
|
12
|
+
apiKey,
|
13
|
+
environmentVariableName: "OPENAI_API_KEY",
|
14
|
+
description: "OpenAI",
|
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: "OPENAI_API_KEY",
|
22
|
-
description: "OpenAI",
|
23
|
-
});
|
24
|
-
}
|
25
|
-
get headers() {
|
26
|
-
return {
|
27
|
-
Authorization: `Bearer ${this.apiKey}`,
|
28
|
-
};
|
29
20
|
}
|
30
21
|
}
|
31
22
|
exports.OpenAIApiConfiguration = OpenAIApiConfiguration;
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import { RetryFunction } from "../../
|
3
|
-
import { ThrottleFunction } from "../../
|
4
|
-
export declare class OpenAIApiConfiguration extends
|
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 OpenAIApiConfiguration 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,27 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
import { loadApiKey } from "../../
|
3
|
-
export class OpenAIApiConfiguration extends
|
1
|
+
import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
|
2
|
+
import { loadApiKey } from "../../core/api/loadApiKey.js";
|
3
|
+
export class OpenAIApiConfiguration extends BaseUrlApiConfiguration {
|
4
4
|
constructor({ baseUrl = "https://api.openai.com/v1", apiKey, retry, throttle, } = {}) {
|
5
5
|
super({
|
6
6
|
baseUrl,
|
7
|
+
headers: {
|
8
|
+
Authorization: `Bearer ${loadApiKey({
|
9
|
+
apiKey,
|
10
|
+
environmentVariableName: "OPENAI_API_KEY",
|
11
|
+
description: "OpenAI",
|
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: "OPENAI_API_KEY",
|
19
|
-
description: "OpenAI",
|
20
|
-
});
|
21
|
-
}
|
22
|
-
get headers() {
|
23
|
-
return {
|
24
|
-
Authorization: `Bearer ${this.apiKey}`,
|
25
|
-
};
|
26
17
|
}
|
27
18
|
}
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.failedOpenAICallResponseHandler = exports.OpenAIError = exports.openAIErrorDataSchema = 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("../../
|
9
|
+
const ApiCallError_js_1 = require("../../core/api/ApiCallError.cjs");
|
10
10
|
exports.openAIErrorDataSchema = zod_1.z.object({
|
11
11
|
error: zod_1.z.object({
|
12
12
|
message: zod_1.z.string(),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { z } from "zod";
|
2
|
-
import { ApiCallError } from "../../
|
3
|
-
import { ResponseHandler } from "../../
|
2
|
+
import { ApiCallError } from "../../core/api/ApiCallError.js";
|
3
|
+
import { ResponseHandler } from "../../core/api/postToApi.js";
|
4
4
|
export declare const openAIErrorDataSchema: z.ZodObject<{
|
5
5
|
error: z.ZodObject<{
|
6
6
|
message: z.ZodString;
|
@@ -8,27 +8,27 @@ export declare const openAIErrorDataSchema: z.ZodObject<{
|
|
8
8
|
param: z.ZodNullable<z.ZodAny>;
|
9
9
|
code: z.ZodNullable<z.ZodString>;
|
10
10
|
}, "strip", z.ZodTypeAny, {
|
11
|
-
code: string | null;
|
12
11
|
message: string;
|
12
|
+
code: string | null;
|
13
13
|
type: string;
|
14
14
|
param?: any;
|
15
15
|
}, {
|
16
|
-
code: string | null;
|
17
16
|
message: string;
|
17
|
+
code: string | null;
|
18
18
|
type: string;
|
19
19
|
param?: any;
|
20
20
|
}>;
|
21
21
|
}, "strip", z.ZodTypeAny, {
|
22
22
|
error: {
|
23
|
-
code: string | null;
|
24
23
|
message: string;
|
24
|
+
code: string | null;
|
25
25
|
type: string;
|
26
26
|
param?: any;
|
27
27
|
};
|
28
28
|
}, {
|
29
29
|
error: {
|
30
|
-
code: string | null;
|
31
30
|
message: string;
|
31
|
+
code: string | null;
|
32
32
|
type: string;
|
33
33
|
param?: any;
|
34
34
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import SecureJSON from "secure-json-parse";
|
2
2
|
import { z } from "zod";
|
3
|
-
import { ApiCallError } from "../../
|
3
|
+
import { ApiCallError } from "../../core/api/ApiCallError.js";
|
4
4
|
export const openAIErrorDataSchema = z.object({
|
5
5
|
error: z.object({
|
6
6
|
message: z.string(),
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenAIImageGenerationResponseFormat = exports.OpenAIImageGenerationModel = exports.calculateOpenAIImageGenerationCostInMillicents = 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("../../
|
7
|
-
const postToApi_js_1 = require("../../
|
6
|
+
const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
|
7
|
+
const postToApi_js_1 = require("../../core/api/postToApi.cjs");
|
8
8
|
const OpenAIApiConfiguration_js_1 = require("./OpenAIApiConfiguration.cjs");
|
9
9
|
const OpenAIError_js_1 = require("./OpenAIError.cjs");
|
10
10
|
/**
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { z } from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
3
|
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
4
|
-
import { ApiConfiguration } from "../../
|
4
|
+
import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
|
5
5
|
import { ImageGenerationModel, ImageGenerationModelSettings } from "../../model-function/generate-image/ImageGenerationModel.js";
|
6
|
-
import { ResponseHandler } from "../../
|
6
|
+
import { ResponseHandler } from "../../core/api/postToApi.js";
|
7
7
|
export interface OpenAIImageGenerationCallSettings {
|
8
8
|
n?: number;
|
9
9
|
size?: "256x256" | "512x512" | "1024x1024";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { z } from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
|
-
import { callWithRetryAndThrottle } from "../../
|
4
|
-
import { createJsonResponseHandler, postJsonToApi, } from "../../
|
3
|
+
import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
|
4
|
+
import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
|
5
5
|
import { OpenAIApiConfiguration } from "./OpenAIApiConfiguration.js";
|
6
6
|
import { failedOpenAICallResponseHandler } from "./OpenAIError.js";
|
7
7
|
/**
|
@@ -7,8 +7,8 @@ exports.OpenAITextEmbeddingModel = exports.calculateOpenAIEmbeddingCostInMillice
|
|
7
7
|
const zod_1 = __importDefault(require("zod"));
|
8
8
|
const AbstractModel_js_1 = require("../../model-function/AbstractModel.cjs");
|
9
9
|
const countTokens_js_1 = require("../../model-function/tokenize-text/countTokens.cjs");
|
10
|
-
const callWithRetryAndThrottle_js_1 = require("../../
|
11
|
-
const postToApi_js_1 = require("../../
|
10
|
+
const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
|
11
|
+
const postToApi_js_1 = require("../../core/api/postToApi.cjs");
|
12
12
|
const OpenAIApiConfiguration_js_1 = require("./OpenAIApiConfiguration.cjs");
|
13
13
|
const OpenAIError_js_1 = require("./OpenAIError.cjs");
|
14
14
|
const TikTokenTokenizer_js_1 = require("./TikTokenTokenizer.cjs");
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
3
|
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
4
|
-
import { ApiConfiguration } from "../../
|
4
|
+
import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
|
5
5
|
import { TextEmbeddingModel, TextEmbeddingModelSettings } from "../../model-function/embed-text/TextEmbeddingModel.js";
|
6
6
|
import { TikTokenTokenizer } from "./TikTokenTokenizer.js";
|
7
7
|
export declare const OPENAI_TEXT_EMBEDDING_MODELS: {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
3
|
import { countTokens } from "../../model-function/tokenize-text/countTokens.js";
|
4
|
-
import { callWithRetryAndThrottle } from "../../
|
5
|
-
import { createJsonResponseHandler, postJsonToApi, } from "../../
|
4
|
+
import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
|
5
|
+
import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
|
6
6
|
import { OpenAIApiConfiguration } from "./OpenAIApiConfiguration.js";
|
7
7
|
import { failedOpenAICallResponseHandler } from "./OpenAIError.js";
|
8
8
|
import { TikTokenTokenizer } from "./TikTokenTokenizer.js";
|
@@ -11,8 +11,8 @@ const AsyncQueue_js_1 = require("../../model-function/generate-text/AsyncQueue.c
|
|
11
11
|
const parseEventSourceReadableStream_js_1 = require("../../model-function/generate-text/parseEventSourceReadableStream.cjs");
|
12
12
|
const countTokens_js_1 = require("../../model-function/tokenize-text/countTokens.cjs");
|
13
13
|
const PromptFormatTextGenerationModel_js_1 = require("../../prompt/PromptFormatTextGenerationModel.cjs");
|
14
|
-
const callWithRetryAndThrottle_js_1 = require("../../
|
15
|
-
const postToApi_js_1 = require("../../
|
14
|
+
const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
|
15
|
+
const postToApi_js_1 = require("../../core/api/postToApi.cjs");
|
16
16
|
const OpenAIApiConfiguration_js_1 = require("./OpenAIApiConfiguration.cjs");
|
17
17
|
const OpenAIError_js_1 = require("./OpenAIError.cjs");
|
18
18
|
const TikTokenTokenizer_js_1 = require("./TikTokenTokenizer.cjs");
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
3
|
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
4
|
-
import { ApiConfiguration } from "../../
|
4
|
+
import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
|
5
5
|
import { DeltaEvent } from "../../model-function/generate-text/DeltaEvent.js";
|
6
6
|
import { TextGenerationModel, TextGenerationModelSettings } from "../../model-function/generate-text/TextGenerationModel.js";
|
7
7
|
import { PromptFormat } from "../../prompt/PromptFormat.js";
|
8
8
|
import { PromptFormatTextGenerationModel } from "../../prompt/PromptFormatTextGenerationModel.js";
|
9
|
-
import { ResponseHandler } from "../../
|
9
|
+
import { ResponseHandler } from "../../core/api/postToApi.js";
|
10
10
|
import { OpenAIImageGenerationCallSettings } from "./OpenAIImageGenerationModel.js";
|
11
11
|
import { TikTokenTokenizer } from "./TikTokenTokenizer.js";
|
12
12
|
/**
|
@@ -5,8 +5,8 @@ import { AsyncQueue } from "../../model-function/generate-text/AsyncQueue.js";
|
|
5
5
|
import { parseEventSourceReadableStream } from "../../model-function/generate-text/parseEventSourceReadableStream.js";
|
6
6
|
import { countTokens } from "../../model-function/tokenize-text/countTokens.js";
|
7
7
|
import { PromptFormatTextGenerationModel } from "../../prompt/PromptFormatTextGenerationModel.js";
|
8
|
-
import { callWithRetryAndThrottle } from "../../
|
9
|
-
import { createJsonResponseHandler, postJsonToApi, } from "../../
|
8
|
+
import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
|
9
|
+
import { createJsonResponseHandler, postJsonToApi, } from "../../core/api/postToApi.js";
|
10
10
|
import { OpenAIApiConfiguration } from "./OpenAIApiConfiguration.js";
|
11
11
|
import { failedOpenAICallResponseHandler } from "./OpenAIError.js";
|
12
12
|
import { TikTokenTokenizer } from "./TikTokenTokenizer.js";
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OpenAITranscriptionResponseFormat = exports.OpenAITranscriptionModel = exports.calculateOpenAITranscriptionCostInMillicents = exports.OPENAI_TRANSCRIPTION_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("../../
|
10
|
-
const postToApi_js_1 = require("../../
|
9
|
+
const callWithRetryAndThrottle_js_1 = require("../../core/api/callWithRetryAndThrottle.cjs");
|
10
|
+
const postToApi_js_1 = require("../../core/api/postToApi.cjs");
|
11
11
|
const OpenAIApiConfiguration_js_1 = require("./OpenAIApiConfiguration.cjs");
|
12
12
|
const OpenAIError_js_1 = require("./OpenAIError.cjs");
|
13
13
|
/**
|
@@ -2,9 +2,9 @@
|
|
2
2
|
import z from "zod";
|
3
3
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
4
4
|
import { ModelFunctionOptions } from "../../model-function/ModelFunctionOptions.js";
|
5
|
-
import { ApiConfiguration } from "../../
|
5
|
+
import { ApiConfiguration } from "../../core/api/ApiConfiguration.js";
|
6
6
|
import { TranscriptionModel, TranscriptionModelSettings } from "../../model-function/transcribe-speech/TranscriptionModel.js";
|
7
|
-
import { ResponseHandler } from "../../
|
7
|
+
import { ResponseHandler } from "../../core/api/postToApi.js";
|
8
8
|
/**
|
9
9
|
* @see https://openai.com/pricing
|
10
10
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../model-function/AbstractModel.js";
|
3
|
-
import { callWithRetryAndThrottle } from "../../
|
4
|
-
import { createJsonResponseHandler, createTextResponseHandler, postToApi, } from "../../
|
3
|
+
import { callWithRetryAndThrottle } from "../../core/api/callWithRetryAndThrottle.js";
|
4
|
+
import { createJsonResponseHandler, createTextResponseHandler, postToApi, } from "../../core/api/postToApi.js";
|
5
5
|
import { OpenAIApiConfiguration } from "./OpenAIApiConfiguration.js";
|
6
6
|
import { failedOpenAICallResponseHandler } from "./OpenAIError.js";
|
7
7
|
/**
|
@@ -8,8 +8,8 @@ const secure_json_parse_1 = __importDefault(require("secure-json-parse"));
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
9
9
|
const AbstractModel_js_1 = require("../../../model-function/AbstractModel.cjs");
|
10
10
|
const PromptFormatTextGenerationModel_js_1 = require("../../../prompt/PromptFormatTextGenerationModel.cjs");
|
11
|
-
const callWithRetryAndThrottle_js_1 = require("../../../
|
12
|
-
const postToApi_js_1 = require("../../../
|
11
|
+
const callWithRetryAndThrottle_js_1 = require("../../../core/api/callWithRetryAndThrottle.cjs");
|
12
|
+
const postToApi_js_1 = require("../../../core/api/postToApi.cjs");
|
13
13
|
const OpenAIApiConfiguration_js_1 = require("../OpenAIApiConfiguration.cjs");
|
14
14
|
const OpenAIError_js_1 = require("../OpenAIError.cjs");
|
15
15
|
const TikTokenTokenizer_js_1 = require("../TikTokenTokenizer.cjs");
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import z from "zod";
|
2
2
|
import { AbstractModel } from "../../../model-function/AbstractModel.js";
|
3
3
|
import { ModelFunctionOptions } from "../../../model-function/ModelFunctionOptions.js";
|
4
|
-
import { ApiConfiguration } from "../../../
|
4
|
+
import { ApiConfiguration } from "../../../core/api/ApiConfiguration.js";
|
5
5
|
import { JsonGenerationModel } from "../../../model-function/generate-json/JsonGenerationModel.js";
|
6
6
|
import { JsonOrTextGenerationModel } from "../../../model-function/generate-json/JsonOrTextGenerationModel.js";
|
7
7
|
import { DeltaEvent } from "../../../model-function/generate-text/DeltaEvent.js";
|
8
8
|
import { TextGenerationModel, TextGenerationModelSettings } from "../../../model-function/generate-text/TextGenerationModel.js";
|
9
9
|
import { PromptFormat } from "../../../prompt/PromptFormat.js";
|
10
10
|
import { PromptFormatTextGenerationModel } from "../../../prompt/PromptFormatTextGenerationModel.js";
|
11
|
-
import { ResponseHandler } from "../../../
|
11
|
+
import { ResponseHandler } from "../../../core/api/postToApi.js";
|
12
12
|
import { TikTokenTokenizer } from "../TikTokenTokenizer.js";
|
13
13
|
import { OpenAIChatMessage } from "./OpenAIChatMessage.js";
|
14
14
|
import { OpenAIChatAutoFunctionPrompt, OpenAIChatSingleFunctionPrompt, OpenAIFunctionDescription } from "./OpenAIChatPrompt.js";
|
@@ -2,8 +2,8 @@ import SecureJSON from "secure-json-parse";
|
|
2
2
|
import z from "zod";
|
3
3
|
import { AbstractModel } from "../../../model-function/AbstractModel.js";
|
4
4
|
import { PromptFormatTextGenerationModel } from "../../../prompt/PromptFormatTextGenerationModel.js";
|
5
|
-
import { callWithRetryAndThrottle } from "../../../
|
6
|
-
import { createJsonResponseHandler, postJsonToApi, } from "../../../
|
5
|
+
import { callWithRetryAndThrottle } from "../../../core/api/callWithRetryAndThrottle.js";
|
6
|
+
import { createJsonResponseHandler, postJsonToApi, } from "../../../core/api/postToApi.js";
|
7
7
|
import { OpenAIApiConfiguration } from "../OpenAIApiConfiguration.js";
|
8
8
|
import { failedOpenAICallResponseHandler } from "../OpenAIError.js";
|
9
9
|
import { TikTokenTokenizer } from "../TikTokenTokenizer.js";
|
@@ -1,31 +1,22 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.StabilityApiConfiguration = void 0;
|
4
|
-
const
|
5
|
-
const loadApiKey_js_1 = require("../../
|
6
|
-
class StabilityApiConfiguration extends
|
4
|
+
const BaseUrlApiConfiguration_js_1 = require("../../core/api/BaseUrlApiConfiguration.cjs");
|
5
|
+
const loadApiKey_js_1 = require("../../core/api/loadApiKey.cjs");
|
6
|
+
class StabilityApiConfiguration extends BaseUrlApiConfiguration_js_1.BaseUrlApiConfiguration {
|
7
7
|
constructor({ baseUrl = "https://api.stability.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: "STABILITY_API_KEY",
|
14
|
+
description: "Stability",
|
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: "STABILITY_API_KEY",
|
22
|
-
description: "Stability",
|
23
|
-
});
|
24
|
-
}
|
25
|
-
get headers() {
|
26
|
-
return {
|
27
|
-
Authorization: `Bearer ${this.apiKey}`,
|
28
|
-
};
|
29
20
|
}
|
30
21
|
}
|
31
22
|
exports.StabilityApiConfiguration = StabilityApiConfiguration;
|
@@ -1,13 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import { RetryFunction } from "../../
|
3
|
-
import { ThrottleFunction } from "../../
|
4
|
-
export declare class StabilityApiConfiguration extends
|
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 StabilityApiConfiguration 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,27 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
import { loadApiKey } from "../../
|
3
|
-
export class StabilityApiConfiguration extends
|
1
|
+
import { BaseUrlApiConfiguration } from "../../core/api/BaseUrlApiConfiguration.js";
|
2
|
+
import { loadApiKey } from "../../core/api/loadApiKey.js";
|
3
|
+
export class StabilityApiConfiguration extends BaseUrlApiConfiguration {
|
4
4
|
constructor({ baseUrl = "https://api.stability.ai/v1", apiKey, retry, throttle, } = {}) {
|
5
5
|
super({
|
6
6
|
baseUrl,
|
7
|
+
headers: {
|
8
|
+
Authorization: `Bearer ${loadApiKey({
|
9
|
+
apiKey,
|
10
|
+
environmentVariableName: "STABILITY_API_KEY",
|
11
|
+
description: "Stability",
|
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: "STABILITY_API_KEY",
|
19
|
-
description: "Stability",
|
20
|
-
});
|
21
|
-
}
|
22
|
-
get headers() {
|
23
|
-
return {
|
24
|
-
Authorization: `Bearer ${this.apiKey}`,
|
25
|
-
};
|
26
17
|
}
|
27
18
|
}
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.failedStabilityCallResponseHandler = exports.StabilityError = exports.stabilityErrorDataSchema = 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("../../
|
9
|
+
const ApiCallError_js_1 = require("../../core/api/ApiCallError.cjs");
|
10
10
|
exports.stabilityErrorDataSchema = zod_1.z.object({
|
11
11
|
message: zod_1.z.string(),
|
12
12
|
});
|