| 9 | import { eq } from "drizzle-orm"; |
| 10 | |
| 11 | const generateImage = (prompt: string) => |
| 12 | Effect.gen(function* () { |
| 13 | const res = yield* Effect.tryPromise(() => |
| 14 | fetch("https://api.getimg.ai/v1/stable-diffusion/text-to-image", { |
| 15 | method: "POST", |
| 16 | headers: { |
| 17 | "Content-Type": "application/json", |
| 18 | Authorization: `Bearer ${process.env.GETIMG_API_KEY}`, |
| 19 | }, |
| 20 | body: JSON.stringify({ |
| 21 | prompt, |
| 22 | negative_prompt: "blurry", |
| 23 | width: 512, |
| 24 | height: 512, |
| 25 | response_format: "url", |
| 26 | }), |
| 27 | }), |
| 28 | ); |
| 29 | const json = yield* Effect.tryPromise(() => res.json()); |
| 30 | console.log(json); |
| 31 | return json; |
| 32 | }); |
| 33 | const uploadImage = (imageUrl: string, path: string) => |
| 34 | Effect.gen(function* () { |
| 35 | const res = yield* Effect.tryPromise(() => fetch(imageUrl)); |