그래프 문서 저장하기
지금 애플리케이션에는 노드 3개와 관계 2개가 있지만, 현재는 메모리에만 존재해요.
이번 연습에서는 미리 준비된 Neo4j 인스턴스에 연결한 뒤, 이 노드들과 관계를 데이터베이스에 저장해 볼 거예요.
이 연습은 강의의 일부입니다
LangChain과 Neo4j로 배우는 Graph RAG
연습 안내
- 제공된 자격 증명으로 Neo4j 데이터베이스에 연결하세요.
- 정의된 노드(
book,jesus,jim)와 관계(written_by_jesus,written_by_jim)로 그래프 문서를 생성하세요. - 그래프 문서를 데이터베이스에 저장하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Connect to the Neo4j Database
graph = ____(url=NEO4J_URL, username=NEO4J_USERNAME, password=NEO4J_PASSWORD)
# Define the collection of graph documents
graph_document = ____(
____=[book, jesus, jim],
____=[written_by_jesus, written_by_jim]
)
# Save the data to your graph
graph.____([graph_document])
graph.refresh_schema()
print(graph.schema)