-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'jhipster:main' into main
- Loading branch information
Showing
99 changed files
with
937 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...te/generator/server/springboot/langchain4j/application/LangChain4jApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
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.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class LangChain4jApplicationService { | ||
|
||
private final LangChain4jModuleFactory factory; | ||
|
||
public LangChain4jApplicationService() { | ||
factory = new LangChain4jModuleFactory(); | ||
} | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...hipster/lite/generator/server/springboot/langchain4j/domain/LangChain4jModuleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package tech.jhipster.lite.generator.server.springboot.langchain4j.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
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.javaproperties.PropertyKey; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
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"; | ||
|
||
private static final JHipsterSource SOURCE = from("server/springboot/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"; | ||
private static final PropertyKey LANGCHAIN4J_PROPERTY_API_KEY = propertyKey("langchain4j.open-ai.chat-model.api-key"); | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull(PROPERTIES, properties); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.documentation(documentationTitle("LangChain4j"), SOURCE.template("langchain4j.md")) | ||
.javaDependencies() | ||
.addDependency(GROUP_ID, ARTIFACT_ID, VERSION_SLUG) | ||
.addDependency(GROUP_ID, OPEN_AI_ARTIFACT_ID, VERSION_SLUG) | ||
.and() | ||
.springMainProperties() | ||
.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")) | ||
.set(propertyKey("langchain4j.open-ai.chat-model.log-responses"), propertyValue("true")) | ||
.and() | ||
.springTestProperties() | ||
.set(LANGCHAIN4J_PROPERTY_API_KEY, propertyValue("jhipster")) | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
.../server/springboot/langchain4j/infrastructure/primary/LangChain4jModuleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tech.jhipster.lite.generator.server.springboot.langchain4j.infrastructure.primary; | ||
|
||
import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.LANGCHAIN4J; | ||
import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.SPRING_BOOT; | ||
|
||
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.module.domain.resource.JHipsterModuleOrganization; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModulePropertiesDefinition; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; | ||
|
||
@Configuration | ||
class LangChain4jModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource langChain4jModule(LangChain4jApplicationService langChain4j) { | ||
return JHipsterModuleResource.builder() | ||
.slug(LANGCHAIN4J) | ||
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addProjectBaseName().addIndentation().build()) | ||
.apiDoc("LangChain4j", "Add LangChain4j") | ||
.organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT).build()) | ||
.tags("server", "spring", "spring-boot", "langchain4j") | ||
.factory(langChain4j::buildModule); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
src/main/java/tech/jhipster/lite/generator/server/springboot/langchain4j/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.generator.server.springboot.langchain4j; |
20 changes: 20 additions & 0 deletions
20
...er/springboot/mvc/sample/langchain4j/application/SampleLangChain4jApplicationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.domain.SampleLangChain4jModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class SampleLangChain4jApplicationService { | ||
|
||
private final SampleLangChain4jModuleFactory factory; | ||
|
||
public SampleLangChain4jApplicationService() { | ||
factory = new SampleLangChain4jModuleFactory(); | ||
} | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...rator/server/springboot/mvc/sample/langchain4j/domain/SampleLangChain4jModuleFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.file.JHipsterDestination; | ||
import tech.jhipster.lite.module.domain.file.JHipsterSource; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public class SampleLangChain4jModuleFactory { | ||
|
||
private static final String SAMPLE = "sample"; | ||
|
||
private static final JHipsterSource SOURCE = from("server/springboot/mvc/sample/langchain4j"); | ||
|
||
private static final String PRIMARY = "infrastructure/primary"; | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
String packagePath = properties.packagePath(); | ||
JHipsterDestination mainDestination = toSrcMainJava().append(packagePath).append(SAMPLE); | ||
JHipsterDestination testDestination = toSrcTestJava().append(packagePath).append(SAMPLE); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.files() | ||
.batch(SOURCE.append("main").append(PRIMARY), mainDestination.append(PRIMARY)) | ||
.addTemplate("ChatResource.java") | ||
.and() | ||
.batch(SOURCE.append("test").append(SAMPLE).append(PRIMARY), testDestination.append(PRIMARY)) | ||
.addTemplate("ChatResourceTest.java") | ||
.and() | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...t/mvc/sample/langchain4j/infrastructure/primary/SampleLangChain4jModuleConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.infrastructure.primary; | ||
|
||
import static tech.jhipster.lite.shared.slug.domain.JHLiteFeatureSlug.SPRING_MVC_SERVER; | ||
import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.*; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.application.SampleLangChain4jApplicationService; | ||
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 SampleLangChain4jModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource langChain4jResourceInit(SampleLangChain4jApplicationService applicationService) { | ||
return JHipsterModuleResource.builder() | ||
.slug(SPRING_BOOT_LANGCHAIN4J_SAMPLE) | ||
.propertiesDefinition( | ||
JHipsterModulePropertiesDefinition.builder().addBasePackage().addIndentation().addSpringConfigurationFormat().build() | ||
) | ||
.apiDoc("Spring Boot - LangChain4j", "Add LangChain4j sample") | ||
.organization(JHipsterModuleOrganization.builder().addDependency(SPRING_MVC_SERVER).addDependency(LANGCHAIN4J).build()) | ||
.tags("spring-boot", "spring", "server", "langchain4j") | ||
.factory(applicationService::buildModule); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
...a/tech/jhipster/lite/generator/server/springboot/mvc/sample/langchain4j/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
/** | ||
* <p> | ||
* Read version for an npm dependency | ||
* Read version for a npm dependency | ||
* </p> | ||
* | ||
* <p> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.