PromptController.java

package fr.tiogars.chat.domains.prompt.controllers;

import fr.tiogars.chat.domains.prompt.models.PromptRequest;
import fr.tiogars.chat.domains.prompt.models.PromptResponse;
import fr.tiogars.chat.domains.prompt.services.PromptService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
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;

/**
 * REST controller for AI prompt operations.
 */
@RestController
@RequestMapping("/api/prompts")
@Tag(name = "Prompts", description = "AI prompt operations")
public class PromptController {

    private final PromptService promptService;

    public PromptController(PromptService promptService) {
        this.promptService = promptService;
    }

    @PostMapping
    @Operation(summary = "Process a prompt with AI", description = "Send a prompt to the configured AI model and get a response")
    public ResponseEntity<PromptResponse> processPrompt(@Valid @RequestBody PromptRequest request) {
        PromptResponse response = promptService.processPrompt(request);
        return ResponseEntity.ok(response);
    }
}