MrAl3x0
commited on
Commit
·
ce68191
1
Parent(s):
15e9663
docs: add LICENSE and screenshot to README
Browse files- Added MIT license file to the repository
- Inserted screenshot into README for visual context
- Minor wording improvements for clarity
- LICENSE +21 -0
- README.md +71 -54
- assets/screenshot.png +3 -0
LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2025 Alex Ulanch
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
README.md
CHANGED
|
@@ -2,14 +2,18 @@
|
|
| 2 |
|
| 3 |
## AI-Powered Legal Research Assistant
|
| 4 |
|
| 5 |
-
This repository hosts a demonstration of LexAI
|
| 6 |
|
| 7 |
### Features
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
### Getting Started
|
| 15 |
|
|
@@ -17,103 +21,116 @@ Follow these steps to set up and run the LexAI demo on your local machine.
|
|
| 17 |
|
| 18 |
#### 1. Clone the Repository
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
```shell
|
| 23 |
git clone https://github.com/alexulanch/lexai-demo.git
|
| 24 |
cd lexai-demo
|
| 25 |
```
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
#### 2. Install Dependencies
|
| 28 |
|
| 29 |
-
Install the required Python packages using pip. The dependencies are `pandas`, `numpy`, `openai`, `gradio`, `scipy`, and `python-dotenv`.
|
| 30 |
|
| 31 |
-
```
|
| 32 |
pip install -r requirements.txt
|
| 33 |
```
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
|
| 41 |
-
**Using a `.env` file (for local development)
|
| 42 |
|
| 43 |
-
1.
|
| 44 |
-
2.
|
| 45 |
|
| 46 |
-
```
|
| 47 |
OPENAI_API_KEY="your_openai_api_key_here"
|
| 48 |
```
|
| 49 |
-
|
| 50 |
-
3.
|
|
|
|
|
|
|
| 51 |
|
| 52 |
#### 4. Run the Application
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
```
|
| 57 |
python -m lexai
|
| 58 |
```
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
```
|
| 67 |
lexai-demo/
|
| 68 |
-
├── .devcontainer/ #
|
| 69 |
│ └── devcontainer.json
|
| 70 |
-
├── lexai/ # Main Python package
|
| 71 |
│ ��── __init__.py
|
| 72 |
-
│ ├── __main__.py #
|
| 73 |
-
│ ├── config.py #
|
| 74 |
│ ├── core/ # Core logic components
|
| 75 |
-
│ │ ├── data_loader.py #
|
| 76 |
-
│ │ └── matcher.py #
|
| 77 |
-
│ └── services/ # External
|
| 78 |
-
│ └── openai_client.py #
|
| 79 |
-
├── pyproject.toml # Project metadata and build
|
| 80 |
-
├── requirements.txt # Python
|
| 81 |
-
└── .gitignore #
|
| 82 |
```
|
| 83 |
|
| 84 |
-
|
| 85 |
-
* `lexai/config.py`: Stores global application settings, model names (e.g., `MODEL_ENGINE = "text-embedding-ada-002"`, `GPT4_MODEL = "gpt-4"`), and role descriptions.
|
| 86 |
-
* `lexai/core/`: Contains the fundamental algorithms and data processing logic, such as loading embeddings (`data_loader.py`) and performing similarity searches (`matcher.py`).
|
| 87 |
-
* `lexai/services/`: Encapsulates interactions with external APIs, specifically the OpenAI API (`openai_client.py`).
|
| 88 |
-
* `.devcontainer/`: Provides configuration for consistent development environments using VS Code Dev Containers.
|
| 89 |
-
* `pyproject.toml`: A modern standard for defining project metadata and build system requirements.
|
| 90 |
|
| 91 |
### Usage
|
| 92 |
|
| 93 |
-
1.
|
| 94 |
-
2.
|
| 95 |
-
3.
|
| 96 |
-
4.
|
| 97 |
-
5.
|
|
|
|
|
|
|
| 98 |
|
| 99 |
### Error Handling
|
| 100 |
|
| 101 |
-
The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
-
|
| 104 |
-
* `OpenAI API Error...`: General errors from the OpenAI API (e.g., rate limiting, network issues).
|
| 105 |
-
* `File Error...`: Problems loading the embedding data files (e.g., `npz` files). Ensure they are correctly placed and accessible.
|
| 106 |
-
* `Input Error...`: Issues with the input provided to the application.
|
| 107 |
|
| 108 |
### Contributing
|
| 109 |
|
| 110 |
-
Contributions are welcome
|
|
|
|
|
|
|
| 111 |
|
| 112 |
### License
|
| 113 |
|
| 114 |
MIT
|
| 115 |
|
|
|
|
|
|
|
| 116 |
### Acknowledgements
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
| 2 |
|
| 3 |
## AI-Powered Legal Research Assistant
|
| 4 |
|
| 5 |
+
This repository hosts a demonstration of **LexAI**, an AI-powered legal research assistant designed to provide relevant legal information based on user queries and specified locations. This project serves as a proof of concept, showcasing the integration of large language models (LLMs) with local embedding data for specialized information retrieval.
|
| 6 |
|
| 7 |
### Features
|
| 8 |
|
| 9 |
+

|
| 10 |
+
|
| 11 |
+
- **AI-Powered Responses**: Utilizes OpenAI's GPT-4 model to generate natural language responses to legal queries.
|
| 12 |
+
- **Location-Specific Information**: Provides legal information tailored to specific jurisdictions (currently Boulder County, Colorado, and Denver, Colorado).
|
| 13 |
+
- **Semantic Search**: Employs embeddings and vector similarity search to find the most relevant legal documents.
|
| 14 |
+
- **Interactive Web Interface**: Built with Gradio for an easy-to-use, browser-based demonstration.
|
| 15 |
+
|
| 16 |
+
---
|
| 17 |
|
| 18 |
### Getting Started
|
| 19 |
|
|
|
|
| 21 |
|
| 22 |
#### 1. Clone the Repository
|
| 23 |
|
| 24 |
+
```bash
|
|
|
|
|
|
|
| 25 |
git clone https://github.com/alexulanch/lexai-demo.git
|
| 26 |
cd lexai-demo
|
| 27 |
```
|
| 28 |
|
| 29 |
+
This project uses [Git LFS](https://git-lfs.github.com/) to manage the embedding data.
|
| 30 |
+
|
| 31 |
+
If you’re **not using the provided dev container**, install Git LFS before cloning:
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
git lfs install
|
| 35 |
+
git lfs pull
|
| 36 |
+
```
|
| 37 |
+
---
|
| 38 |
+
|
| 39 |
#### 2. Install Dependencies
|
| 40 |
|
| 41 |
+
Install the required Python packages using pip. The dependencies are: `pandas`, `numpy`, `openai`, `gradio`, `scipy`, and `python-dotenv`.
|
| 42 |
|
| 43 |
+
```bash
|
| 44 |
pip install -r requirements.txt
|
| 45 |
```
|
| 46 |
|
| 47 |
+
---
|
| 48 |
|
| 49 |
+
#### 3. Configure Your OpenAI API Key
|
| 50 |
|
| 51 |
+
This application relies on the OpenAI API. You will need an API key to access the models used for embeddings and chat completions (e.g., `text-embedding-ada-002`, `gpt-4`).
|
| 52 |
|
| 53 |
+
**Using a `.env` file (recommended for local development):**
|
| 54 |
|
| 55 |
+
1. Create a file named `.env` in the root directory of the project.
|
| 56 |
+
2. Add your API key to the file like this:
|
| 57 |
|
| 58 |
+
```dotenv
|
| 59 |
OPENAI_API_KEY="your_openai_api_key_here"
|
| 60 |
```
|
| 61 |
+
|
| 62 |
+
3. Ensure `.env` is listed in `.gitignore` to avoid committing it by mistake.
|
| 63 |
+
|
| 64 |
+
---
|
| 65 |
|
| 66 |
#### 4. Run the Application
|
| 67 |
|
| 68 |
+
Start the Gradio app:
|
| 69 |
|
| 70 |
+
```bash
|
| 71 |
python -m lexai
|
| 72 |
```
|
| 73 |
|
| 74 |
+
You’ll see a local URL like `http://127.0.0.1:7860` — open it in your browser to use LexAI Demo.
|
| 75 |
|
| 76 |
+
---
|
| 77 |
|
| 78 |
+
### Project Structure
|
| 79 |
|
| 80 |
```
|
| 81 |
lexai-demo/
|
| 82 |
+
├── .devcontainer/ # Dev container config for VS Code
|
| 83 |
│ └── devcontainer.json
|
| 84 |
+
├── lexai/ # Main Python package
|
| 85 |
│ ��── __init__.py
|
| 86 |
+
│ ├── __main__.py # Gradio app entry point
|
| 87 |
+
│ ├── config.py # Global app config and constants
|
| 88 |
│ ├── core/ # Core logic components
|
| 89 |
+
│ │ ├── data_loader.py # Loads embedding data
|
| 90 |
+
│ │ └── matcher.py # Semantic search logic
|
| 91 |
+
│ └── services/ # External API integrations
|
| 92 |
+
│ └── openai_client.py # Interacts with OpenAI API
|
| 93 |
+
├── pyproject.toml # Project metadata and build config
|
| 94 |
+
├── requirements.txt # Python dependencies
|
| 95 |
+
└── .gitignore # Files/directories Git should ignore
|
| 96 |
```
|
| 97 |
|
| 98 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
### Usage
|
| 101 |
|
| 102 |
+
1. Enter your legal question in the "Query" textbox.
|
| 103 |
+
2. Select the desired "Location" (Boulder or Denver) from the dropdown.
|
| 104 |
+
3. Click "Submit" to get an AI-generated response and relevant legal references.
|
| 105 |
+
4. Use the "Clear" button to reset.
|
| 106 |
+
5. Explore the example queries provided.
|
| 107 |
+
|
| 108 |
+
---
|
| 109 |
|
| 110 |
### Error Handling
|
| 111 |
|
| 112 |
+
The app handles several common error cases:
|
| 113 |
+
|
| 114 |
+
- `Invalid OpenAI API key...`: Check your `.env` file or environment variable setup.
|
| 115 |
+
- `OpenAI API Error...`: Rate limits, network issues, etc.
|
| 116 |
+
- `File Error...`: Missing or unreadable `.npz` embedding files.
|
| 117 |
+
- `Input Error...`: Malformed or missing user input.
|
| 118 |
|
| 119 |
+
---
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
### Contributing
|
| 122 |
|
| 123 |
+
Contributions are welcome! Open an issue or pull request with ideas or fixes.
|
| 124 |
+
|
| 125 |
+
---
|
| 126 |
|
| 127 |
### License
|
| 128 |
|
| 129 |
MIT
|
| 130 |
|
| 131 |
+
---
|
| 132 |
+
|
| 133 |
### Acknowledgements
|
| 134 |
|
| 135 |
+
- Built with [Gradio](https://gradio.app)
|
| 136 |
+
- Powered by [OpenAI](https://openai.com)
|
assets/screenshot.png
ADDED
|
Git LFS Details
|