|
1 | 1 | package com.bigpicture.moonrabbit.domain.fine.service; |
2 | 2 |
|
3 | 3 | import lombok.extern.slf4j.Slf4j; |
4 | | -import org.springframework.core.io.ByteArrayResource; |
5 | 4 | import org.springframework.core.io.FileSystemResource; |
6 | 5 | import org.springframework.http.MediaType; |
7 | 6 | import org.springframework.stereotype.Service; |
|
12 | 11 | import org.springframework.web.reactive.function.client.WebClientResponseException; |
13 | 12 |
|
14 | 13 | import java.io.File; |
15 | | -import java.nio.file.Files; |
16 | 14 | import java.util.Map; |
17 | 15 |
|
18 | 16 | @Service |
@@ -52,17 +50,8 @@ public String startFineTuningWithBaseModel(String jsonlPath, String baseModel) { |
52 | 50 | // Step 1: Upload JSONL file |
53 | 51 | MultiValueMap<String, Object> multipartBody = new LinkedMultiValueMap<>(); |
54 | 52 |
|
55 | | - // [수정된 로직 시작: ByteArrayResource를 사용하여 filename 명시] |
56 | | - // 1. 파일 내용을 byte 배열로 읽기 (IOException 발생 가능) |
57 | | - byte[] fileContent = Files.readAllBytes(jsonlFile.toPath()); |
58 | | - |
59 | | - // 2. ByteArrayResource를 생성하고, getFilename()을 오버라이드하여 파일 이름(.jsonl)을 강제 주입 |
60 | | - ByteArrayResource resource = new ByteArrayResource(fileContent) { |
61 | | - @Override |
62 | | - public String getFilename() { |
63 | | - return jsonlFile.getName(); // "fine_dataset_....jsonl" 파일명 사용 |
64 | | - } |
65 | | - }; |
| 53 | + // FileSystemResource를 사용하여 스트리밍 방식으로 전송 (메모리 효율성 향상) |
| 54 | + FileSystemResource resource = new FileSystemResource(jsonlFile); |
66 | 55 |
|
67 | 56 | multipartBody.add("file", resource); |
68 | 57 | multipartBody.add("purpose", "fine-tune"); |
|
0 commit comments