From 9b4c554cca11f5c3105085b54646e684dd235f1d Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Wed, 18 Dec 2024 20:46:27 -0500 Subject: image creation works but is weird --- src/server/ApiManagers/AssistantManager.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'src/server/ApiManagers') diff --git a/src/server/ApiManagers/AssistantManager.ts b/src/server/ApiManagers/AssistantManager.ts index 83bb1b228..425365348 100644 --- a/src/server/ApiManagers/AssistantManager.ts +++ b/src/server/ApiManagers/AssistantManager.ts @@ -426,30 +426,12 @@ export default class AssistantManager extends ApiManager { } try { - const image = await openai.images.generate({ model: 'dall-e-3', prompt: image_prompt, response_format: 'b64_json' }); + const image = await openai.images.generate({ model: 'dall-e-3', prompt: image_prompt, response_format: 'url' }); console.log(image); - const base64String = image.data[0].b64_json; - if (!base64String) { - throw new Error('No base64 data received from image generation'); - } - // Generate a UUID for the file to ensure unique naming - const uuidv4 = uuid.v4(); - const fullFilename = `${uuidv4}.jpg`; // Prefix the file name with the UUID - - // Get the full server path where the file will be saved - const serverFilePath = serverPathToFile(Directory.images, fullFilename); - - const binaryData = Buffer.from(base64String, 'base64'); + const url = image.data[0].url; - // Write the CSV data (which is a raw string) to the file - await writeFileAsync(serverFilePath, binaryData); - - // Construct the client-accessible URL for the file - const fileUrl = clientPathToFile(Directory.images, fullFilename); - - // Send the file URL and UUID back to the client - res.send({ base64_data: base64String, image_path: fileUrl }); + res.send({ url }); } catch (error) { console.error('Error fetching the URL:', error); res.status(500).send({ -- cgit v1.2.3-70-g09d2