diff --git a/api/pom.xml b/api/pom.xml
index d24fbcb6..c8f1436c 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -45,18 +45,7 @@
spring-boot-starter-security
-
- dev.langchain4j
- langchain4j
- 0.25.0
-
-
-
- dev.langchain4j
- langchain4j-open-ai-spring-boot-starter
- 0.25.0
-
-
+
org.springframework.boot
spring-boot-starter-actuator
diff --git a/api/src/main/java/org/open4goods/api/config/ApiConfig.java b/api/src/main/java/org/open4goods/api/config/ApiConfig.java
index 8e2226e9..1d8be6eb 100644
--- a/api/src/main/java/org/open4goods/api/config/ApiConfig.java
+++ b/api/src/main/java/org/open4goods/api/config/ApiConfig.java
@@ -12,8 +12,6 @@
import org.open4goods.api.services.RealtimeAggregationService;
import org.open4goods.api.services.ReferentielService;
import org.open4goods.api.services.aggregation.services.batch.AiCompletionAggregationService;
-import org.open4goods.api.services.ai.AiService;
-import org.open4goods.api.services.ai.NudgerAgent;
import org.open4goods.api.services.store.DataFragmentStoreService;
import org.open4goods.crawler.config.yml.FetcherProperties;
import org.open4goods.crawler.repository.CsvIndexationRepository;
@@ -45,6 +43,8 @@
import org.open4goods.services.SerialisationService;
import org.open4goods.services.StandardiserService;
import org.open4goods.services.VerticalsConfigService;
+import org.open4goods.services.ai.AiService;
+import org.open4goods.services.ai.NudgerAgent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.customizers.OpenApiCustomizer;
diff --git a/api/src/main/java/org/open4goods/api/controller/api/ProductController.java b/api/src/main/java/org/open4goods/api/controller/api/ProductController.java
index 3e25921c..b7384451 100644
--- a/api/src/main/java/org/open4goods/api/controller/api/ProductController.java
+++ b/api/src/main/java/org/open4goods/api/controller/api/ProductController.java
@@ -4,12 +4,12 @@
import java.util.Map;
-import org.open4goods.api.services.ai.AiService;
import org.open4goods.dao.ProductRepository;
import org.open4goods.exceptions.ResourceNotFoundException;
import org.open4goods.model.constants.RolesConstants;
import org.open4goods.model.data.AiDescription;
import org.open4goods.model.product.Product;
+import org.open4goods.services.ai.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
diff --git a/api/src/main/java/org/open4goods/api/services/aggregation/services/batch/AiCompletionAggregationService.java b/api/src/main/java/org/open4goods/api/services/aggregation/services/batch/AiCompletionAggregationService.java
index f05bbc5b..b9910489 100644
--- a/api/src/main/java/org/open4goods/api/services/aggregation/services/batch/AiCompletionAggregationService.java
+++ b/api/src/main/java/org/open4goods/api/services/aggregation/services/batch/AiCompletionAggregationService.java
@@ -4,13 +4,13 @@
import java.util.Map.Entry;
import org.open4goods.api.services.aggregation.AbstractBatchAggregationService;
-import org.open4goods.api.services.ai.AiService;
import org.open4goods.config.yml.attributes.AiConfig;
import org.open4goods.config.yml.ui.VerticalConfig;
import org.open4goods.model.data.AiDescription;
import org.open4goods.model.product.Product;
import org.open4goods.services.EvaluationService;
import org.open4goods.services.VerticalsConfigService;
+import org.open4goods.services.ai.AiService;
/**
* Service in charge of mapping product categories to verticals
diff --git a/commons/pom.xml b/commons/pom.xml
index 6063b621..b2b620f6 100644
--- a/commons/pom.xml
+++ b/commons/pom.xml
@@ -46,13 +46,13 @@
- org.thymeleaf
- thymeleaf-spring6
+ org.thymeleaf
+ thymeleaf-spring6
-
+
- org.springframework.boot
- spring-boot-starter-data-redis
+ org.springframework.boot
+ spring-boot-starter-data-redis
@@ -79,6 +79,19 @@
1.8.0
+
+ dev.langchain4j
+ langchain4j
+ 0.25.0
+
+
+
+ dev.langchain4j
+ langchain4j-open-ai-spring-boot-starter
+ 0.25.0
+
+
+
jakarta.mail
jakarta.mail-api
diff --git a/api/src/main/java/org/open4goods/api/services/ai/AiService.java b/commons/src/main/java/org/open4goods/services/ai/AiService.java
similarity index 98%
rename from api/src/main/java/org/open4goods/api/services/ai/AiService.java
rename to commons/src/main/java/org/open4goods/services/ai/AiService.java
index 348bca52..30be8ccc 100644
--- a/api/src/main/java/org/open4goods/api/services/ai/AiService.java
+++ b/commons/src/main/java/org/open4goods/services/ai/AiService.java
@@ -1,4 +1,4 @@
-package org.open4goods.api.services.ai;
+package org.open4goods.services.ai;
import java.util.ArrayList;
diff --git a/api/src/main/java/org/open4goods/api/services/ai/NudgerAgent.java b/commons/src/main/java/org/open4goods/services/ai/NudgerAgent.java
similarity index 86%
rename from api/src/main/java/org/open4goods/api/services/ai/NudgerAgent.java
rename to commons/src/main/java/org/open4goods/services/ai/NudgerAgent.java
index cdd65c63..0bc40724 100644
--- a/api/src/main/java/org/open4goods/api/services/ai/NudgerAgent.java
+++ b/commons/src/main/java/org/open4goods/services/ai/NudgerAgent.java
@@ -1,4 +1,4 @@
-package org.open4goods.api.services.ai;
+package org.open4goods.services.ai;
import dev.langchain4j.service.SystemMessage;
diff --git a/ui/src/main/java/org/open4goods/ui/config/AppConfig.java b/ui/src/main/java/org/open4goods/ui/config/AppConfig.java
index f58214fb..d4c68a15 100644
--- a/ui/src/main/java/org/open4goods/ui/config/AppConfig.java
+++ b/ui/src/main/java/org/open4goods/ui/config/AppConfig.java
@@ -23,6 +23,8 @@
import org.open4goods.services.StandardiserService;
import org.open4goods.services.VerticalsConfigService;
import org.open4goods.services.XwikiService;
+import org.open4goods.services.ai.AiService;
+import org.open4goods.services.ai.NudgerAgent;
import org.open4goods.ui.config.yml.UiConfig;
import org.open4goods.ui.services.GtinService;
import org.open4goods.ui.services.ImageService;
@@ -51,6 +53,13 @@
@Configuration
public class AppConfig {
+
+ @Bean
+ @Autowired
+ AiService aiService (NudgerAgent nudgerAgent, VerticalsConfigService verticalService, EvaluationService spelEvaluationService) {
+ return new AiService(nudgerAgent, verticalService, spelEvaluationService);
+ }
+
// TODO : Cache period pageNumber conf
public static final int CACHE_PERIOD_SECONDS = 3600*24*7;
private final UiConfig config;