AI智能工牌的建表语句

This commit is contained in:
spllzh
2025-08-07 22:31:05 +08:00
parent 6dfe402eed
commit 58a131e3c8
26 changed files with 817 additions and 42 deletions

View 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;
}
}