Skip to content

Commit d25af90

Browse files
authored
Merge pull request #194 from capgoing/langchain
📝 [Mock data] 프론트 통신을 위한 GraphRAG retrievedTriples 임시 데이터 추가
2 parents b7dc075 + 673e2d9 commit d25af90

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/main/java/com/going/server/domain/chatbot/dto/CreateChatbotResponseDto.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public class CreateChatbotResponseDto {
1515
private String graphId;
1616
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm")
1717
private LocalDateTime createdAt;
18-
private List<String> retrievedChunks;
19-
private List<String> sourceNodes;
20-
private Map<String, String> ragMeta;
18+
private List<String> retrievedTriples; //관계 중심의 3요소 표현 ("물 -상태변화→ 응고")
19+
private List<String> sourceNodes; //질의에 사용된 핵심 노드들 ("물", "응고" 등)
20+
private List<String> 증강할때쓴자료; //LLM에 넘긴 context 문장들 (이름은 `augmentedSentences` 등으로 변경 권장)
21+
22+
private Map<String, String> ragMeta; //(ex: 사용한 쿼리문 등)
2123

2224
public static CreateChatbotResponseDto of(
2325
String chatContent,
@@ -30,7 +32,7 @@ public static CreateChatbotResponseDto of(
3032
.chatContent(chatContent)
3133
.graphId(graphId)
3234
.createdAt(createdAt)
33-
.retrievedChunks(retrievedChunks)
35+
.retrievedTriples(retrievedChunks)
3436
.sourceNodes(sourceNodes)
3537
.ragMeta(Map.of("chunkCount", String.valueOf(retrievedChunks.size())))
3638
.build();

src/main/java/com/going/server/domain/chatbot/service/ChatbotServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ public CreateChatbotResponseDto createAnswerWithRAG(String graphStrId, CreateCha
7777
Long dbId = graphRepository.findDbIdByGraphId(Long.valueOf(graphStrId));
7878
Graph graph = graphRepository.getByGraph(dbId);
7979

80+
// 새로운 채팅인 경우
8081
if (requestDto.isNewChat()) {
8182
deletePreviousChat(dbId);
8283
}
8384

85+
// 새로운 질문 추가
8486
Chatting userChat = Chatting.builder()
8587
.graph(graph)
8688
.content(requestDto.getChatContent())
@@ -89,6 +91,7 @@ public CreateChatbotResponseDto createAnswerWithRAG(String graphStrId, CreateCha
8991
.build();
9092
chattingRepository.save(userChat);
9193

94+
// 채팅 내역 조회
9295
List<Chatting> chatHistory = chattingRepository.findAllByGraphId(dbId);
9396

9497
// RAG 응답 생성 (응답 + 메타 포함)

src/main/java/com/going/server/domain/rag/service/GraphRAGService.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public class GraphRAGService {
3131
/**
3232
* 사용자 질문에 대해 Cypher 쿼리 → 그래프 정보 검색 → 프롬프트 생성 → LLM 응답 생성
3333
* 본 메서드는 LangChain 없이 구현한 Spring 기반 GraphRAG의 핵심 흐름입니다.
34+
*
35+
* private LocalDateTime createdAt;
36+
* private List<String> retrievedTriples; //관계 중심의 3요소 표현 ("물 -상태변화→ 응고")
37+
* private List<String> sourceNodes; //질의에 사용된 핵심 노드들 ("물", "응고" 등)
38+
* private List<String> 증강할때쓴자료; //LLM에 넘긴 context 문장들 (이름은 `augmentedSentences` 등으로 변경 권장)
39+
* -> 이렇게 결과 나오도록 정리
3440
*/
3541
public CreateChatbotResponseDto createAnswerWithGraphRAG(
3642
Long dbId,
@@ -74,11 +80,20 @@ public CreateChatbotResponseDto createAnswerWithGraphRAG(
7480
chattingRepository.save(answer);
7581
log.info("[GraphRAG] Response saved to DB");
7682

83+
// 임시 retrievedTriples 설정
84+
List<String> retrievedTriples = List.of(
85+
"(물)-[:RELATED {label: '상태변화'}]->(기화)",
86+
"(기화)-[:RELATED {label: '조건'}]->(높은 온도)",
87+
"(수증기)-[:RELATED {label: '응결'}]->(물방울)",
88+
"(물)-[:RELATED {label: '응고'}]->(얼음)",
89+
"(응고)-[:RELATED {label: '예시'}]->(겨울철 얼어붙은 길)"
90+
);
91+
7792
return CreateChatbotResponseDto.of(
7893
response,
7994
dbId.toString(),
8095
answer.getCreatedAt(),
81-
contextChunks,
96+
retrievedTriples,
8297
sourceNodes
8398
);
8499
}

0 commit comments

Comments
 (0)