LexAI is a proof-of-concept AI-powered legal research assistant that helps users access location-specific legal information through a simple web interface. By combining large language models with structured jurisdictional data, LexAI delivers clear, tailored answers to everyday legal questions.
- GPT-4 Integration: Uses OpenAI's GPT-4 to generate concise, relevant legal responses.
- Jurisdiction-Specific Search: Preloaded embeddings for Boulder County and Denver, Colorado.
- Semantic Search Engine: Uses cosine similarity for embedding-based document retrieval.
- Modern Web Interface: Built with Gradio for real-time interaction.
- Modular Design: Clean separation of logic for UI, inference, and API handling.
- Fully Tested: Unit tests cover embedding loading, matching logic, and OpenAI API integration.
- Developer Ready: Comes with dev tools like Ruff, Black, pytest, mypy, and test coverage support.
LexAI is an AI-powered legal research assistant that helps users access location-specific legal information through a simple web interface. By combining large language models with structured jurisdictional data, LexAI delivers clear, tailored answers to everyday legal questions.
- GPT-4 Integration: Uses OpenAI's GPT-4 to generate concise, relevant legal responses.
- Jurisdiction-Specific Search: Preloaded embeddings for Boulder County and Denver, Colorado.
- Semantic Search Engine: Uses cosine similarity for embedding-based document retrieval.
- Modern Web Interface: Built with Gradio for real-time interaction.
- Modular Design: Clean separation of logic for UI, inference, and API handling.
- Fully Tested: Unit tests cover embedding loading, matching logic, and OpenAI API integration.
- Developer Friendly: Includes dev tools like Ruff, Black, pytest, mypy, and coverage reports.
git clone https://github.com/alexulanch/lexai.git
cd lexai
This project uses Git LFS to manage large files such as .npz
embedding data.
git lfs install
git lfs pull
pip install -r requirements.txt
# For development tools:
pip install -r dev-requirements.txt
Copy the template and add your API key:
cp .env.example .env
Then edit .env
and set:
OPENAI_API_KEY=your_openai_api_key
python -m lexai
Then open http://127.0.0.1:7860
in your browser.
.
├── LICENSE
├── README.md
├── assets/
│ └── screenshot.png
├── dev-requirements.txt
├── .env.example
├── lexai/
│ ├── __main__.py
│ ├── config.py
│ ├── core/
│ │ ├── data_loader.py
│ │ ├── match_engine.py
│ │ └── matcher.py
│ ├── data/
│ │ ├── boulder_embeddings.npz
│ │ └── denver_embeddings.npz
│ ├── services/
│ │ ├── lexai_service.py
│ │ └── openai_client.py
│ └── ui/
│ ├── formatters.py
│ └── gradio_interface.py
├── pyproject.toml
├── pytest.ini
├── requirements.txt
└── tests/
├── test_data_loader.py
├── test_matcher.py
└── test_openai_client.py
To run tests:
pytest
To check code coverage:
pytest --cov=lexai --cov-report=term
To lint:
ruff check .
To format code:
black .
MIT License