open4good / open4goods

The open4goods project
Other
16 stars 10 forks source link

Verticals Images Generation - AI #376

Closed scezen closed 2 months ago

scezen commented 2 months ago

Issue Reference

This PR addresses issue #304.

Objective

  1. Modification of existing services to use Spring AI instead of Langchain.
  2. Create and implement an image generation service using Spring AI.

Summary of Changes

Detailed Changes

  1. ImageGenerationService.java:

    • Implements methods to generate images using the OpenAI API and save them locally.
    • Contains utility functions to check if an image should be generated, generate prompts, and manage the images folder.
  2. ImageGenerationConfig.java:

    • Configuration class to hold properties like prompt template and force override flag.
  3. application.yml:

    • Added configuration for imageGenerationConfig with prompt template and forceOverride flag.
  4. UiConfig.java:

    • Added properties for generated images folder and image generation configuration.
  5. AppConfig.java:

    • Defined beans for ImageGenerationService and modified existing beans to integrate image generation capabilities.
  6. VerticalsConfigService.java:

    • Modified to load vertical configurations and initiate image generation tasks for each vertical.
    • Multi-threading using ExecutorService to manage background image generation.
    • Added methods to map configurations, handle URLs, and manage the lifecycle of the image generation process.
  7. ResourceController.java:

    • Added endpoint to serve images for specific verticals.
  8. AdminController.java:

    • Added endpoint to allow administrators to manually regenerate images for verticals if needed.
  9. index.html:

    • Integrated generated images into the vertical cards and added a button to manually regenerate images (admin control needed).

Additional Notes

GoulvenF commented 2 months ago

Thanks @scezen for this great PR ! After reviewing, code and documentation is excellent. I merge, we'll have it on nudger.fr next week.