-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de3ae98
commit fb53f99
Showing
8 changed files
with
109 additions
and
36 deletions.
There are no files selected for viewing
34 changes: 0 additions & 34 deletions
34
...sample/jpapersistence/infrastructure/primary/SampleJpaPersistenceModuleConfiguration.java
This file was deleted.
Oops, something went wrong.
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); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...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,34 @@ | ||
package tech.jhipster.lite.generator.server.springboot.mvc.sample.langchain4j.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.from; | ||
import static tech.jhipster.lite.module.domain.JHipsterModule.moduleBuilder; | ||
import static tech.jhipster.lite.module.domain.JHipsterModule.toSrcMainJava; | ||
|
||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
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 JHipsterSource SOURCE = from("server/springboot/mvc/sample/langchain4j"); | ||
|
||
private static final String SECONDARY = "infrastructure/secondary"; | ||
private static final String SECONDARY_DESTINATION = "sample/" + SECONDARY; | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
|
||
String packagePath = properties.packagePath(); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.files() | ||
.batch(SOURCE.append("main").append(SECONDARY), toSrcMainJava().append(packagePath).append(SECONDARY_DESTINATION)) | ||
.addTemplate("ChatController.java.mustache") | ||
.and() | ||
.and() | ||
.build(); | ||
//@formatter:on | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...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,29 @@ | ||
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.generator.server.springboot.mvc.sample.langchain4j.domain.SampleLangChain4jModuleFactory; | ||
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
21 changes: 21 additions & 0 deletions
21
...ingboot/mvc/sample/langchain4j/main/infrastructure/secondary/ChatController.java.mustache
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,21 @@ | ||
package {{packageName}}.sample.infrastructure.secondary; | ||
|
||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class ChatController { | ||
ChatLanguageModel chatLanguageModel; | ||
public ChatController(ChatLanguageModel chatLanguageModel) { | ||
this.chatLanguageModel = chatLanguageModel; | ||
} | ||
|
||
@GetMapping("/chat") | ||
public String model(@RequestParam(value = "message", defaultValue = "Hello") String message) { | ||
return chatLanguageModel.generate(message); | ||
} | ||
} |
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