Skip to content

Commit 81fb2e8

Browse files
authored
Merge pull request #347 from prgrms-web-devcourse-final-project/develop
배포
2 parents d2c1692 + 12a5d81 commit 81fb2e8

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

backend/src/main/java/com/ai/lawyer/domain/chatbot/service/ChatBotService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,7 @@ public class ChatBotService {
6161
// 멤버 조회 -> 벡터 검색 -> 프롬프트 생성 -> LLM 호출 (스트림) -> Kafka 이벤트 발행 -> 응답 반환
6262
@Transactional
6363
public Flux<ChatResponse> sendMessage(Long memberId, ChatRequest chatRequestDto, Long roomId) {
64-
65-
// Mono.fromCallable()과 subscribeOn()을 사용하여 블로킹 작업을 별도 스레드에서 실행
66-
// boundedElastic 스케줄러는 블로킹 I/O 작업에 최적화된 스레드 풀 사용
6764
return Mono.fromCallable(() -> {
68-
// 멤버 조회 (블로킹)
69-
Member member = memberRepository.findById(memberId)
70-
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 회원입니다."));
7165

7266
// 벡터 검색 (판례, 법령) (블로킹)
7367
List<Document> similarCaseDocuments = qdrantService.searchDocument(chatRequestDto.getMessage(), "type", "판례");
@@ -77,7 +71,7 @@ public Flux<ChatResponse> sendMessage(Long memberId, ChatRequest chatRequestDto,
7771
String lawContext = formatting(similarLawDocuments);
7872

7973
// 채팅방 조회 또는 생성 (블로킹)
80-
History history = getOrCreateRoom(member, roomId);
74+
History history = getOrCreateRoom(memberId, roomId);
8175

8276
// 메시지 기억 관리 (User 메시지 추가)
8377
ChatMemory chatMemory = saveChatMemory(chatRequestDto, history);
@@ -167,11 +161,11 @@ private Prompt getPrompt(String caseContext, String lawContext, ChatMemory chatM
167161
return new Prompt(List.of(systemMessage, userMessage));
168162
}
169163

170-
private History getOrCreateRoom(Member member, Long roomId) {
164+
private History getOrCreateRoom(Long memberId, Long roomId) {
171165
if (roomId != null) {
172166
return historyService.getHistory(roomId);
173167
} else {
174-
return historyRepository.save(History.builder().memberId(member.getMemberId()).build());
168+
return historyRepository.save(History.builder().memberId(memberId).build());
175169
}
176170
}
177171

0 commit comments

Comments
 (0)