package com.sino.mci.inbound.controller;

import com.sino.mci.inbound.dto.IntentRecognizeRequest;
import com.sino.mci.inbound.intent.IntentRecognitionService;
import com.sino.mci.inbound.intent.IntentResult;
import com.sino.mci.shared.web.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 意图识别调试接口。
 */
@RestController
@RequestMapping("/api/v1/intent")
@RequiredArgsConstructor
public class IntentController {

    private final IntentRecognitionService intentRecognitionService;

    @PostMapping("/recognize")
    public ApiResponse<IntentResult> recognize(
            @RequestHeader("X-Tenant-Code") String tenantCode,
            @RequestBody IntentRecognizeRequest request) {
        return ApiResponse.ok(intentRecognitionService.recognize(
                tenantCode, request.getText(), request.getContext()));
    }
}
