会话记忆
This commit is contained in:
parent
8536e6932e
commit
92c0344365
@ -1,6 +1,8 @@
|
||||
package com.huangge1199.ai.config;
|
||||
|
||||
import com.huangge1199.ai.service.LangChainService;
|
||||
import dev.langchain4j.memory.ChatMemory;
|
||||
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
|
||||
import dev.langchain4j.model.chat.ChatModel;
|
||||
import dev.langchain4j.service.AiServices;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -21,6 +23,10 @@ public class LangChainConfig {
|
||||
|
||||
@Bean
|
||||
public LangChainService langChainService() {
|
||||
return AiServices.create(LangChainService.class, qwenChatModel);
|
||||
ChatMemory chatMemory = MessageWindowChatMemory.withMaxMessages(10);
|
||||
return AiServices.builder(LangChainService.class)
|
||||
.chatModel(qwenChatModel)
|
||||
.chatMemory(chatMemory)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user