28 lines
916 B
Java
28 lines
916 B
Java
|
package com.ai.config;
|
||
|
|
||
|
import com.ai.service.Assist;
|
||
|
import dev.langchain4j.community.model.dashscope.QwenChatModel;
|
||
|
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
|
||
|
import dev.langchain4j.model.chat.ChatLanguageModel;
|
||
|
import dev.langchain4j.service.AiServices;
|
||
|
import lombok.RequiredArgsConstructor;
|
||
|
import org.springframework.context.annotation.Bean;
|
||
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
||
|
@Configuration
|
||
|
@RequiredArgsConstructor
|
||
|
public class AssistantInit {
|
||
|
|
||
|
ChatLanguageModel qwenModel = QwenChatModel.builder()
|
||
|
.apiKey("sk-2f703a41fff0488e9b6888013d2ee58a")
|
||
|
.modelName("deepseek-v3")
|
||
|
.build();
|
||
|
|
||
|
@Bean
|
||
|
public Assist init() {
|
||
|
return AiServices.builder(Assist.class)
|
||
|
.chatMemoryProvider(memoryId -> MessageWindowChatMemory.withMaxMessages(10))
|
||
|
.chatLanguageModel(qwenModel).build();
|
||
|
}
|
||
|
}
|