package com.zhengmeng.ocrplatform.llm;

import com.zhengmeng.ocrplatform.common.ApiResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/v1/llm/models")
public class LlmModelController {
    private final LlmModelService service;

    public LlmModelController(LlmModelService service) {
        this.service = service;
    }

    @GetMapping
    public ApiResponse<List<LlmModelItem>> listModels() {
        return ApiResponse.ok(service.listModels());
    }

    @PatchMapping("/{modelId}")
    public ApiResponse<LlmModelItem> updateModel(@PathVariable String modelId, @RequestBody LlmModelUpdateRequest request) {
        return ApiResponse.ok(service.updateModel(modelId, request));
    }

    @PostMapping("/{modelId}/select")
    public ApiResponse<LlmModelItem> selectModel(@PathVariable String modelId) {
        return ApiResponse.ok(service.selectModel(modelId));
    }
}
