Skip to content

Commit

Permalink
Add an example of use
Browse files Browse the repository at this point in the history
  • Loading branch information
anunnakian committed Nov 6, 2024
1 parent 5905e7f commit c031693
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import tech.jhipster.lite.module.domain.JHipsterModule;
import tech.jhipster.lite.module.domain.file.JHipsterSource;
import tech.jhipster.lite.module.domain.javabuild.ArtifactId;
import tech.jhipster.lite.module.domain.javabuild.GroupId;
import tech.jhipster.lite.module.domain.javabuild.VersionSlug;
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties;
Expand All @@ -12,8 +13,10 @@
public class LangChain4JModuleFactory {

private static final JHipsterSource SOURCE = from("server/springboot/langchain4j");
private static final GroupId LANGCHAIN4J_GROUP_ID = groupId("dev.langchain4j");
private static final VersionSlug LANGCHAIN4J_VERSION_SLUG = versionSlug("langchain4j");
private static final GroupId GROUP_ID = groupId("dev.langchain4j");
private static final ArtifactId ARTIFACT_ID = artifactId("langchain4j-spring-boot-starter");
private static final ArtifactId OPEN_AI_ARTIFACT_ID = artifactId("langchain4j-open-ai-spring-boot-starter");
private static final VersionSlug VERSION_SLUG = versionSlug("langchain4j");

private static final String PROPERTIES = "properties";

Expand All @@ -24,21 +27,15 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return moduleBuilder(properties)
.documentation(documentationTitle("Dev tools"), SOURCE.template("langchain4j.md"))
.javaDependencies()
.addDependency(LANGCHAIN4J_GROUP_ID,
artifactId("langchain4j-spring-boot-starter"),
LANGCHAIN4J_VERSION_SLUG)
.addDependency(LANGCHAIN4J_GROUP_ID,
artifactId("langchain4j-open-ai-spring-boot-starter"),
LANGCHAIN4J_VERSION_SLUG)
.and()
.files()
.and()
.addDependency(GROUP_ID, ARTIFACT_ID, VERSION_SLUG)
.addDependency(GROUP_ID, OPEN_AI_ARTIFACT_ID, VERSION_SLUG)
.and()
.springMainProperties()
.set(propertyKey("langchain4j.open-ai.chat-model.api-key"), propertyValue("${OPENAI_API_KEY}"))
.set(propertyKey("langchain4j.open-ai.chat-model.model-name"), propertyValue("gpt-4o-mini"))
.set(propertyKey("langchain4j.open-ai.chat-model.log-requests"), propertyValue("true"))
.set(propertyKey("langchain4j.open-ai.chat-model.log-responses"), propertyValue("true"))
.and()
.set(propertyKey("langchain4j.open-ai.chat-model.api-key"), propertyValue("${OPENAI_API_KEY}"))
.set(propertyKey("langchain4j.open-ai.chat-model.model-name"), propertyValue("gpt-4o-mini"))
.set(propertyKey("langchain4j.open-ai.chat-model.log-requests"), propertyValue("true"))
.set(propertyKey("langchain4j.open-ai.chat-model.log-responses"), propertyValue("true"))
.and()
.build();
//@formatter:on
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JHipsterModuleResource langChain4JModule(LangChain4JApplicationService langChain
return JHipsterModuleResource.builder()
.slug(LANGCHAIN4J)
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addProjectBaseName().addIndentation().build())
.apiDoc("LangChain4J", "Add LangChain4J Spring dependency")
.apiDoc("LangChain4J", "Add LangChain4j")
.organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT).build())
.tags("server", "spring", "spring-boot", "langchain4j")
.factory(langChain4J::buildModule);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# LangChain4J
# LangChain4j

How to use it :
How to use it:

[Official documentation](https://docs.langchain4j.dev/tutorials/spring-boot-integration/)
4 changes: 2 additions & 2 deletions src/test/features/server/springboot/langchain4j.feature
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Feature: LangChain4J module
Feature: LangChain4j module

Scenario: Should add Spring Boot LangChain4J Starter
Scenario: Should add Spring Boot LangChain4j Starter
When I apply modules to default project
| maven-java |
| spring-boot |
Expand Down

0 comments on commit c031693

Please sign in to comment.