AI智能工牌的建表语句
This commit is contained in:
68
src/main/java/com/rj/config/CommonConfig.java
Normal file
68
src/main/java/com/rj/config/CommonConfig.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.rj.config;
|
||||
|
||||
import com.rj.aiservice.CstAIService;
|
||||
import com.rj.repository.RedisChatMemoryStore;
|
||||
import dev.langchain4j.memory.ChatMemory;
|
||||
import dev.langchain4j.memory.chat.ChatMemoryProvider;
|
||||
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
|
||||
import dev.langchain4j.model.openai.OpenAiChatModel;
|
||||
import dev.langchain4j.service.AiServices;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Author: 李中华 wx: spllzh email(qq): 28668817@qq.com
|
||||
* Date: 2025/8/4 10:24
|
||||
**/
|
||||
@Configuration
|
||||
public class CommonConfig {
|
||||
|
||||
@Autowired
|
||||
private OpenAiChatModel openAiChatModel;
|
||||
|
||||
// @Bean
|
||||
public CstAIService cstAIService() {
|
||||
|
||||
CstAIService cstAIService = AiServices.builder(CstAIService.class)
|
||||
.chatModel(openAiChatModel)
|
||||
.build();
|
||||
|
||||
return cstAIService;
|
||||
}
|
||||
@Bean
|
||||
public ChatMemory chatMemory() {
|
||||
|
||||
MessageWindowChatMemory build = MessageWindowChatMemory.builder()
|
||||
.maxMessages(10)
|
||||
.build();
|
||||
return build;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
RedisChatMemoryStore redisChatMemoryStore;
|
||||
|
||||
|
||||
|
||||
@Bean
|
||||
public ChatMemoryProvider chatMemoryProvider() {
|
||||
|
||||
ChatMemoryProvider chatMemoryProvider = new ChatMemoryProvider() {
|
||||
@Override
|
||||
public ChatMemory get(Object memoryId) {
|
||||
|
||||
MessageWindowChatMemory chatMemory = MessageWindowChatMemory.builder()
|
||||
.id(memoryId)
|
||||
.maxMessages(10)
|
||||
.chatMemoryStore(redisChatMemoryStore)
|
||||
.build();
|
||||
return chatMemory;
|
||||
}
|
||||
};
|
||||
|
||||
return chatMemoryProvider;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user