aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/AssistantManager.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-12-18 20:46:27 -0500
committerA.J. Shulman <Shulman.aj@gmail.com>2024-12-18 20:46:27 -0500
commit9b4c554cca11f5c3105085b54646e684dd235f1d (patch)
treeaa8e9b54dad2e13e33702bcb6072ad5fc89fe600 /src/server/ApiManagers/AssistantManager.ts
parent57e3c9b9977228a561e8972a469a67f17f4bcd9c (diff)
image creation works but is weird
Diffstat (limited to 'src/server/ApiManagers/AssistantManager.ts')
-rw-r--r--src/server/ApiManagers/AssistantManager.ts24
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({