Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public Mono<ClaudeResponseDto> chatWithClaude(ClaudeRequestDto request, Long cou
+ "</example>"
+ "</systemPrompt>";

// 전체 XML 구조 통합
String xmlPrompt = "<conversationAnalysis>\n"
+ systemPrompt
+ "</conversationAnalysis>\n";
Expand All @@ -184,10 +183,11 @@ public Mono<ClaudeResponseDto> chatWithClaude(ClaudeRequestDto request, Long cou

private Mono<ClaudeResponseDto> parseXMLChatResponse(String xmlResponse, CounselingLog counselingLog, ClaudeRequestDto request) {
try {
String cleanedResponse = cleanXmlString(xmlResponse);
// XML 파서 초기화
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
String assistantResponseText = new JSONObject(xmlResponse)
String assistantResponseText = new JSONObject(cleanedResponse)
.getJSONArray("content")
.getJSONObject(0)
.getString("text");
Expand Down Expand Up @@ -488,6 +488,10 @@ private LocalDateTime generateRandomTime() {
long randomSeconds = ThreadLocalRandom.current().nextLong(minSeconds, maxSeconds);
return LocalDateTime.now().plusSeconds(randomSeconds);
}

private String cleanXmlString(String xml) {
return xml.trim().replaceFirst("^([\\W&&[^<]]+)<", "<");
}
}


Expand Down
Loading