package com.iwe3.langchain4j;

import com.iwe3.langchain4j.service.ChatAssistant;
import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.model.chat.ChatModel;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class MemoryApplicationTest {

    @Resource(name="qwen")
    private ChatModel chatModel;

    @Test
    public void testLowerLevel(){

        // 第一轮对话
        var um01 = UserMessage.userMessage("我是蒲哥");
        var res01 = chatModel.chat(um01);
        var am01 = res01.aiMessage();
        // 输出大语言模型的回复
        System.out.println(am01.text());

        // 第二轮对话
        var um02 = UserMessage.userMessage("你知道我是谁吗");
        //将第一轮对话记录，也一起发给 LLM
        var res02 = chatModel.chat(um02);

        var am02 = res02.aiMessage();
        // 输出大语言模型的回复
        System.out.println(am02.text());
    }



    @Autowired
    private ChatAssistant chatAssistant;
    @Test
    public void testHighLevel(){
        var res = chatAssistant.chat("我是蒲哥");
        System.out.println("res = " + res);
        res = chatAssistant.chat("我是谁？");
        System.out.println("res = " + res);
    }



}