package com.seer.teach.teacher.common.llm.req;


import com.seer.teach.common.config.LlmConfig;
import com.seer.teach.teacher.common.resp.SubjectScoreResp;
import com.seer.teach.teacher.common.utils.SubjectTagUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.HashMap;
import java.util.List;
import java.util.Random;

/**
 * @Author: Captain
 * @Description:
 * @Date: 2025-05-20 20:26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Schema(description = "JSON RPC 2.0 标准")
public class JsonRpcReq {

    @Schema(description = "请求ID")
    private Integer id;

    @Schema(description = "协议标准")
    private String jsonrpc;

    @Schema(description = "请求目标")
    private String method;

    @Schema(description = "参数")
    private Object params;

    /**
     * 构造一个用于题目批改的 JSON-RPC 请求对象。
     *
     * @param params 题目批改请求参数对象
     * @return 返回构造好的 JsonRpcReq 对象
     */
    public static JsonRpcReq questionsCorrect(QuestionsCorrectLlmReq params) {
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.QUESTIONS_CORRECT, params);
    }

    public static JsonRpcReq recommendChapters(HashMap<String, Object> params) {
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.RECOMMEND_CHAPTERS, params);
    }

    public static JsonRpcReq tts( HashMap<String, Object> params) {
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.TTS, params);
    }

    public static JsonRpcReq stt(HashMap<String, Object> params) {
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.STT, params);
    }

    public static JsonRpcReq getComment(Integer userId, List<SubjectScoreResp> score) {
        HashMap<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("tags", SubjectTagUtils.getAllTags());
        params.put("subjects", score);
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.GET_COMMENT, params);
    }

    public static JsonRpcReq getPlanQuestions(LlmGetPlanQuestionReq params) {
        return new JsonRpcReq(new Random().nextInt(100) + 1, "2.0", LlmConfig.GET_PLAN_QUESTIONS, params);
    }
}
