@@ -192,28 +192,6 @@ export default function carsResourseTemplate(resourceId: string, dataSource: Car
192192
193193
194194 *********************************************************************************/
195- // new UploadPlugin({
196- // storageAdapter: new AdminForthAdapterS3CompatibleStorage({
197- // accessKeyId: 'minioadmin',
198- // secretAccessKey: 'minioadmin',
199- // endpoint: 'http://localhost:9000',
200- // bucket: 'adminforth-dev-demo',
201- // region: 'us-east-1',
202- // s3ACL: 'private',
203- // cleanupKeyValueAdapter: levelDbAdapter,
204- // forcePathStyle: true,
205- // cleanupCheckInterval: '30m',
206- // cleanupGracePeriod: '5d'
207- // }),
208- // pathColumnName: 'photos',
209- // allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif', 'webm', 'webp'],
210- // maxFileSize: 1024 * 1024 * 20, // 20 MB
211- // filePath: ({originalFilename, originalExtension, contentType}) =>
212- // `${dataSource}/car_images/cars/${originalFilename}_${Date.now()}.${originalExtension}`,
213- // preview: {
214- // maxShowWidth: "300px",
215- // },
216- // }),
217195 new UploadPlugin ( {
218196 storageAdapter : new AdminForthAdapterS3CompatibleStorage ( {
219197 accessKeyId : 'minioadmin' ,
@@ -222,10 +200,31 @@ export default function carsResourseTemplate(resourceId: string, dataSource: Car
222200 bucket : 'adminforth-dev-demo' ,
223201 region : 'us-east-1' ,
224202 s3ACL : 'private' ,
225- // cleanupKeyValueAdapter: levelDbAdapter,
203+ cleanupKeyValueAdapter : levelDbAdapter ,
226204 forcePathStyle : true ,
227- // cleanupCheckInterval: '30m',
228- // cleanupGracePeriod: '5d'
205+ cleanupCheckInterval : '30m' ,
206+ cleanupGracePeriod : '5d'
207+ } ) ,
208+ pathColumnName : 'photos' ,
209+ allowedFileExtensions : [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'webm' , 'webp' ] ,
210+ maxFileSize : 1024 * 1024 * 20 , // 20 MB
211+ filePath : ( { originalFilename, originalExtension, contentType} ) =>
212+ `${ dataSource } /car_images/cars/${ originalFilename } _${ Date . now ( ) } .${ originalExtension } ` ,
213+ preview : {
214+ maxShowWidth : "300px" ,
215+ } ,
216+ } ) ,
217+ new UploadPlugin ( {
218+ storageAdapter : process . env . USE_S3 !== 'true' ? new AdminForthStorageAdapterLocalFilesystem ( {
219+ fileSystemFolder : "./db/uploads" ,
220+ mode : "public" , // or "private"
221+ signingSecret : '1241245' ,
222+ } ) : new AdminForthAdapterS3Storage ( {
223+ bucket : process . env . AWS_BUCKET_NAME as string ,
224+ region : process . env . AWS_REGION as string ,
225+ accessKeyId : process . env . AWS_ACCESS_KEY_ID as string ,
226+ secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY as string ,
227+ s3ACL : "public-read"
229228 } ) ,
230229 pathColumnName : 'promo_picture' ,
231230 allowedFileExtensions : [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'webm' , 'webp' ] ,
@@ -310,40 +309,40 @@ export default function carsResourseTemplate(resourceId: string, dataSource: Car
310309 *********************************************************************************/
311310 ...( process . env . OPENAI_API_KEY ?
312311 [
313- // new UploadPlugin({
314- // storageAdapter: process.env.USE_S3 !== 'true' ? new AdminForthStorageAdapterLocalFilesystem({
315- // fileSystemFolder: "./db/uploads_promo_generated",
316- // mode: "public", // or "private"
317- // signingSecret: '1241245',
318- // }) : new AdminForthAdapterS3Storage({
319- // bucket: process.env.AWS_BUCKET_NAME as string,
320- // region: process.env.AWS_REGION as string,
321- // accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
322- // secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
323- // s3ACL: "public-read"
324- // }),
312+ new UploadPlugin ( {
313+ storageAdapter : process . env . USE_S3 !== 'true' ? new AdminForthStorageAdapterLocalFilesystem ( {
314+ fileSystemFolder : "./db/uploads_promo_generated" ,
315+ mode : "public" , // or "private"
316+ signingSecret : '1241245' ,
317+ } ) : new AdminForthAdapterS3Storage ( {
318+ bucket : process . env . AWS_BUCKET_NAME as string ,
319+ region : process . env . AWS_REGION as string ,
320+ accessKeyId : process . env . AWS_ACCESS_KEY_ID as string ,
321+ secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY as string ,
322+ s3ACL : "public-read"
323+ } ) ,
325324
326- // pathColumnName: 'generated_promo_picture',
327- // allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif', 'webm', 'webp'],
328- // maxFileSize: 1024 * 1024 * 20, // 20 MB
329- // filePath: ({originalFilename, originalExtension, contentType}) =>
330- // `${dataSource}/car_images/cars_promo_images_generated/${originalFilename}_${Date.now()}.${originalExtension}`,
331- // preview: {
332- // maxShowWidth: "300px",
333- // },
334- // generation: {
335- // countToGenerate: 2,
336- // adapter: new ImageGenerationAdapterOpenAI({
337- // openAiApiKey: process.env.OPENAI_API_KEY as string,
338- // model: 'gpt-image-1',
339- // }),
340- // attachFiles: async ({ record }) => {
341- // return [`https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${record.promo_picture}`];
342- // },
343- // generationPrompt: "Generate a high-quality promotional image for a car with model {{model}} and color {{color}}. The car is a {{body_type}} type. The image should be vibrant and eye-catching, suitable for advertising purposes.",
344- // outputSize: '1536x1024'
345- // }
346- // }),
325+ pathColumnName : 'generated_promo_picture' ,
326+ allowedFileExtensions : [ 'jpg' , 'jpeg' , 'png' , 'gif' , 'webm' , 'webp' ] ,
327+ maxFileSize : 1024 * 1024 * 20 , // 20 MB
328+ filePath : ( { originalFilename, originalExtension, contentType} ) =>
329+ `${ dataSource } /car_images/cars_promo_images_generated/${ originalFilename } _${ Date . now ( ) } .${ originalExtension } ` ,
330+ preview : {
331+ maxShowWidth : "300px" ,
332+ } ,
333+ generation : {
334+ countToGenerate : 2 ,
335+ adapter : new ImageGenerationAdapterOpenAI ( {
336+ openAiApiKey : process . env . OPENAI_API_KEY as string ,
337+ model : 'gpt-image-1' ,
338+ } ) ,
339+ attachFiles : async ( { record } ) => {
340+ return [ `https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${ record . promo_picture } ` ] ;
341+ } ,
342+ generationPrompt : "Generate a high-quality promotional image for a car with model {{model}} and color {{color}}. The car is a {{body_type}} type. The image should be vibrant and eye-catching, suitable for advertising purposes." ,
343+ outputSize : '1536x1024'
344+ }
345+ } ) ,
347346 new TextCompletePlugin ( {
348347 fieldName : 'model' ,
349348 adapter : new CompletionAdapterOpenAIResponses ( {
@@ -354,76 +353,76 @@ export default function carsResourseTemplate(resourceId: string, dataSource: Car
354353 }
355354 } ) ,
356355 } ) ,
357- // new BulkAiFlowPlugin({
358- // actionName: 'Generate description and Price',
359- // askConfirmationBeforeGenerating: true,
360- // textCompleteAdapter: new CompletionAdapterOpenAIResponses({
361- // openAiApiKey: process.env.OPENAI_API_KEY as string,
362- // model: "gpt-5-mini",
363- // extraRequestBodyParameters: {
364- // temperature: 1,
365- // },
366- // }),
367- // fillPlainFields: {
368- // description: "Create a desription for the car with name {{model}} and engine type {{engine_type}}. Desription should be HTML formatted.",
369- // price: "Based on the car model {{model}} and engine type {{engine_type}}, suggest a competitive market price in USD. Return only the numeric value.",
370- // },
371- // rateLimits: { // bulk generation limits
372- // fillFieldsFromImages: "1/1m", // 1 request per minute
373- // fillPlainFields: "1/1m", // 1 request per minute
374- // generateImages: "1/1m", // 1 request per minute
375- // }
376- // }),
377- // new BulkAiFlowPlugin({
378- // actionName: 'Analyze image',
379- // askConfirmationBeforeGenerating: true,
380- // visionAdapter: new AdminForthImageVisionAdapterOpenAi({
381- // openAiApiKey: process.env.OPENAI_API_KEY as string,
382- // model: 'gpt-5-mini',
383- // }),
384- // fillFieldsFromImages: {
385- // body_type: "What is the body type of the car shown in the image?",
386- // color: "What is the color of the car shown in the image?",
387- // mileage: "Estimate the mileage of the car shown in the image in kilometers.",
388- // },
389- // attachFiles: async ({ record }) => {
390- // if (!record.promo_picture) {
391- // return [];
392- // }
393- // return [`https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${record.promo_picture}`];
394- // },
395- // rateLimits: { // bulk generation limits
396- // fillFieldsFromImages: "1/1m", // 1 request per minute
397- // fillPlainFields: "1/1m", // 1 request per minute
398- // generateImages: "1/1m", // 1 request per two minutes
399- // }
400- // }),
401- // new BulkAiFlowPlugin({
402- // actionName: 'Generate promo image',
403- // askConfirmationBeforeGenerating: true,
404- // imageGenerationAdapter: new ImageGenerationAdapterOpenAI({
405- // openAiApiKey: process.env.OPENAI_API_KEY as string,
406- // model: 'gpt-image-1',
407- // }),
408- // generateImages: {
409- // generated_promo_picture: {
410- // countToGenerate: 1,
411- // outputSize: '1536x1024',
412- // prompt: "Create a high-quality promotional image for a {{color}} car shown on attached image. Generated image should be in anime style",
413- // }
414- // },
415- // rateLimits: { // bulk generation limits
416- // fillFieldsFromImages: "1/1m", // 1 request per minute
417- // fillPlainFields: "1/1m", // 1 request per minute
418- // generateImages: "1/1m", // 1 request per minute
419- // },
420- // attachFiles: async ({ record }) => {
421- // if (!record.promo_picture) {
422- // return [];
423- // }
424- // return [`https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${record.promo_picture}`];
425- // },
426- // }),
356+ new BulkAiFlowPlugin ( {
357+ actionName : 'Generate description and Price' ,
358+ askConfirmationBeforeGenerating : true ,
359+ textCompleteAdapter : new CompletionAdapterOpenAIResponses ( {
360+ openAiApiKey : process . env . OPENAI_API_KEY as string ,
361+ model : "gpt-5-mini" ,
362+ extraRequestBodyParameters : {
363+ temperature : 1 ,
364+ } ,
365+ } ) ,
366+ fillPlainFields : {
367+ description : "Create a desription for the car with name {{model}} and engine type {{engine_type}}. Desription should be HTML formatted." ,
368+ price : "Based on the car model {{model}} and engine type {{engine_type}}, suggest a competitive market price in USD. Return only the numeric value." ,
369+ } ,
370+ rateLimits : { // bulk generation limits
371+ fillFieldsFromImages : "1/1m" , // 1 request per minute
372+ fillPlainFields : "1/1m" , // 1 request per minute
373+ generateImages : "1/1m" , // 1 request per minute
374+ }
375+ } ) ,
376+ new BulkAiFlowPlugin ( {
377+ actionName : 'Analyze image' ,
378+ askConfirmationBeforeGenerating : true ,
379+ visionAdapter : new AdminForthImageVisionAdapterOpenAi ( {
380+ openAiApiKey : process . env . OPENAI_API_KEY as string ,
381+ model : 'gpt-5-mini' ,
382+ } ) ,
383+ fillFieldsFromImages : {
384+ body_type : "What is the body type of the car shown in the image?" ,
385+ color : "What is the color of the car shown in the image?" ,
386+ mileage : "Estimate the mileage of the car shown in the image in kilometers." ,
387+ } ,
388+ attachFiles : async ( { record } ) => {
389+ if ( ! record . promo_picture ) {
390+ return [ ] ;
391+ }
392+ return [ `https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${ record . promo_picture } ` ] ;
393+ } ,
394+ rateLimits : { // bulk generation limits
395+ fillFieldsFromImages : "1/1m" , // 1 request per minute
396+ fillPlainFields : "1/1m" , // 1 request per minute
397+ generateImages : "1/1m" , // 1 request per two minutes
398+ }
399+ } ) ,
400+ new BulkAiFlowPlugin ( {
401+ actionName : 'Generate promo image' ,
402+ askConfirmationBeforeGenerating : true ,
403+ imageGenerationAdapter : new ImageGenerationAdapterOpenAI ( {
404+ openAiApiKey : process . env . OPENAI_API_KEY as string ,
405+ model : 'gpt-image-1' ,
406+ } ) ,
407+ generateImages : {
408+ generated_promo_picture : {
409+ countToGenerate : 1 ,
410+ outputSize : '1536x1024' ,
411+ prompt : "Create a high-quality promotional image for a {{color}} car shown on attached image. Generated image should be in anime style" ,
412+ }
413+ } ,
414+ rateLimits : { // bulk generation limits
415+ fillFieldsFromImages : "1/1m" , // 1 request per minute
416+ fillPlainFields : "1/1m" , // 1 request per minute
417+ generateImages : "1/1m" , // 1 request per minute
418+ } ,
419+ attachFiles : async ( { record } ) => {
420+ if ( ! record . promo_picture ) {
421+ return [ ] ;
422+ }
423+ return [ `https://tmpbucket-adminforth.s3.eu-central-1.amazonaws.com/${ record . promo_picture } ` ] ;
424+ } ,
425+ } ) ,
427426 ] : [ ] ) ,
428427 ] ,
429428
0 commit comments