mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-28 08:30:19 +09:00
feat: dall-e plugin upgrade
This commit is contained in:
parent
568ffede5c
commit
4551abdce8
@ -41,20 +41,32 @@ export class DallEAPIWrapper extends StructuredTool {
|
||||
prompt: z
|
||||
.string()
|
||||
.describe(
|
||||
'input must be a english prompt. you can set `quality: "hd"` for enhanced detail.',
|
||||
"A text description of the desired image(s). input must be a english prompt.",
|
||||
),
|
||||
size: z
|
||||
.enum(["1024x1024", "1024x1792", "1792x1024"])
|
||||
.default("1024x1024")
|
||||
.describe("images size"),
|
||||
quality: z
|
||||
.enum(["standard", "hd"])
|
||||
.default("standard")
|
||||
.describe(
|
||||
"hd increases image detail and clarity at the cost of doubled consumption, and should not be used unless specified by the user.",
|
||||
),
|
||||
style: z
|
||||
.enum(["vivid", "natural"])
|
||||
.default("vivid")
|
||||
.describe(
|
||||
"vivid leads to the creation of more intense and dramatic images, while Natural results in images that look more realistic and less exaggerated.",
|
||||
),
|
||||
});
|
||||
|
||||
/** @ignore */
|
||||
async _call({ prompt, size }: z.infer<typeof this.schema>) {
|
||||
async _call({ prompt, size, quality, style }: z.infer<typeof this.schema>) {
|
||||
let imageUrl;
|
||||
const apiUrl = `${this.baseURL}/images/generations`;
|
||||
try {
|
||||
const requestOptions = {
|
||||
let requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@ -65,8 +77,25 @@ export class DallEAPIWrapper extends StructuredTool {
|
||||
prompt: prompt,
|
||||
n: this.n,
|
||||
size: size,
|
||||
quality: quality,
|
||||
style: style,
|
||||
}),
|
||||
};
|
||||
if (this.model != "dall-e-3") {
|
||||
requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${this.apiKey}`,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: this.model,
|
||||
prompt: prompt,
|
||||
n: this.n,
|
||||
size: size,
|
||||
}),
|
||||
};
|
||||
}
|
||||
console.log(requestOptions);
|
||||
const response = await fetch(apiUrl, requestOptions);
|
||||
const json = await response.json();
|
||||
@ -98,5 +127,5 @@ export class DallEAPIWrapper extends StructuredTool {
|
||||
}
|
||||
}
|
||||
|
||||
description = `openai's dall-e 3 image generator.`;
|
||||
description = `openai's dall-e image generator.`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user