-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feat: 퀘스트 추천 api 추가
- Loading branch information
Showing
21 changed files
with
205 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/groom/orbit/ai/app/util/CustomOutputConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.groom.orbit.ai.app.util; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.ai.converter.BeanOutputConverter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
public class CustomOutputConverter<T> { | ||
|
||
private final BeanOutputConverter<T> converter; | ||
private final ObjectMapper objectMapper; | ||
private final Class<T> targetType; | ||
|
||
public CustomOutputConverter(Class<T> converterClass) { | ||
this.converter = new BeanOutputConverter<>(converterClass); | ||
this.objectMapper = new ObjectMapper(); | ||
this.targetType = converterClass; | ||
} | ||
|
||
public T convertToObject(String text) { | ||
return converter.convert(text); | ||
} | ||
|
||
public List<T> convertToList(String text) { | ||
try { | ||
// JSON 문자열을 파싱하여 리스트 형태로 변환 | ||
text = preprocessJson(text); | ||
return objectMapper.readValue(text, new TypeReference<>() {}); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException("Failed to convert text to List: " + text, e); | ||
} | ||
} | ||
|
||
public String getFormat() { | ||
return converter.getFormat(); | ||
} | ||
|
||
private String preprocessJson(String text) { | ||
text = text.trim(); | ||
if (text.startsWith("```") && text.endsWith("```")) { | ||
String[] lines = text.split("\n", 2); | ||
if (lines[0].trim().equalsIgnoreCase("```json")) { | ||
text = lines.length > 1 ? lines[1] : ""; | ||
} else { | ||
text = text.substring(3); | ||
} | ||
text = text.substring(0, text.length() - 3); | ||
} | ||
return text.trim(); | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
src/main/java/com/groom/orbit/config/openai/AiFeedbackPrompt.java
This file was deleted.
Oops, something went wrong.
92 changes: 0 additions & 92 deletions
92
src/main/java/com/groom/orbit/config/openai/AiFeedbackRequestDto.java
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
src/main/java/com/groom/orbit/config/openai/AiFeedbackResponseDto.java
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
src/main/java/com/groom/orbit/config/openai/GoalRecommendPrompt.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.