File size: 8,740 Bytes
17d9814
 
 
 
 
 
 
 
 
d96419c
 
bca24d1
 
 
 
d96419c
 
 
0baad52
 
d96419c
0baad52
 
 
 
 
 
 
 
 
 
 
 
 
d96419c
 
 
0baad52
d96419c
 
 
 
0baad52
 
d96419c
 
0baad52
 
 
 
 
 
d96419c
 
0baad52
 
d96419c
 
 
 
 
 
 
 
 
 
 
0baad52
 
 
 
 
 
 
68d35e4
 
 
 
 
 
 
d96419c
 
0baad52
 
 
 
 
 
 
 
 
 
d96419c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0baad52
 
d96419c
0baad52
d96419c
0baad52
 
d96419c
68d35e4
 
 
 
 
 
 
 
 
0baad52
d96419c
0baad52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d96419c
0baad52
 
 
 
68d35e4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0baad52
d96419c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0baad52
 
 
 
 
 
68d35e4
 
 
 
 
 
d96419c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0baad52
68d35e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
title: Package Conflict Identifier
emoji: πŸ“¦
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
---

# Package Conflict Identifier πŸ“¦πŸ”

### Use "git" for accessing git and "origin" for accessing the hugging face spaces
#### git push git main , git push origin main
<br>

[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Google ADK](https://img.shields.io/badge/Google-ADK-4285F4.svg)](https://github.com/google/adk)
[![MCP Ready](https://img.shields.io/badge/MCP-Ready-green.svg)](https://modelcontextprotocol.io/)
[![Hugging Face Spaces](https://img.shields.io/badge/πŸ€—%20Hugging%20Face-Spaces-blue)](https://huggingface.co/spaces/Yash030/AI-Package-Doctor)

> **AI-powered package conflict identifier and resolver** using Google's Agent Development Kit (ADK). It leverages a multi-agent architecture with Google Gemini and OpenRouter (Grok) models to diagnose dependency issues, research solutions, and generate fixed configuration files.

<div align="center">

## πŸš€ **Try it Live!**

| **Web UI** | **MCP Server Endpoint** |
| :---: | :---: |
| [![Open in Spaces](https://huggingface.co/datasets/huggingface/badges/resolve/main/open-in-hf-spaces-sm.svg)](https://huggingface.co/spaces/Yash030/AI-Package-Doctor) | `https://yash030-ai-package-doctor.hf.space/mcp/sse` |

</div>

---

## 🎯 Features

- **πŸ€– Advanced Multi-Agent Architecture**:
  - **Context Search Agent**: Retrieves insights from past sessions using Pinecone vector memory.
  - **Parallel Research Team**: Concurrent searching of Official Docs and Community forums.
  - **Web Crawl Agent**: Uses **Firecrawl** (via OpenRouter) for deep web scraping of documentation.
  - **Code Surgeon**: Generates and validates `requirements.txt` fixes.

- **🧠 Hybrid Model Intelligence**:
  - **Google Gemini 2.0 Flash Lite**: For high-speed reasoning and orchestration.
  - **Grok 4.1 Fast (via OpenRouter)**: For specialized web crawling and context analysis.

- **πŸ”Œ Model Context Protocol (MCP) Server**:
  - Exposes the agent's capabilities as a standard MCP tool (`solve_dependency_issue`).
  - Connects seamlessly to MCP clients like Claude Desktop or other AI assistants.

- **πŸ’Ύ Persistent Memory**:
  - **Short-Term**: SQLite/PostgreSQL session storage.
  - **Long-Term**: Pinecone Vector Database for recalling past solutions.

- **πŸ› οΈ Intelligent Tooling**:
  - `retrieve_memory`: Semantic search of previous conversations.
  - `google_search`: Live web search.
  - `firecrawl`: Advanced web scraping.

## πŸ“ Project Structure

```
package_conflict_resolver/
β”œβ”€β”€ .env                  # Environment variables (API Keys)
β”œβ”€β”€ requirements.txt      # Dependencies
β”œβ”€β”€ main.py               # CLI Entry Point
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ combined_server.py # Combined ADK Web UI + MCP Server
β”‚   β”œβ”€β”€ config.py         # Configuration & Service Initialization
β”‚   β”œβ”€β”€ tools.py          # Custom Tools (Search, Memory, Validation)
β”‚   β”œβ”€β”€ agents.py         # Agent Definitions & Workflow
β”‚   └── utils.py          # Logging & Helpers
└── ...
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ combined_server.py # Combined ADK Web UI + MCP Server
β”‚   β”œβ”€β”€ config.py         # Configuration & Service Initialization
β”‚   β”œβ”€β”€ tools.py          # Custom Tools (Search, Memory, Validation)
β”‚   β”œβ”€β”€ agents.py         # Agent Definitions & Workflow
β”‚   └── utils.py          # Logging & Helpers
└── ...
```

## πŸ—οΈ Architecture

<div align="center">
  <img src="https://github.com/user-attachments/assets/ee299a66-8601-494a-a2ba-d102b036dff2" alt="Architecture Diagram" width="800"/>
  <br>
  <em>High-level architecture of the Package Conflict Identifier Agent</em>
</div>

<br>

## πŸš€ Quick Start

### 1. Clone & Install
```bash
git clone <your-repo-url>
cd package_conflict_resolver
pip install -r requirements.txt
```

### 2. Configure Environment
Create a `.env` file with your API keys:
```env
GOOGLE_API_KEY=your_gemini_key
OPENROUTER_API_KEY=your_openrouter_key
PINECONE_API_KEY=your_pinecone_key
DATABASE_URL=sqlite+aiosqlite:///legacy_solver.db
```

### 3. Run the Agent

**Option A: Combined Server (Web UI + MCP) - Recommended**
This runs both the ADK Developer UI and the MCP Server on the same port.
```bash
python -m src.combined_server
```
- **Web UI**: [http://localhost:7860/dev-ui/](http://localhost:7860/dev-ui/)
- **MCP SSE Endpoint**: [http://localhost:7860/mcp/sse](http://localhost:7860/mcp/sse)

**Option B: CLI Mode**
**Option A: Combined Server (Web UI + MCP) - Recommended**
This runs both the ADK Developer UI and the MCP Server on the same port.
```bash
python -m src.combined_server
```
- **Web UI**: [http://localhost:7860/dev-ui/](http://localhost:7860/dev-ui/)
- **MCP SSE Endpoint**: [http://localhost:7860/mcp/sse](http://localhost:7860/mcp/sse)

**Option B: CLI Mode**
```bash
python main.py
```

## πŸ”Œ MCP Server Integration

This agent is deployed as an MCP server, allowing you to use its dependency solving capabilities directly from other AI tools.

### Public Endpoint (Hugging Face Spaces)
- **SSE URL**: `https://yash030-ai-package-doctor.hf.space/mcp/sse`

### Usage with Claude Desktop
Add the following to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "AI Package Doctor": {
      "command": "",
      "url": "https://yash030-ai-package-doctor.hf.space/mcp/sse",
      "transport": "sse"
    }
  }
}
```

Once connected, you can ask Claude:
> "I have a conflict between numpy 1.26.4 and tensorflow 2.10.0. Can you help me fix it?"

Claude will use the `solve_dependency_issue` tool to analyze the problem using the full power of the agentic workflow.
## πŸ”Œ MCP Server Integration

This agent is deployed as an MCP server, allowing you to use its dependency solving capabilities directly from other AI tools.

### Public Endpoint (Hugging Face Spaces)
- **SSE URL**: `https://yash030-ai-package-doctor.hf.space/mcp/sse`

### Usage with Claude Desktop
Add the following to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "AI Package Doctor": {
      "command": "",
      "url": "https://yash030-ai-package-doctor.hf.space/mcp/sse",
      "transport": "sse"
    }
  }
}
```

Once connected, you can ask Claude:
> "I have a conflict between numpy 1.26.4 and tensorflow 2.10.0. Can you help me fix it?"

Claude will use the `solve_dependency_issue` tool to analyze the problem using the full power of the agentic workflow.

## πŸ€– Agent Workflow

1.  **Query Creator Agent**:
    - Analyzes the user's error message.
    - Uses `retrieve_memory` to check if this issue was solved before.
    - Generates search queries for the research team.

2.  **Context Search Agent**:
    - Specifically looks for relevant context in the project's long-term memory.

3.  **Parallel Research Team**:
    - **Docs Search Agent**: Searches official documentation.
    - **Community Search Agent**: Searches StackOverflow/GitHub.
    - **Web Crawl Agent**: Deep crawls specific documentation pages using Firecrawl.

4.  **Code Surgeon**:
    - Synthesizes all gathered information.
    - Generates a corrected `requirements.txt` or solution plan.

## ☁️ Deployment & Persistence

### Hugging Face Spaces
The project is configured to run on Hugging Face Spaces (Docker SDK).
- **Dockerfile**: Included in the root.
- **Port**: Exposes port `7860`.
- **Storage**: Uses `/data` directory for persistent storage (if configured with persistent volume).

### Hugging Face Spaces
The project is configured to run on Hugging Face Spaces (Docker SDK).
- **Dockerfile**: Included in the root.
- **Port**: Exposes port `7860`.
- **Storage**: Uses `/data` directory for persistent storage (if configured with persistent volume).

### Database
For production (e.g., Hugging Face Spaces), use a PostgreSQL database:
```env
DATABASE_URL=postgresql+asyncpg://user:password@host/dbname
```

### Long-Term Memory (Pinecone)
To enable persistent memory across restarts:
1.  Get a free API key from [Pinecone.io](https://www.pinecone.io).
2.  Set `PINECONE_API_KEY` in `.env`.
3.  The agent will automatically index and retrieve past sessions.

## πŸ“ License

MIT License.

## πŸ™ Credits

Built with:
- [Google Agent Development Kit (ADK)](https://github.com/google/adk)
- [Google Gemini](https://deepmind.google/technologies/gemini/)
- [OpenRouter](https://openrouter.ai/)
- [Pinecone](https://www.pinecone.io/)
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Model Context Protocol](https://modelcontextprotocol.io/)