Skip to content

Commit

Permalink
Merge branch 'main' into feat/#35
Browse files Browse the repository at this point in the history
  • Loading branch information
oU-Ua authored Oct 5, 2024
2 parents 0ec7fce + 549f945 commit 254c776
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/easylead/easylead/config/GptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class GptConfig {
public static final String AUTHORIZATION = "Authorization";
public static final String BEARER = "Bearer ";
public static final String CHAT_MODEL = "gpt-4o-mini";
public static final String CHAT_MODEL_CUSTOM = "ft:gpt-3.5-turbo-0613:personal::9rJq4pTM";
public static final String CHAT_MODEL_CUSTOM = "ft:gpt-3.5-turbo-0613:personal::9rWlz51c";
public static final Integer MAX_TOKEN = 300;
public static final Boolean STREAM = true;
public static final String ROLE = "user";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,25 @@ public void easyToRead(String isbn) throws JsonProcessingException {
Book book = bookConverter.toBook(request);
System.out.println(book.getISBN()+" "+ book.getTitle());
Book saveBook = bookService.save(book);
for(Origin originContent : originList){

String easyContent= null;
String imgUrl = null;
try {
// 두 비동기 작업을 병렬로 시작
CompletableFuture<String> easyContentFuture = bookService.transformContent(originContent.getPageContent());
CompletableFuture<String> imgUrlFuture = bookService.makeImage(originContent.getPageContent());

// 두 작업이 모두 완료될 때까지 기다림
easyContent = easyContentFuture.get();
imgUrl = imgUrlFuture.get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}

Content content = contentConverter.toContent(saveBook,easyContent,originContent.getOriginId(),imgUrl);
contentService.save(content);
}
// for(Origin originContent : originList){
//
// String easyContent= null;
// String imgUrl = null;
// try {
// // 두 비동기 작업을 병렬로 시작
// CompletableFuture<String> easyContentFuture = bookService.transformContent(originContent.getPageContent());
// CompletableFuture<String> imgUrlFuture = bookService.makeImage(originContent.getPageContent());
//
// // 두 작업이 모두 완료될 때까지 기다림
// easyContent = easyContentFuture.get();
// imgUrl = imgUrlFuture.get();
// } catch (InterruptedException | ExecutionException e) {
// throw new RuntimeException(e);
// }
//
// Content content = contentConverter.toContent(saveBook,easyContent,originContent.getOriginId(),imgUrl);
// contentService.save(content);
// }
request.updateProgress(Progress.P4);
requestService.update(request);

Expand All @@ -132,7 +132,7 @@ public BookContentResDTO readContent(Long userId, Long pageId, String isbn) {
readService.save(read);


return BookContentResDTO.builder().content(contentList).maxPage(maxPage).build();
return BookContentResDTO.builder().pageId(pageId).content(contentList).maxPage(maxPage).build();
}

public List<BookInfoResDTO> recentList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@Builder
public class BookContentResDTO {
List<ContentResDTO> content;
Long pageId;
Long maxPage;

}
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public HttpRequest requestGPTCustom(String text) throws JsonProcessingException

messages.add(new Message(text, "user"));

ChatGPTRequestDTO chatGptRequest = new ChatGPTRequestDTO("ft:gpt-3.5-turbo-0613:personal::9rJq4pTM", messages, 0.3,false);
ChatGPTRequestDTO chatGptRequest = new ChatGPTRequestDTO("ft:gpt-3.5-turbo-0613:personal::9rWlz51c", messages, 0.3,false);
String input = null;
input = mapper.writeValueAsString(chatGptRequest);
System.out.println(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ public TextFileResDTO easyToReadImage(MultipartFile file) throws JsonProcessingE

HttpRequest request = gptService.requestGPT(reqText,"gpt-4o-mini");
return TextFileResDTO.builder().text(gptService.responseGPT(request)).build();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ public class TextController {
private final TextBusiness textBusiness;

@PostMapping(value = "/image")
public ResponseEntity<TextFileResDTO> easyToReadImage(Locale locale,
HttpServletRequest request,
HttpServletResponse response,
public ResponseEntity<TextFileResDTO> easyToReadImage(

@RequestPart(value = "image") MultipartFile file) throws JsonProcessingException {

return ResponseEntity.ok(textBusiness.easyToReadImage(file));
Expand Down

0 comments on commit 254c776

Please sign in to comment.