Skip to content

Commit

Permalink
Moving gen ai to commons
Browse files Browse the repository at this point in the history
  • Loading branch information
goulven authored and goulven committed Dec 27, 2023
1 parent a6cf430 commit b5a5673
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
13 changes: 1 addition & 12 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,7 @@
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>0.25.0</version>
</dependency>

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
<version>0.25.0</version>
</dependency>


<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions api/src/main/java/org/open4goods/api/config/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 18 additions & 5 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@


<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring6</artifactId>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring6</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

<dependency>
Expand All @@ -79,6 +79,19 @@
<version>1.8.0</version>
</dependency>

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>0.25.0</version>
</dependency>

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-open-ai-spring-boot-starter</artifactId>
<version>0.25.0</version>
</dependency>


<dependency>
<groupId>jakarta.mail</groupId>
<artifactId>jakarta.mail-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.open4goods.api.services.ai;
package org.open4goods.services.ai;


import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.open4goods.api.services.ai;
package org.open4goods.services.ai;

import dev.langchain4j.service.SystemMessage;

Expand Down
9 changes: 9 additions & 0 deletions ui/src/main/java/org/open4goods/ui/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b5a5673

Please sign in to comment.