8 天以前 2f80b7085c4eabce06d3491306b75eecc275275f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.ruoyi.ai.config;
 
import com.ruoyi.ai.store.MongoChatMemoryStore;
import dev.langchain4j.community.model.dashscope.QwenStreamingChatModel;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
@Configuration
public class PurchaseAgentConfig {
 
    @Bean
    ChatMemoryProvider chatMemoryProviderPurchase(MongoChatMemoryStore mongoChatMemoryStore) {
        return memoryId -> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(30)
                .chatMemoryStore(mongoChatMemoryStore)
                .build();
    }
 
    @Bean("purchaseVisionStreamingChatModel")
    QwenStreamingChatModel purchaseVisionStreamingChatModel(
            @Value("${langchain4j.community.dashscope.streaming-chat-model.api-key}") String apiKey) {
        return QwenStreamingChatModel.builder()
                .apiKey(apiKey)
                .modelName("qwen-vl-max")
                .isMultimodalModel(true)
                .build();
    }
}