diff options
Diffstat (limited to 'src/server/ApiManagers/AssistantManager.ts')
-rw-r--r-- | src/server/ApiManagers/AssistantManager.ts | 24 |
1 files changed, 3 insertions, 21 deletions
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({ |