Neo4j RAG (Retrieval-Augmented Generation) implementation using Drivine for the Embabel Agent framework.
This module provides a Neo4j-based implementation of the RAG pattern using Drivine4j, a lightweight Neo4j driver for Java/Kotlin. It includes:
- CypherSearch: Interface for executing Cypher queries and retrieving results
- DrivineCypherSearch: Main implementation using Drivine for Neo4j operations
- DrivineStore: Content element repository for storing and retrieving documents and chunks
- LogicalQueryResolver: Resolves logical query names to Cypher query files
- Mappers: Row mappers for converting Neo4j query results to domain objects
ContentElementMapper: Maps to ContentElement (Document/Chunk)EntityDataMapper: Maps to EntityDataEntityDataSimilarityMapper: Maps to similarity search results for entitiesChunkSimilarityMapper: Maps to similarity search results for chunks
- Drivine4j: Lightweight Neo4j driver
- Embabel Agent RAG Pipeline: Core RAG abstractions and interfaces
- Spring Boot: For dependency injection and transaction management
- Kotlin: Implementation language
Add this dependency to your project:
<dependency>
<groupId>com.embabel.agent</groupId>
<artifactId>embabel-rag-neo-drivine</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>Configure Neo4j connection properties in your application configuration:
neo-rag-service:
cypher-directory: classpath:cypherCypher query files are located in src/main/resources/cypher/:
chunk_vector_search.cypher: Vector similarity search for chunksentity_vector_search.cypher: Vector similarity search for entitieschunk_fulltext_search.cypher: Full-text search for chunksentity_fulltext_search.cypher: Full-text search for entitiesvector_cluster.cypher: Clustering based on vector similaritysave_content_element.cypher: Save documents and chunkscreate_entity.cypher: Create named entitiesdelete_document_and_descendants.cypher: Delete documents and their chunks- And more...
The module includes integration tests using Testcontainers for Neo4j:
mvn testSee LICENSE file in the root directory.