Debopam Param
commited on
Commit
Β·
3cea541
1
Parent(s):
c6869c0
Added readme
Browse files
README.md
CHANGED
@@ -6,37 +6,366 @@ colorTo: gray
|
|
6 |
pinned: false
|
7 |
sdk: docker
|
8 |
---
|
|
|
9 |
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
##
|
15 |
|
16 |
-
|
17 |
-
- Streamlit-based user interface for customer service representatives
|
18 |
-
- FastAPI backend with SQLite database
|
19 |
-
- Deployed on Hugging Face Spaces
|
20 |
|
21 |
-
##
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
|
|
|
|
|
|
|
|
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
##
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
pinned: false
|
7 |
sdk: docker
|
8 |
---
|
9 |
+
# AI-Powered Dispute Resolution
|
10 |
|
11 |
+
[](https://github.com/DebopamParam/AI-Powered_Dispute_Resolution/actions)
|
12 |
+
[](https://github.com/DebopamParam/AI-Powered_Dispute_Resolution/releases)
|
13 |
+
[](https://github.com/DebopamParam/AI-Powered_Dispute_Resolution/blob/main/LICENSE)
|
14 |
+
[](https://www.python.org/)
|
15 |
+
[](https://fastapi.tiangolo.com/)
|
16 |
+
[](https://streamlit.io/)
|
17 |
+
[](https://langchain.com/)
|
18 |
+
[](https://ai.google.dev/)
|
19 |
+
[](https://huggingface.co/spaces)
|
20 |
|
21 |
+
## π Table of Contents
|
22 |
+
- [Overview](#overview)
|
23 |
+
- [Key Features](#key-features)
|
24 |
+
- [Architecture Overview](#architecture-overview)
|
25 |
+
- [Technologies Used](#technologies-used)
|
26 |
+
- [Prerequisites](#prerequisites)
|
27 |
+
- [Installation](#installation)
|
28 |
+
- [Configuration](#configuration)
|
29 |
+
- [Usage](#usage)
|
30 |
+
- [API Documentation](#api-documentation)
|
31 |
+
- [Testing](#testing)
|
32 |
+
- [Deployment](#deployment)
|
33 |
+
- [Contributing](#contributing)
|
34 |
+
- [License](#license)
|
35 |
+
- [Acknowledgments](#acknowledgments)
|
36 |
+
- [Contact/Support](#contactsupport)
|
37 |
+
- [Disclaimer](#disclaimer)
|
38 |
|
39 |
+
## π Overview
|
40 |
|
41 |
+
The AI-Powered Dispute Resolution system is designed to streamline the process of analyzing and resolving disputes using advanced AI technologies. This application leverages large language models to analyze dispute details, identify key issues, suggest potential solutions, and provide legal references. The system is primarily designed to operate as a standalone application on Hugging Face Spaces, combining a user-friendly Streamlit frontend with a robust FastAPI backend.
|
|
|
|
|
|
|
42 |
|
43 |
+
## β¨ Key Features
|
44 |
|
45 |
+
### AI-Powered Analysis
|
46 |
+
- **Intelligent Dispute Processing**: Analyzes dispute details using Gemini API to extract key information
|
47 |
+
- **Solution Recommendation**: Suggests potential resolutions based on similar historical cases
|
48 |
+
- **Legal Reference Integration**: Provides relevant legal references and precedents
|
49 |
+
- **Continuous Learning**: System improves over time by incorporating feedback from resolved cases
|
50 |
|
51 |
+
### Frontend Capabilities
|
52 |
+
- **Intuitive Interface**: User-friendly Streamlit interface for submitting and tracking disputes
|
53 |
+
- **Dashboard**: Real-time visualization of dispute status and analytics
|
54 |
+
- **Document Upload**: Support for uploading relevant documents in various formats
|
55 |
+
- **Explainable AI**: Clear explanations of how the AI reached its conclusions
|
56 |
|
57 |
+
### Backend Robustness
|
58 |
+
- **Secure API**: FastAPI backend ensuring secure data processing
|
59 |
+
- **Efficient Data Management**: Optimized database schema for quick retrieval and analysis
|
60 |
+
- **Scalable Architecture**: Designed to handle increasing volumes of disputes
|
61 |
+
- **Comprehensive Logging**: Detailed activity logs for auditing purposes
|
62 |
|
63 |
+
### Deployment Strategy
|
64 |
+
- **Hugging Face Integration**: Seamless deployment on Hugging Face Spaces
|
65 |
+
- **Single Container Solution**: Entire application packaged in a single Docker container
|
66 |
+
- **Environment Variable Configuration**: Easy configuration through environment variables
|
67 |
|
68 |
+
## ποΈ Architecture Overview
|
69 |
|
70 |
+
### High-Level System Diagram
|
71 |
+
|
72 |
+
```mermaid
|
73 |
+
graph TD
|
74 |
+
A[User] -->|Submits Dispute| B[Streamlit Frontend]
|
75 |
+
B -->|API Request| C[FastAPI Backend]
|
76 |
+
C -->|Query| D[Database]
|
77 |
+
C -->|Analysis Request| E[Gemini API]
|
78 |
+
E -->|Analysis Results| C
|
79 |
+
C -->|Response| B
|
80 |
+
B -->|Display Results| A
|
81 |
+
style A fill:#f9f,stroke:#333,stroke-width:2px
|
82 |
+
style B fill:#bbf,stroke:#333,stroke-width:2px
|
83 |
+
style C fill:#bfb,stroke:#333,stroke-width:2px
|
84 |
+
style D fill:#fbb,stroke:#333,stroke-width:2px
|
85 |
+
style E fill:#bff,stroke:#333,stroke-width:2px
|
86 |
+
```
|
87 |
+
|
88 |
+
The diagram above illustrates the flow of data through the system, from user input to AI analysis and result presentation.
|
89 |
+
|
90 |
+
### Component Interaction Diagram
|
91 |
+
|
92 |
+
```mermaid
|
93 |
+
sequenceDiagram
|
94 |
+
participant User
|
95 |
+
participant Frontend as Streamlit Frontend
|
96 |
+
participant Backend as FastAPI Backend
|
97 |
+
participant DB as Database
|
98 |
+
participant AI as Gemini API
|
99 |
+
|
100 |
+
User->>Frontend: Submit dispute details
|
101 |
+
Frontend->>Backend: POST /api/disputes
|
102 |
+
Backend->>DB: Store dispute data
|
103 |
+
Backend->>AI: Request analysis
|
104 |
+
AI->>Backend: Return analysis results
|
105 |
+
Backend->>DB: Update with analysis
|
106 |
+
Backend->>Frontend: Return dispute ID & status
|
107 |
+
Frontend->>User: Display confirmation
|
108 |
+
User->>Frontend: View analysis results
|
109 |
+
Frontend->>Backend: GET /api/disputes/{id}
|
110 |
+
Backend->>DB: Retrieve dispute data
|
111 |
+
DB->>Backend: Return dispute data
|
112 |
+
Backend->>Frontend: Return complete dispute info
|
113 |
+
Frontend->>User: Display analysis results
|
114 |
+
```
|
115 |
+
|
116 |
+
This sequence diagram shows the typical flow when a user submits a dispute for analysis.
|
117 |
+
|
118 |
+
### Deployment Architecture Diagram
|
119 |
+
|
120 |
+
```mermaid
|
121 |
+
graph TD
|
122 |
+
A[Hugging Face Space] -->|Container| B[Docker Container]
|
123 |
+
B -->|Port 8000| C[FastAPI Backend]
|
124 |
+
B -->|Port 8501| D[Streamlit Frontend]
|
125 |
+
C -->|Internal Communication| D
|
126 |
+
C -->|Database| E[SQLite]
|
127 |
+
style A fill:#f9f,stroke:#333,stroke-width:2px
|
128 |
+
style B fill:#bbf,stroke:#333,stroke-width:2px
|
129 |
+
style C fill:#bfb,stroke:#333,stroke-width:2px
|
130 |
+
style D fill:#fbb,stroke:#333,stroke-width:2px
|
131 |
+
style E fill:#bff,stroke:#333,stroke-width:2px
|
132 |
+
```
|
133 |
+
|
134 |
+
The deployment architecture shows how the application is packaged in a single Docker container for deployment on Hugging Face Spaces.
|
135 |
+
|
136 |
+
### Database Schema Diagram
|
137 |
+
|
138 |
+
```mermaid
|
139 |
+
erDiagram
|
140 |
+
DISPUTES {
|
141 |
+
string id PK
|
142 |
+
string title
|
143 |
+
string description
|
144 |
+
datetime created_at
|
145 |
+
string status
|
146 |
+
string user_id FK
|
147 |
+
}
|
148 |
+
ANALYSIS {
|
149 |
+
string id PK
|
150 |
+
string dispute_id FK
|
151 |
+
string key_issues
|
152 |
+
string suggested_solutions
|
153 |
+
string legal_references
|
154 |
+
datetime created_at
|
155 |
+
}
|
156 |
+
USERS {
|
157 |
+
string id PK
|
158 |
+
string username
|
159 |
+
string email
|
160 |
+
datetime created_at
|
161 |
+
}
|
162 |
+
FEEDBACK {
|
163 |
+
string id PK
|
164 |
+
string analysis_id FK
|
165 |
+
int rating
|
166 |
+
string comments
|
167 |
+
datetime created_at
|
168 |
+
}
|
169 |
+
DISPUTES ||--o{ ANALYSIS : has
|
170 |
+
USERS ||--o{ DISPUTES : submits
|
171 |
+
ANALYSIS ||--o{ FEEDBACK : receives
|
172 |
+
```
|
173 |
+
|
174 |
+
This ER diagram shows the database structure used to store dispute information, analysis results, user data, and feedback.
|
175 |
+
|
176 |
+
### User Flow Diagram
|
177 |
+
|
178 |
+
```mermaid
|
179 |
+
graph TD
|
180 |
+
A[Start] --> B[Create Account/Login]
|
181 |
+
B --> C[Submit New Dispute]
|
182 |
+
C --> D[Upload Supporting Documents]
|
183 |
+
D --> E[View Initial AI Analysis]
|
184 |
+
E --> F{Satisfied with Analysis?}
|
185 |
+
F -->|Yes| G[Accept Recommendations]
|
186 |
+
F -->|No| H[Request Detailed Analysis]
|
187 |
+
H --> I[Review Detailed Analysis]
|
188 |
+
I --> J{Accept Solution?}
|
189 |
+
J -->|Yes| K[Implement Solution]
|
190 |
+
J -->|No| L[Provide Feedback]
|
191 |
+
L --> M[Receive Refined Analysis]
|
192 |
+
M --> J
|
193 |
+
G --> N[Provide Feedback on Process]
|
194 |
+
K --> N
|
195 |
+
N --> O[End]
|
196 |
+
style A fill:#f9f,stroke:#333,stroke-width:2px
|
197 |
+
style F fill:#bbf,stroke:#333,stroke-width:2px
|
198 |
+
style J fill:#bbf,stroke:#333,stroke-width:2px
|
199 |
+
style O fill:#f9f,stroke:#333,stroke-width:2px
|
200 |
+
```
|
201 |
+
|
202 |
+
This diagram illustrates the typical user journey through the dispute resolution process.
|
203 |
+
|
204 |
+
## π οΈ Technologies Used
|
205 |
+
|
206 |
+
- [Python 3.9+](https://www.python.org/) - Programming language
|
207 |
+
- [FastAPI](https://fastapi.tiangolo.com/) - Backend API framework
|
208 |
+
- [Streamlit](https://streamlit.io/) - Frontend framework
|
209 |
+
- [LangChain](https://langchain.com/) - AI integration framework
|
210 |
+
- [Gemini API](https://ai.google.dev/) - AI language model
|
211 |
+
- [SQLite](https://www.sqlite.org/) - Database
|
212 |
+
- [Docker](https://www.docker.com/) - Containerization
|
213 |
+
- [Hugging Face Spaces](https://huggingface.co/spaces) - Deployment platform
|
214 |
+
|
215 |
+
## π Prerequisites
|
216 |
+
|
217 |
+
To run this application, you need:
|
218 |
+
|
219 |
+
- Python 3.9 or higher
|
220 |
+
- Docker and Docker Compose
|
221 |
+
- Gemini API key
|
222 |
+
- Hugging Face account (for deployment)
|
223 |
+
|
224 |
+
## π§ Installation
|
225 |
+
|
226 |
+
1. Clone the repository:
|
227 |
+
```bash
|
228 |
+
git clone https://github.com/DebopamParam/AI-Powered_Dispute_Resolution.git
|
229 |
+
cd AI-Powered_Dispute_Resolution
|
230 |
+
```
|
231 |
+
|
232 |
+
2. Create a `.env` file in the root directory with the following variables:
|
233 |
+
```
|
234 |
+
GEMINI_API_KEY=your_gemini_api_key
|
235 |
+
DATABASE_URL=sqlite:///./app.db
|
236 |
+
DEBUG=False
|
237 |
+
```
|
238 |
+
|
239 |
+
3. Build the Docker image:
|
240 |
+
```bash
|
241 |
+
docker build -t dispute-resolution-app .
|
242 |
+
```
|
243 |
+
|
244 |
+
## βοΈ Configuration
|
245 |
+
|
246 |
+
### Environment Variables
|
247 |
+
|
248 |
+
The application can be configured using the following environment variables:
|
249 |
+
|
250 |
+
- `GEMINI_API_KEY` - Your Gemini API key
|
251 |
+
- `DATABASE_URL` - Database connection string (defaults to SQLite)
|
252 |
+
- `DEBUG` - Enable debug mode (True/False)
|
253 |
+
- `LOG_LEVEL` - Logging level (INFO, DEBUG, ERROR)
|
254 |
+
- `MAX_UPLOAD_SIZE` - Maximum file upload size in MB
|
255 |
+
|
256 |
+
### Optional Configuration Files
|
257 |
+
|
258 |
+
You can also create the following configuration files:
|
259 |
+
|
260 |
+
- `config/app_config.json` - Application-specific settings
|
261 |
+
- `config/model_config.json` - AI model parameters
|
262 |
+
|
263 |
+
## π Usage
|
264 |
+
|
265 |
+
### Running Locally
|
266 |
+
|
267 |
+
1. Start the application using Docker Compose:
|
268 |
+
```bash
|
269 |
+
docker-compose up
|
270 |
+
```
|
271 |
+
|
272 |
+
2. Navigate to http://localhost:8501 in your web browser
|
273 |
+
|
274 |
+
### Quickstart Guide
|
275 |
+
|
276 |
+
1. Create an account or log in
|
277 |
+
2. Click on "Create New Dispute"
|
278 |
+
3. Fill in the dispute details:
|
279 |
+
- Title
|
280 |
+
- Description
|
281 |
+
- Parties involved
|
282 |
+
- Relevant dates
|
283 |
+
4. Upload any supporting documents
|
284 |
+
5. Click "Submit for Analysis"
|
285 |
+
6. Wait for the AI to analyze the dispute
|
286 |
+
7. Review the analysis results, which include:
|
287 |
+
- Key issues identified
|
288 |
+
- Suggested solutions
|
289 |
+
- Legal references
|
290 |
+
8. Provide feedback on the analysis
|
291 |
+
9. Implement the recommended solutions
|
292 |
+
|
293 |
+
## π API Documentation
|
294 |
+
|
295 |
+
The API documentation is automatically generated and available at `/docs` when running the application. It provides:
|
296 |
+
|
297 |
+
- Complete list of endpoints
|
298 |
+
- Request and response schemas
|
299 |
+
- Authentication requirements
|
300 |
+
- Example requests
|
301 |
+
- Interactive testing capabilities
|
302 |
+
|
303 |
+
## π§ͺ Testing
|
304 |
+
|
305 |
+
To run the tests:
|
306 |
+
|
307 |
+
```bash
|
308 |
+
# Run all tests
|
309 |
+
python -m pytest
|
310 |
+
|
311 |
+
# Run specific test file
|
312 |
+
python -m pytest tests/test_api.py
|
313 |
+
|
314 |
+
# Run with coverage report
|
315 |
+
python -m pytest --cov=app tests/
|
316 |
+
```
|
317 |
+
|
318 |
+
## π Deployment
|
319 |
+
|
320 |
+
### Deploying to Hugging Face Spaces
|
321 |
+
|
322 |
+
1. Fork this repository
|
323 |
+
2. Create a new Space on Hugging Face:
|
324 |
+
- Type: Docker
|
325 |
+
- Repository: Your forked repository
|
326 |
+
3. Add the following secrets to your Space:
|
327 |
+
- `GEMINI_API_KEY` - Your Gemini API key
|
328 |
+
4. The Space will automatically build and deploy the application
|
329 |
+
|
330 |
+
### Deploying Locally with Docker Compose
|
331 |
+
|
332 |
+
1. Make sure Docker and Docker Compose are installed
|
333 |
+
2. Create the `.env` file as described in the Installation section
|
334 |
+
3. Run the following command:
|
335 |
+
```bash
|
336 |
+
docker-compose up -d
|
337 |
+
```
|
338 |
+
4. Access the application at http://localhost:8501
|
339 |
+
|
340 |
+
## π€ Contributing
|
341 |
+
|
342 |
+
Contributions are welcome! Please follow these steps:
|
343 |
+
|
344 |
+
1. Fork the repository
|
345 |
+
2. Create a new branch (`git checkout -b feature/amazing-feature`)
|
346 |
+
3. Make your changes
|
347 |
+
4. Commit your changes (`git commit -m 'Add some amazing feature'`)
|
348 |
+
5. Push to the branch (`git push origin feature/amazing-feature`)
|
349 |
+
6. Open a Pull Request
|
350 |
+
|
351 |
+
Please make sure your code follows the project's coding standards and includes appropriate tests.
|
352 |
+
|
353 |
+
## π License
|
354 |
+
|
355 |
+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/DebopamParam/AI-Powered_Dispute_Resolution/blob/main/LICENSE) file for details.
|
356 |
+
|
357 |
+
## π Acknowledgments
|
358 |
+
|
359 |
+
- [FastAPI](https://fastapi.tiangolo.com/) for the efficient API framework
|
360 |
+
- [Streamlit](https://streamlit.io/) for the intuitive frontend framework
|
361 |
+
- [LangChain](https://langchain.com/) for simplifying AI integration
|
362 |
+
- [Gemini API](https://ai.google.dev/) for the powerful language model
|
363 |
+
- [Hugging Face Spaces](https://huggingface.co/spaces) for the deployment platform
|
364 |
+
|
365 |
+
## π Contact/Support
|
366 |
+
|
367 |
+
- For bug reports and feature requests, please [open an issue](https://github.com/DebopamParam/AI-Powered_Dispute_Resolution/issues)
|
368 |
+
|
369 |
+
## β οΈ Disclaimer
|
370 |
+
|
371 |
+
This project is a prototype and should be used with caution. The AI-generated recommendations should not be considered legal advice. Always consult with a qualified legal professional for legal matters.
|