From 150506603ab5fc923002f5bfd898ca96dfb7191c Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Mon, 11 Nov 2024 11:16:10 +0100 Subject: [PATCH 1/3] LangChain4j: refactoring with lowercase letter j --- ...Service.java => LangChain4jApplicationService.java} | 10 +++++----- ...oduleFactory.java => LangChain4jModuleFactory.java} | 2 +- ...ration.java => LangChain4jModuleConfiguration.java} | 10 +++++----- ...toryTest.java => LangChain4jModuleFactoryTest.java} | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) rename src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/{LangChain4JApplicationService.java => LangChain4jApplicationService.java} (68%) rename src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/{LangChain4JModuleFactory.java => LangChain4jModuleFactory.java} (98%) rename src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/{LangChain4JModuleConfiguration.java => LangChain4jModuleConfiguration.java} (79%) rename src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/{LangChain4JModuleFactoryTest.java => LangChain4jModuleFactoryTest.java} (96%) diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4JApplicationService.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4jApplicationService.java similarity index 68% rename from src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4JApplicationService.java rename to src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4jApplicationService.java index 2dfcfdf8009..1576bb54e8c 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4JApplicationService.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/application/LangChain4jApplicationService.java @@ -1,17 +1,17 @@ package tech.jhipster.lite.generator.server.springboot.langchain4j.application; import org.springframework.stereotype.Service; -import tech.jhipster.lite.generator.server.springboot.langchain4j.domain.LangChain4JModuleFactory; +import tech.jhipster.lite.generator.server.springboot.langchain4j.domain.LangChain4jModuleFactory; import tech.jhipster.lite.module.domain.JHipsterModule; import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; @Service -public class LangChain4JApplicationService { +public class LangChain4jApplicationService { - private final LangChain4JModuleFactory factory; + private final LangChain4jModuleFactory factory; - public LangChain4JApplicationService() { - factory = new LangChain4JModuleFactory(); + public LangChain4jApplicationService() { + factory = new LangChain4jModuleFactory(); } public JHipsterModule buildModule(JHipsterModuleProperties properties) { diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java similarity index 98% rename from src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactory.java rename to src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java index 9465f047371..3ea2bc8c46c 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java @@ -11,7 +11,7 @@ import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; import tech.jhipster.lite.shared.error.domain.Assert; -public class LangChain4JModuleFactory { +public class LangChain4jModuleFactory { private static final String API_KEY_DEMO_COMMENT = "You can temporarily use 'demo' key, which is provided for free for demonstration purposes"; diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4JModuleConfiguration.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4jModuleConfiguration.java similarity index 79% rename from src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4JModuleConfiguration.java rename to src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4jModuleConfiguration.java index b9a427a5837..870e2f54041 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4JModuleConfiguration.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/infrastructure/primary/LangChain4jModuleConfiguration.java @@ -5,22 +5,22 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import tech.jhipster.lite.generator.server.springboot.langchain4j.application.LangChain4JApplicationService; +import tech.jhipster.lite.generator.server.springboot.langchain4j.application.LangChain4jApplicationService; import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; @Configuration -class LangChain4JModuleConfiguration { +class LangChain4jModuleConfiguration { @Bean - JHipsterModuleResource langChain4JModule(LangChain4JApplicationService langChain4J) { + JHipsterModuleResource langChain4jModule(LangChain4jApplicationService langChain4j) { return JHipsterModuleResource.builder() .slug(LANGCHAIN4J) .propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addProjectBaseName().addIndentation().build()) - .apiDoc("LangChain4J", "Add LangChain4j") + .apiDoc("LangChain4j", "Add LangChain4j") .organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT).build()) .tags("server", "spring", "spring-boot", "langchain4j") - .factory(langChain4J::buildModule); + .factory(langChain4j::buildModule); } } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java similarity index 96% rename from src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactoryTest.java rename to src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java index 15e4afb3c67..3428f3a82ff 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4JModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java @@ -15,10 +15,10 @@ @UnitTest @ExtendWith(MockitoExtension.class) -class LangChain4JModuleFactoryTest { +class LangChain4jModuleFactoryTest { @InjectMocks - private LangChain4JModuleFactory factory; + private LangChain4jModuleFactory factory; @Test void shouldCreateModule() { From ab656b59de17ea82fcce42e49ac1118bfad9f25f Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Mon, 11 Nov 2024 11:31:26 +0100 Subject: [PATCH 2/3] LangChain4j: rename documentation --- .../springboot/langchain4j/domain/LangChain4jModuleFactory.java | 2 +- .../langchain4j/domain/LangChain4jModuleFactoryTest.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java index 3ea2bc8c46c..d4eb851560d 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java @@ -30,7 +30,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { //@formatter:off return moduleBuilder(properties) - .documentation(documentationTitle("Dev tools"), SOURCE.template("langchain4j.md")) + .documentation(documentationTitle("LangChain4j"), SOURCE.template("langchain4j.md")) .javaDependencies() .addDependency(GROUP_ID, ARTIFACT_ID, VERSION_SLUG) .addDependency(GROUP_ID, OPEN_AI_ARTIFACT_ID, VERSION_SLUG) diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java index 3428f3a82ff..77d40161737 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java @@ -29,6 +29,7 @@ void shouldCreateModule() { JHipsterModule module = factory.buildModule(properties); assertThatModuleWithFiles(module, pomFile()) + .hasFiles("documentation/langchain4j.md") .hasFile("pom.xml") .containing("") .containing( From 8b849edbb8e926a31b9581e7bf111985d857783c Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Mon, 11 Nov 2024 11:36:32 +0100 Subject: [PATCH 3/3] LangChain4j: use demo for api-key value --- .../springboot/langchain4j/domain/LangChain4jModuleFactory.java | 2 +- .../langchain4j/domain/LangChain4jModuleFactoryTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java index d4eb851560d..09dbe3d6efa 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java @@ -36,7 +36,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) { .addDependency(GROUP_ID, OPEN_AI_ARTIFACT_ID, VERSION_SLUG) .and() .springMainProperties() - .set(LANGCHAIN4J_PROPERTY_API_KEY, propertyValue("${OPENAI_API_KEY}")) + .set(LANGCHAIN4J_PROPERTY_API_KEY, propertyValue("demo")) .comment(LANGCHAIN4J_PROPERTY_API_KEY, comment(API_KEY_DEMO_COMMENT)) .set(propertyKey("langchain4j.open-ai.chat-model.model-name"), propertyValue("gpt-4o-mini")) .set(propertyKey("langchain4j.open-ai.chat-model.log-requests"), propertyValue("true")) diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java index 77d40161737..b4d83f5ce08 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactoryTest.java @@ -58,7 +58,7 @@ void shouldCreateModule() { open-ai: chat-model: # You can temporarily use 'demo' key, which is provided for free for demonstration purposes - api-key: ${OPENAI_API_KEY} + api-key: demo log-requests: 'true' log-responses: 'true' model-name: gpt-4o-mini