LawWiser is a Spring Boot application that uses Spring AI implementing RAG (Retrieval-Augmented Generation) to help users understand and query documents. For this prototype I used the constitution of The Republic of Ireland, but any collection of documents can be used to achieve the state-of-the-art RAG in Java.
- Natural Language Queries: Ask questions about the Irish Constitution in plain English
- AI-Powered Responses: Leverages Spring AI and vector embeddings to generate accurate answers
- Semantic Search: Finds relevant constitutional sections based on the meaning of your query, not just keywords
- PDF Document Processing: Automatically extracts and processes constitutional text from PDF documents
- Spring Boot: Core application framework
- Spring AI: AI capabilities and chat model integration
- Vector Database: Stores document embeddings for semantic searching
- PostgreSQL with pgvector: Database backend for vector storage
- PDF Document Processing: Extracts constitutional text from PDF sources
- Java 17 or higher
- Maven
- PostgreSQL with pgvector extension
- Clone the repository
- Configure your database connection in
application.yaml
- Run the application using Maven:
./mvnw spring-boot:run
- Access the API at
http://localhost:8080
Send GET requests to the root endpoint with your question as a parameter:
GET /?question=What does Article 6 of the Irish Constitution say?
The application will:
- Process your query
- Search for relevant sections in the Irish Constitution
- Use AI to generate a comprehensive answer based on the constitutional text
- Document Loading: The application loads the Irish Constitution PDF and splits it into manageable chunks
- Vector Embeddings: The text chunks are converted into vector embeddings and stored in a vector database
- Semantic Search: When a query is received, the application finds the most relevant constitutional sections
- AI Response Generation: The system prompts an AI model with your question and the relevant constitutional sections to generate an accurate answer
LawWiserApplication.java
: Main application entry pointLawWiserController.java
: REST controller handling user queriesDataLoader.java
: Responsible for loading and processing the constitutional document
This project is licensed under the MIT License. See the LICENSE file for details.