feat(image): default response_format to url for upstream compatibility
This commit is contained in:
1 parent
b612af1c38
commit
3c5e5dd023
3 files changed
+9
-4
No files matched your search
Vendored
+1
@@ -11,6 +11,7 @@ export interface ImagePluginConfig {
|
|||||||
allowPrivateNetwork?: boolean;
|
allowPrivateNetwork?: boolean;
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
models?: string[];
|
models?: string[];
|
||||||
|
responseFormat?: "url" | "b64_json";
|
||||||
}
|
}
|
||||||
export declare function resolvePluginApiKey(rawKey: string | SecretRefObject | undefined): string | undefined;
|
export declare function resolvePluginApiKey(rawKey: string | SecretRefObject | undefined): string | undefined;
|
||||||
export declare function resolveImageConfig(cfg: ImageGenerationRequest["cfg"] | undefined, apiPluginConfig?: Record<string, unknown>): ImagePluginConfig | undefined;
|
export declare function resolveImageConfig(cfg: ImageGenerationRequest["cfg"] | undefined, apiPluginConfig?: Record<string, unknown>): ImagePluginConfig | undefined;
|
||||||
|
|||||||
Vendored
+3
-2
@@ -188,13 +188,14 @@ export function buildOpenAIImageGenerationProvider({ isProviderApiKeyConfigured,
|
|||||||
});
|
});
|
||||||
let response;
|
let response;
|
||||||
let release;
|
let release;
|
||||||
|
const responseFormat = pluginCfg?.responseFormat ?? "url";
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.set("model", model);
|
form.set("model", model);
|
||||||
form.set("prompt", req.prompt);
|
form.set("prompt", req.prompt);
|
||||||
form.set("n", String(count));
|
form.set("n", String(count));
|
||||||
form.set("size", size);
|
form.set("size", size);
|
||||||
form.set("response_format", "b64_json");
|
form.set("response_format", responseFormat);
|
||||||
inputImages.forEach((img, idx) => {
|
inputImages.forEach((img, idx) => {
|
||||||
const mime = img.mimeType || "image/png";
|
const mime = img.mimeType || "image/png";
|
||||||
const ext = extensionForMime(mime)?.slice(1) || "png";
|
const ext = extensionForMime(mime)?.slice(1) || "png";
|
||||||
@@ -221,7 +222,7 @@ export function buildOpenAIImageGenerationProvider({ isProviderApiKeyConfigured,
|
|||||||
prompt: req.prompt,
|
prompt: req.prompt,
|
||||||
n: count,
|
n: count,
|
||||||
size,
|
size,
|
||||||
response_format: "b64_json",
|
response_format: responseFormat,
|
||||||
};
|
};
|
||||||
if (req.quality) {
|
if (req.quality) {
|
||||||
jsonBody.quality = req.quality;
|
jsonBody.quality = req.quality;
|
||||||
|
|||||||
+5
-2
@@ -48,6 +48,7 @@ export interface ImagePluginConfig {
|
|||||||
allowPrivateNetwork?: boolean;
|
allowPrivateNetwork?: boolean;
|
||||||
defaultModel?: string;
|
defaultModel?: string;
|
||||||
models?: string[];
|
models?: string[];
|
||||||
|
responseFormat?: "url" | "b64_json";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resolvePluginApiKey(rawKey: string | SecretRefObject | undefined): string | undefined {
|
export function resolvePluginApiKey(rawKey: string | SecretRefObject | undefined): string | undefined {
|
||||||
@@ -267,13 +268,15 @@ export function buildOpenAIImageGenerationProvider({
|
|||||||
let response: Response;
|
let response: Response;
|
||||||
let release: () => Promise<void>;
|
let release: () => Promise<void>;
|
||||||
|
|
||||||
|
const responseFormat = pluginCfg?.responseFormat ?? "url";
|
||||||
|
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.set("model", model);
|
form.set("model", model);
|
||||||
form.set("prompt", req.prompt);
|
form.set("prompt", req.prompt);
|
||||||
form.set("n", String(count));
|
form.set("n", String(count));
|
||||||
form.set("size", size);
|
form.set("size", size);
|
||||||
form.set("response_format", "b64_json");
|
form.set("response_format", responseFormat);
|
||||||
|
|
||||||
inputImages.forEach((img, idx) => {
|
inputImages.forEach((img, idx) => {
|
||||||
const mime = img.mimeType || "image/png";
|
const mime = img.mimeType || "image/png";
|
||||||
@@ -306,7 +309,7 @@ export function buildOpenAIImageGenerationProvider({
|
|||||||
prompt: req.prompt,
|
prompt: req.prompt,
|
||||||
n: count,
|
n: count,
|
||||||
size,
|
size,
|
||||||
response_format: "b64_json",
|
response_format: responseFormat,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (req.quality) {
|
if (req.quality) {
|
||||||
|
|||||||
Reference in new issue
Block a user