View Javadoc
1   package fr.tiogars.chat.domains.prompt.controllers;
2   
3   import fr.tiogars.chat.domains.prompt.models.PromptRequest;
4   import fr.tiogars.chat.domains.prompt.models.PromptResponse;
5   import fr.tiogars.chat.domains.prompt.services.PromptService;
6   import io.swagger.v3.oas.annotations.Operation;
7   import io.swagger.v3.oas.annotations.tags.Tag;
8   import jakarta.validation.Valid;
9   import org.springframework.http.ResponseEntity;
10  import org.springframework.web.bind.annotation.PostMapping;
11  import org.springframework.web.bind.annotation.RequestBody;
12  import org.springframework.web.bind.annotation.RequestMapping;
13  import org.springframework.web.bind.annotation.RestController;
14  
15  /**
16   * REST controller for AI prompt operations.
17   */
18  @RestController
19  @RequestMapping("/api/prompts")
20  @Tag(name = "Prompts", description = "AI prompt operations")
21  public class PromptController {
22  
23      private final PromptService promptService;
24  
25      public PromptController(PromptService promptService) {
26          this.promptService = promptService;
27      }
28  
29      @PostMapping
30      @Operation(summary = "Process a prompt with AI", description = "Send a prompt to the configured AI model and get a response")
31      public ResponseEntity<PromptResponse> processPrompt(@Valid @RequestBody PromptRequest request) {
32          PromptResponse response = promptService.processPrompt(request);
33          return ResponseEntity.ok(response);
34      }
35  }