Modification of existing services to use Spring AI instead of Langchain.
Create and implement an image generation service using Spring AI.
Summary of Changes
AiService: Updated service and related files to use Spring AI instead of Langchain.
ImageGenerationService: Service to generate images using the OpenAI API and save them to a specified folder.
Configuration Files: Configuration for the image generation service in application.yml.
UI Config: Updated to include the destination folder for generated images and the image generation configuration.
App Config: Added bean ImageGenerationService and modified VerticalsConfigService bean.
VerticalsConfigService: Updated to include the image generation functionality, loading configurations from both classpath and folders, and generating images for each vertical.
Resource Controller: Implemented an endpoint to serve the generated images for each vertical.
Admin Controller: Added an endpoint to regenerate images for specific verticals.
Frontend (index.html): Integrated the generated images into the frontend, providing a way to change images via an admin button.
Detailed Changes
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.
ImageGenerationConfig.java:
Configuration class to hold properties like prompt template and force override flag.
application.yml:
Added configuration for imageGenerationConfig with prompt template and forceOverride flag.
UiConfig.java:
Added properties for generated images folder and image generation configuration.
AppConfig.java:
Defined beans for ImageGenerationService and modified existing beans to integrate image generation capabilities.
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.
ResourceController.java:
Added endpoint to serve images for specific verticals.
AdminController.java:
Added endpoint to allow administrators to manually regenerate images for verticals if needed.
index.html:
Integrated generated images into the vertical cards and added a button to manually regenerate images (admin control needed).
Additional Notes
The image generation prompt in the configuration ensures a consistent style for all generated images.
The system checks if an image already exists to avoid unnecessary regenerations unless forceOverride is enabled.
Issue Reference
This PR addresses issue #304.
Objective
Summary of Changes
application.yml
.ImageGenerationService
and modifiedVerticalsConfigService
bean.Detailed Changes
ImageGenerationService.java:
ImageGenerationConfig.java:
application.yml:
imageGenerationConfig
with prompt template and forceOverride flag.UiConfig.java:
AppConfig.java:
ImageGenerationService
and modified existing beans to integrate image generation capabilities.VerticalsConfigService.java:
ResourceController.java:
AdminController.java:
index.html:
Additional Notes