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

Files changed (3) hide show
  1. LICENSE +21 -0
  2. README.md +71 -54
  3. 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, 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
- * AI-Powered Responses: Utilizes OpenAI's GPT models to generate natural language responses to legal queries.
10
- * Location-Specific Information: Provides legal information tailored to specific jurisdictions (currently Boulder County, Colorado, and Denver, Colorado).
11
- * Semantic Search: Employs embeddings and vector similarity search to find the most relevant legal documents.
12
- * Interactive Web Interface: Built with Gradio for an easy-to-use, browser-based demonstration.
 
 
 
 
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
- First, clone this repository to your local machine:
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
- ```shell
32
  pip install -r requirements.txt
33
  ```
34
 
35
- #### 3. Obtain and Configure OpenAI API Key
36
 
37
- This application relies on the OpenAI API. You will need an API key to use the models for embeddings and chat completions (e.g., text-embedding-ada-002, gpt-4).
38
 
39
- **Important: Never hardcode your API key directly into your code or commit it to version control!**
40
 
41
- **Using a `.env` file (for local development)**
42
 
43
- 1. Create a new file named `.env` in the **root directory** of your project (the same directory as `pyproject.toml` and `requirements.txt`).
44
- 2. Add your OpenAI API key to this file in the following format:
45
 
46
- ```
47
  OPENAI_API_KEY="your_openai_api_key_here"
48
  ```
49
- Replace `"your_openai_api_key_here"` with your actual API key. The quotes are optional but good practice if your key contains special characters.
50
- 3. **Ensure `.env` is in `.gitignore`:** The `.gitignore` file in this repository should already include `.env` to prevent it from being accidentally committed.
 
 
51
 
52
  #### 4. Run the Application
53
 
54
- Once your API key is configured, you can launch the Gradio application:
55
 
56
- ```shell
57
  python -m lexai
58
  ```
59
 
60
- The application will start, and you will see a local URL (e.g., `http://127.0.0.1:7860`) in your terminal. Open this URL in your web browser to interact with the LexAI Demo.
61
 
62
- ### Project Structure
63
 
64
- The project is organized into a clear and modular structure:
65
 
66
  ```
67
  lexai-demo/
68
- ├── .devcontainer/ # Development container configuration (for VS Code Dev Containers)
69
  │ └── devcontainer.json
70
- ├── lexai/ # Main Python package for the application
71
  │ ��── __init__.py
72
- │ ├── __main__.py # Application entry point (Gradio app)
73
- │ ├── config.py # Application-wide configuration and constants
74
  │ ├── core/ # Core logic components
75
- │ │ ├── data_loader.py # Handles loading of embedding data
76
- │ │ └── matcher.py # Logic for finding semantic matches
77
- │ └── services/ # External service integrations
78
- │ └── openai_client.py # Client for interacting with OpenAI API
79
- ├── pyproject.toml # Project metadata and build configuration (PEP 517/518)
80
- ├── requirements.txt # Python package dependencies
81
- └── .gitignore # Specifies files/directories to ignore in Git
82
  ```
83
 
84
- * `lexai/__main__.py`: This is the heart of the Gradio application, defining the UI and orchestrating the calls to core logic and services.
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. Enter your legal question in the "Query" textbox.
94
- 2. Select the desired "Location" (Boulder or Denver) from the dropdown.
95
- 3. Click the "Submit" button to get an AI-generated response and relevant legal references.
96
- 4. Use the "Clear" button to reset the input and output.
97
- 5. Explore the "Examples" provided to quickly test the application.
 
 
98
 
99
  ### Error Handling
100
 
101
- The application includes basic error handling for common issues:
 
 
 
 
 
102
 
103
- * `Invalid OpenAI API key...`: This indicates that the `OPENAI_API_KEY` environment variable is either missing, empty, or incorrect. Please double-check your `.env` file or system environment variable setup.
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. If you have suggestions for improvements or encounter issues, please open an issue or submit a pull request.
 
 
111
 
112
  ### License
113
 
114
  MIT
115
 
 
 
116
  ### Acknowledgements
117
 
118
- * Built with Gradio
119
- * Powered by OpenAI
 
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
+ ![LexAI Demo Screenshot](assets/screenshot.png)
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

  • SHA256: dd2bd4dcccaddbeffda844540cc35ad9775c36fabda0ed5afd5d0be0f856552a
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB