File size: 8,099 Bytes
a9dc537
6f224d0
 
7df4e24
 
 
6f224d0
 
 
a9dc537
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<<<<<<< HEAD
---
title: SPARKNET
sdk: streamlit
app_file: demo/app.py
python_version: "3.10"
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
=======
# SPARKNET: Agentic AI Workflow System

Multi-agent orchestration system leveraging local LLM models via Ollama with multi-GPU support.

## Overview

SPARKNET is an autonomous AI agent framework that enables:
- **Multi-Agent Orchestration**: Specialized agents for planning, execution, and validation
- **Local LLM Integration**: Uses Ollama for privacy-preserving AI inference
- **Multi-GPU Support**: Efficiently utilizes 4x NVIDIA RTX 2080 Ti GPUs
- **Tool-Augmented Agents**: Agents can use tools for file I/O, code execution, and system monitoring
- **Memory Management**: Vector-based episodic and semantic memory
- **Learning & Adaptation**: Feedback loops for continuous improvement

## System Requirements

### Hardware
- NVIDIA GPUs with CUDA support (tested on 4x RTX 2080 Ti, 11GB VRAM each)
- Minimum 16GB RAM
- 50GB+ free disk space

### Software
- Python 3.10+
- CUDA 12.0+
- Ollama installed and running

## Installation

### 1. Install Ollama
```bash
# Install Ollama (if not already installed)
curl -fsSL https://ollama.com/install.sh | sh

# Start Ollama server
ollama serve
```

### 2. Install SPARKNET
```bash
cd /home/mhamdan/SPARKNET

# Install dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .
```

### 3. Download Recommended Models
```bash
# Lightweight models
ollama pull llama3.2:latest
ollama pull phi3:latest

# General purpose models
ollama pull llama3.1:8b
ollama pull mistral:latest

# Large reasoning model
ollama pull qwen2.5:14b

# Embedding models
ollama pull nomic-embed-text:latest
ollama pull mxbai-embed-large:latest
```

## Quick Start

### Basic Usage

```python
from src.llm.ollama_client import OllamaClient
from src.agents.executor_agent import ExecutorAgent
from src.agents.base_agent import Task
from src.tools import register_default_tools
import asyncio

# Initialize
ollama_client = OllamaClient()
tool_registry = register_default_tools()

# Create agent
agent = ExecutorAgent(llm_client=ollama_client)
agent.set_tool_registry(tool_registry)

# Create and execute task
task = Task(
    id="task_1",
    description="List all Python files in the current directory",
)

async def run():
    result = await agent.process_task(task)
    print(f"Status: {result.status}")
    print(f"Result: {result.result}")

asyncio.run(run())
```

### Running Examples

```bash
# Simple agent with tool usage
python examples/simple_task.py

# Multi-agent collaboration
python examples/multi_agent_collab.py

# GPU monitoring
python examples/gpu_monitor.py

# Patent Wake-Up workflow (VISTA Scenario 1)
python test_patent_wakeup.py
```

## Patent Wake-Up Workflow (Phase 2C)

SPARKNET now includes a complete **Patent Wake-Up workflow** for VISTA Scenario 1, which transforms dormant patents into commercialization opportunities.

### Quick Start

```bash
# 1. Ensure required models are available
ollama pull llama3.1:8b
ollama pull mistral:latest
ollama pull qwen2.5:14b

# 2. Run the Patent Wake-Up workflow
python test_patent_wakeup.py
```

### Workflow Steps

The Patent Wake-Up pipeline executes four specialized agents sequentially:

1. **DocumentAnalysisAgent** - Analyzes patent structure and assesses Technology Readiness Level (TRL)
2. **MarketAnalysisAgent** - Identifies market opportunities with size/growth data
3. **MatchmakingAgent** - Matches with potential partners using semantic search
4. **OutreachAgent** - Generates professional valorization briefs (PDF format)

### Example Output

```
Patent: AI-Powered Drug Discovery Platform
TRL Level: 7/9
Market Opportunities: 4 identified ($150B+ addressable market)
Stakeholder Matches: 10 partners (investors, companies, universities)
Output: outputs/valorization_brief_[patent_id]_[date].pdf
```

### Specialized Agents

| Agent | Purpose | Model | Output |
|-------|---------|-------|--------|
| DocumentAnalysisAgent | Patent extraction & TRL assessment | llama3.1:8b | PatentAnalysis object |
| MarketAnalysisAgent | Market opportunity identification | mistral:latest | MarketAnalysis object |
| MatchmakingAgent | Stakeholder matching with scoring | qwen2.5:14b | List of StakeholderMatch |
| OutreachAgent | Valorization brief generation | llama3.1:8b | ValorizationBrief + PDF |

See `PHASE_2C_COMPLETE_SUMMARY.md` for full implementation details.

## Architecture

### Core Components

1. **Agents** (`src/agents/`)
   - `BaseAgent`: Core agent interface
   - `ExecutorAgent`: Task execution with tools
   - `PlannerAgent`: Task decomposition (coming soon)
   - `CriticAgent`: Output validation (coming soon)

2. **LLM Integration** (`src/llm/`)
   - `OllamaClient`: Interface to local Ollama models
   - Model routing based on task complexity

3. **Tools** (`src/tools/`)
   - File operations: read, write, search
   - Code execution: Python, bash
   - GPU monitoring and selection

4. **Utilities** (`src/utils/`)
   - GPU manager for resource allocation
   - Logging and configuration
   - Memory management

### Configuration

Configuration files in `configs/`:
- `system.yaml`: System-wide settings
- `models.yaml`: Model routing rules
- `agents.yaml`: Agent configurations

## Available Models

| Model | Size | Use Case |
|-------|------|----------|
| llama3.2:latest | 2.0 GB | Classification, routing, simple QA |
| phi3:latest | 2.2 GB | Quick reasoning, structured output |
| mistral:latest | 4.4 GB | General tasks, creative writing |
| llama3.1:8b | 4.9 GB | General tasks, code generation |
| qwen2.5:14b | 9.0 GB | Complex reasoning, multi-step tasks |
| nomic-embed-text | 274 MB | Text embeddings, semantic search |
| mxbai-embed-large | 669 MB | High-quality embeddings, RAG |

## GPU Management

SPARKNET automatically manages GPU resources:

```python
from src.utils.gpu_manager import get_gpu_manager

gpu_manager = get_gpu_manager()

# Monitor all GPUs
print(gpu_manager.monitor())

# Select best GPU with 8GB+ free
with gpu_manager.gpu_context(min_memory_gb=8.0) as gpu_id:
    # Your model code here
    print(f"Using GPU {gpu_id}")
```

## Development

### Project Structure
```
SPARKNET/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agents/         # Agent implementations
β”‚   β”œβ”€β”€ llm/           # LLM client and routing
β”‚   β”œβ”€β”€ workflow/      # Task orchestration (coming soon)
β”‚   β”œβ”€β”€ memory/        # Memory systems (coming soon)
β”‚   β”œβ”€β”€ tools/         # Agent tools
β”‚   └── utils/         # Utilities
β”œβ”€β”€ configs/           # Configuration files
β”œβ”€β”€ examples/          # Example scripts
β”œβ”€β”€ tests/            # Unit tests
└── Dataset/          # Data directory

```

### Running Tests
```bash
pytest tests/
```

### Code Formatting
```bash
black src/
flake8 src/
```

## Roadmap

### Phase 1: Foundation βœ…
- [x] Project structure
- [x] GPU manager
- [x] Ollama client
- [x] Base agent
- [x] Basic tools
- [x] Configuration system

### Phase 2: Multi-Agent System (In Progress)
- [x] ExecutorAgent
- [ ] PlannerAgent
- [ ] CriticAgent
- [ ] MemoryAgent
- [ ] CoordinatorAgent
- [ ] Agent communication protocol

### Phase 3: Advanced Features
- [ ] Vector-based memory (ChromaDB)
- [ ] Learning and feedback mechanisms
- [ ] Model router
- [ ] Workflow engine
- [ ] Monitoring dashboard

### Phase 4: Optimization
- [ ] Multi-GPU parallelization
- [ ] Performance optimization
- [ ] Comprehensive testing
- [ ] Documentation

## Contributing

Contributions are welcome! Please:
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests
5. Submit a pull request

## License

MIT License - see LICENSE file for details

## Acknowledgments

- Ollama for local LLM inference
- NVIDIA for CUDA and GPU support
- The open-source AI community

## Support

For issues and questions:
- GitHub Issues: [Your repo URL]
- Documentation: [Docs URL]

---

Built with ❀️ for autonomous AI systems
>>>>>>> e692211 (Initial commit: SPARKNET framework)