|
| 1 | +package com.opensource.docgrid.domain.embedding.controller; |
| 2 | + |
| 3 | +import org.springframework.http.MediaType; |
| 4 | +import org.springframework.http.ResponseEntity; |
| 5 | +import org.springframework.web.bind.annotation.GetMapping; |
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 7 | +import org.springframework.web.bind.annotation.RestController; |
| 8 | + |
| 9 | +import com.opensource.docgrid.domain.embedding.dto.response.EmbeddingModelResponse; |
| 10 | +import com.opensource.docgrid.domain.embedding.service.query.EmbeddingModelQueryService; |
| 11 | +import com.opensource.docgrid.global.common.response.ApiResponse; |
| 12 | +import com.opensource.docgrid.global.common.response.ErrorResponse; |
| 13 | +import com.opensource.docgrid.global.common.response.ResponseUtils; |
| 14 | + |
| 15 | +import io.swagger.v3.oas.annotations.Operation; |
| 16 | +import io.swagger.v3.oas.annotations.media.Content; |
| 17 | +import io.swagger.v3.oas.annotations.media.ExampleObject; |
| 18 | +import io.swagger.v3.oas.annotations.media.Schema; |
| 19 | +import io.swagger.v3.oas.annotations.responses.ApiResponses; |
| 20 | +import io.swagger.v3.oas.annotations.tags.Tag; |
| 21 | +import lombok.RequiredArgsConstructor; |
| 22 | + |
| 23 | +@Tag( |
| 24 | + name = "Embedding Model", |
| 25 | + description = "문서 인덱싱과 검색에서 사용할 임베딩 모델 설정 조회 API" |
| 26 | +) |
| 27 | +@RestController |
| 28 | +@RequestMapping("/api/embedding-models") |
| 29 | +@RequiredArgsConstructor |
| 30 | +public class EmbeddingModelController { |
| 31 | + |
| 32 | + private final EmbeddingModelQueryService embeddingModelQueryService; |
| 33 | + |
| 34 | + @Operation( |
| 35 | + summary = "기본 임베딩 모델 조회", |
| 36 | + description = """ |
| 37 | + is_active=true, is_searchable=true인 기본 임베딩 모델을 조회합니다. |
| 38 | + 신규 embedding_job 생성 시 사용할 모델 설정이며, 정상적으로 하나만 존재해야 합니다. |
| 39 | + 모델이 없거나 여러 개 존재하면 서버 설정 오류가 발생합니다. |
| 40 | + 실제 Vector를 생성하거나 임베딩 모델을 실행하지 않습니다. |
| 41 | + """ |
| 42 | + ) |
| 43 | + @ApiResponses({ |
| 44 | + @io.swagger.v3.oas.annotations.responses.ApiResponse( |
| 45 | + responseCode = "200", |
| 46 | + description = "기본 임베딩 모델 조회 성공" |
| 47 | + ), |
| 48 | + @io.swagger.v3.oas.annotations.responses.ApiResponse( |
| 49 | + responseCode = "500", |
| 50 | + description = "기본 임베딩 모델 설정 오류", |
| 51 | + content = @Content( |
| 52 | + schema = @Schema(implementation = ErrorResponse.class), |
| 53 | + examples = { |
| 54 | + @ExampleObject( |
| 55 | + name = "모델 미설정", |
| 56 | + value = """ |
| 57 | + {"success":false,"status":500,"code":"EMBEDDING-MODEL-001","message":"사용 가능한 임베딩 모델이 설정되지 않았습니다.","method":"GET","path":"/api/embedding-models/active","timestamp":"2026-07-14 12:00:00"} |
| 58 | + """ |
| 59 | + ), |
| 60 | + @ExampleObject( |
| 61 | + name = "모델 중복 설정", |
| 62 | + value = """ |
| 63 | + {"success":false,"status":500,"code":"EMBEDDING-MODEL-002","message":"사용 가능한 임베딩 모델이 여러 개 설정되어 있습니다.","method":"GET","path":"/api/embedding-models/active","timestamp":"2026-07-14 12:00:00"} |
| 64 | + """ |
| 65 | + ) |
| 66 | + } |
| 67 | + ) |
| 68 | + ) |
| 69 | + }) |
| 70 | + @GetMapping(value = "/active", produces = MediaType.APPLICATION_JSON_VALUE) |
| 71 | + public ResponseEntity<ApiResponse<EmbeddingModelResponse>> getActiveModel() { |
| 72 | + return ResponseUtils.ok(embeddingModelQueryService.getActiveModelResponse()); |
| 73 | + } |
| 74 | +} |
0 commit comments