forked from pinks/eris
feat: send generation as file
This commit is contained in:
parent
f678324889
commit
8b5d242865
|
@ -37,6 +37,7 @@ interface GenerationJob {
|
||||||
replyMessage: Message;
|
replyMessage: Message;
|
||||||
workerInstanceKey?: string;
|
workerInstanceKey?: string;
|
||||||
progress?: number;
|
progress?: number;
|
||||||
|
asFile?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const generationQueue = new Queue<GenerationJob>(db, "jobQueue");
|
export const generationQueue = new Queue<GenerationJob>(db, "jobQueue");
|
||||||
|
@ -284,6 +285,7 @@ async function processGenerationJob(
|
||||||
replyMessage: state.replyMessage,
|
replyMessage: state.replyMessage,
|
||||||
workerInstanceKey: workerInstance.value.key,
|
workerInstanceKey: workerInstance.value.key,
|
||||||
startDate,
|
startDate,
|
||||||
|
sendOriginal: state.task.params.file,
|
||||||
endDate: new Date(),
|
endDate: new Date(),
|
||||||
imageKeys,
|
imageKeys,
|
||||||
info,
|
info,
|
||||||
|
|
|
@ -18,6 +18,7 @@ interface UploadJob {
|
||||||
replyMessage: Message;
|
replyMessage: Message;
|
||||||
workerInstanceKey?: string;
|
workerInstanceKey?: string;
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
|
sendOriginal: boolean;
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
imageKeys: Deno.KvKey[];
|
imageKeys: Deno.KvKey[];
|
||||||
info: SdGenerationInfo;
|
info: SdGenerationInfo;
|
||||||
|
@ -71,6 +72,15 @@ export async function processUploadQueue() {
|
||||||
if (!imageType) throw new Error("Image has unknown type");
|
if (!imageType) throw new Error("Image has unknown type");
|
||||||
size += imageBuffer.byteLength;
|
size += imageBuffer.byteLength;
|
||||||
types.add(imageType.ext);
|
types.add(imageType.ext);
|
||||||
|
if (state.sendOriginal) {
|
||||||
|
return InputMediaBuilder.document(
|
||||||
|
new InputFile(imageBuffer, `image${idx}.${imageType.ext}`),
|
||||||
|
// if it can fit, add caption for first photo
|
||||||
|
idx === 0 && caption.text.length <= 1024
|
||||||
|
? { caption: caption.text, caption_entities: caption.entities }
|
||||||
|
: undefined,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return InputMediaBuilder.photo(
|
return InputMediaBuilder.photo(
|
||||||
new InputFile(imageBuffer, `image${idx}.${imageType.ext}`),
|
new InputFile(imageBuffer, `image${idx}.${imageType.ext}`),
|
||||||
// if it can fit, add caption for first photo
|
// if it can fit, add caption for first photo
|
||||||
|
@ -78,6 +88,7 @@ export async function processUploadQueue() {
|
||||||
? { caption: caption.text, caption_entities: caption.entities }
|
? { caption: caption.text, caption_entities: caption.entities }
|
||||||
: undefined,
|
: undefined,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ export interface PngInfo {
|
||||||
|
|
||||||
interface PngInfoExtra extends PngInfo {
|
interface PngInfoExtra extends PngInfo {
|
||||||
upscale?: number;
|
upscale?: number;
|
||||||
|
file?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parsePngInfo(
|
export function parsePngInfo(
|
||||||
|
@ -113,6 +114,12 @@ export function parsePngInfo(
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "file": {
|
||||||
|
part = "params";
|
||||||
|
const file = value === "true" || value === "1" || value === "yes";
|
||||||
|
params.file = file;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case "model":
|
case "model":
|
||||||
case "modelhash":
|
case "modelhash":
|
||||||
case "modelname":
|
case "modelname":
|
||||||
|
|
Loading…
Reference in New Issue