package com.ruoyi.web.llm.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.llm.service.ISessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
/**
 * session对话Controller
 *
 * @author cmc
 * @date 2025-04-08
 */
@RestController
@RequestMapping("/llm/session")
public class SessionController extends BaseController
{
    @Autowired
    private ISessionService sessionService;

    /**
     * 生成回答
     */
    @GetMapping("/answer")
    public SseEmitter answer(String topicId, String question) {
        return sessionService.answer(topicId, question);
    }

    /**
     * 调用LLM+RAG（外部文件）生成回答
     */
    @GetMapping("/answerWithDocument")
    public SseEmitter answerWithDocument(String topicId, String chatId, String question) throws Exception
    {
        return sessionService.answerWithDocument(topicId, chatId, question);
    }
}

