Skip to content

Commit

Permalink
feat: 여행 일정의 비용 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yo0oni committed Aug 13, 2024
1 parent d344efc commit 488b2da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
@NoArgsConstructor
public class GptScheduleDetail {
private String detail;
private Double price;
private Coordinate coordinate;

public GptScheduleDetail(String detail, Coordinate coordinate) {
public GptScheduleDetail(String detail, Double price, Coordinate coordinate) {
this.detail = detail;
this.price = price;
this.coordinate = coordinate;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.isp.backend.domain.gpt.service;

import com.isp.backend.domain.country.entity.Country;
import com.isp.backend.domain.country.repository.CountryRepository;
import com.isp.backend.domain.gpt.config.GptConfig;
import com.isp.backend.domain.gpt.constant.ParsingConstants;
import com.isp.backend.domain.gpt.dto.request.GptRequest;
Expand All @@ -12,6 +13,7 @@
import com.isp.backend.domain.gpt.entity.GptSchedule;
import com.isp.backend.domain.gpt.entity.GptScheduleParser;
import com.isp.backend.domain.schedule.service.ScheduleService;
import com.isp.backend.global.exception.schedule.CountryNotFoundException;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
Expand All @@ -34,6 +36,7 @@
public class GptService {

private final GptScheduleParser gptScheduleParser;
private final CountryRepository countryRepository;
private final ScheduleService scheduleService;
private final WebClient webClient;

Expand All @@ -49,7 +52,6 @@ public GptScheduleResponse getResponse(HttpHeaders headers, GptRequest gptReques
.retrieve()
.bodyToMono(GptResponse.class)
.block();

List<GptSchedule> gptSchedules = gptScheduleParser.parseScheduleText(extractScheduleText(response));
return new GptScheduleResponse(gptSchedules);
}
Expand All @@ -61,9 +63,8 @@ private String extractScheduleText(GptResponse gptResponse) {
@Async
public CompletableFuture<GptSchedulesResponse> askQuestion(GptScheduleRequest questionRequest) {
String question = formatQuestion(questionRequest);
Country country = countryRepository.findAirportCodeByCity(questionRequest.getDestination()).orElseThrow(CountryNotFoundException::new); String countryImage = country.getImageUrl();
List<GptMessage> messages = Collections.singletonList(createMessage(question));
Country country = scheduleService.validateCountry(questionRequest.getDestination());
String countryImage = country.getImageUrl();

ExecutorService executorService = Executors.newFixedThreadPool(5);
List<CompletableFuture<GptScheduleResponse>> futures = Arrays.asList(
Expand Down Expand Up @@ -103,7 +104,7 @@ private String formatQuestion(GptScheduleRequest questionRequest) {
questionRequest.getExcludedActivities(),
questionRequest.getDepartureDate(),
questionRequest.getReturnDate(),
String.join(ParsingConstants.COMMA, questionRequest.getPurpose())
String.join(ParsingConstants.COMMA.getStringValue(), questionRequest.getPurpose())
);
}

Expand Down

0 comments on commit 488b2da

Please sign in to comment.