2023-09-10 18:56:17 +00:00
|
|
|
import { GrammyTypes, IKV } from "../deps.ts";
|
|
|
|
import { db } from "./db.ts";
|
|
|
|
|
2023-09-22 02:59:22 +00:00
|
|
|
export interface GenerationSchema {
|
2023-09-12 01:57:44 +00:00
|
|
|
from: GrammyTypes.User;
|
|
|
|
chat: GrammyTypes.Chat;
|
2023-09-24 12:05:28 +00:00
|
|
|
sdInstanceId?: string;
|
|
|
|
info?: SdGenerationInfo;
|
|
|
|
startDate?: Date;
|
|
|
|
endDate?: Date;
|
2023-09-10 18:56:17 +00:00
|
|
|
}
|
|
|
|
|
2023-09-22 02:59:22 +00:00
|
|
|
/**
|
|
|
|
* `info` field in generation response is a serialized json string of this shape.
|
|
|
|
*/
|
|
|
|
export interface SdGenerationInfo {
|
|
|
|
prompt: string;
|
|
|
|
all_prompts: string[];
|
|
|
|
negative_prompt: string;
|
|
|
|
all_negative_prompts: string[];
|
|
|
|
seed: number;
|
|
|
|
all_seeds: number[];
|
|
|
|
subseed: number;
|
|
|
|
all_subseeds: number[];
|
|
|
|
subseed_strength: number;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
|
|
|
sampler_name: string;
|
|
|
|
cfg_scale: number;
|
|
|
|
steps: number;
|
|
|
|
batch_size: number;
|
|
|
|
restore_faces: boolean;
|
|
|
|
face_restoration_model: unknown;
|
|
|
|
sd_model_hash: string;
|
|
|
|
seed_resize_from_w: number;
|
|
|
|
seed_resize_from_h: number;
|
|
|
|
denoising_strength: number;
|
|
|
|
extra_generation_params: Record<string, string>;
|
|
|
|
index_of_first_image: number;
|
|
|
|
infotexts: string[];
|
|
|
|
styles: unknown[];
|
|
|
|
job_timestamp: string;
|
|
|
|
clip_skip: number;
|
|
|
|
is_using_inpainting_conditioning: boolean;
|
|
|
|
}
|
2023-09-17 23:01:09 +00:00
|
|
|
|
2023-09-24 12:05:28 +00:00
|
|
|
type GenerationIndices = {
|
|
|
|
fromId: number;
|
|
|
|
chatId: number;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const generationStore = new IKV.Store<GenerationSchema, GenerationIndices>(
|
|
|
|
db,
|
|
|
|
"generations",
|
|
|
|
{
|
|
|
|
indices: {
|
|
|
|
fromId: { getValue: (item) => item.from.id },
|
|
|
|
chatId: { getValue: (item) => item.chat.id },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|