Skip to content

Commit

Permalink
[FIX] 카테고리 범위 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
wakkpu committed Jan 27, 2024
1 parent c229e3a commit 54308e6
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ public String getSearchResults(String searchQuery) throws Exception {
.fromEntity(brandRepository.findAll())
.getBrandResponses();

String allBrands = brands.stream()
String brandString = brands.stream()
.map(ReadBrandResponse::toString)
.collect(Collectors.joining(","));

List<Category> midCategories = categoryRepository.findAllChildCategories(null)
List<Category> midCategories = categoryRepository.findByMasterCategory_IdOrderByNameAsc(null)
.stream()
.flatMap(rootCategory -> categoryRepository.findAllChildCategories(rootCategory.getId()).stream())
.flatMap(rootCategory -> categoryRepository.findByMasterCategory_IdOrderByNameAsc(rootCategory.getId()).stream())
.collect(Collectors.toList());

List<ReadChildrenCategoryResponse> categories = ReadChildrenCategoryListResponse
.fromEntity(midCategories)
.getCategoryResponses();

String allCategories = categories.stream()
String categoryString = categories.stream()
.map(ReadChildrenCategoryResponse::toString)
.collect(Collectors.joining(","));

Expand All @@ -58,7 +58,7 @@ public String getSearchResults(String searchQuery) throws Exception {
List<Map<String, Object>> messages = new ArrayList<>();
Map<String, Object> message = new HashMap<>();
message.put("role", "user");
message.put("content", createPrompt(searchQuery, allBrands, allCategories, genderStrings));
message.put("content", createPrompt(searchQuery, brandString, categoryString, genderStrings));
messages.add(message);

Map<String, Object> requestData = new HashMap<>();
Expand Down Expand Up @@ -110,10 +110,10 @@ private String createTranslatePrompt(String query) {
return "Translate this sentence into english: " + "\"" + query + "\"";
}

private String createPrompt(String searchQuery, String brands, String categories, String genders) {
private String createPrompt(String searchQuery, String brandString, String categoryString, String genders) {
return "{" +
"\"categories\": [" + categories + "], " +
"\"brands\": [" + brands + "], " +
"\"categories\": [" + categoryString + "], " +
"\"brands\": [" + brandString + "], " +
"\"genders\": " + genders + ", " +
"\"priceRanges\": [" +
"{\"id\": 1, \"name\": \"$0-$299\"}, " +
Expand Down

0 comments on commit 54308e6

Please sign in to comment.