File size: 4,959 Bytes
939c020
 
c2ea5ed
939c020
 
 
 
 
c2ea5ed
c8243d5
b9161fb
c8243d5
1670330
c8243d5
939c020
 
c2ea5ed
 
 
 
18efc55
 
 
 
 
 
 
 
c8243d5
18efc55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c8243d5
18efc55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2ea5ed
 
 
 
 
 
18efc55
 
 
c2ea5ed
18efc55
c2ea5ed
18efc55
c2ea5ed
18efc55
 
 
 
 
c2ea5ed
18efc55
 
 
c2ea5ed
 
18efc55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c2ea5ed
 
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
---
title: AgentGraph
emoji: πŸ•ΈοΈ
colorFrom: purple
colorTo: indigo
sdk: docker
pinned: false
license: mit
app_port: 7860
hf_oauth: true
# HF automatically includes 'openid profile', we add specific scopes we need
hf_oauth_scopes:
  - read-repos
hf_oauth_expiration_minutes: 480
---

# πŸ•ΈοΈ AgentGraph

A comprehensive agent monitoring and knowledge graph extraction system for understanding AI agent behavior and decision-making processes.

## πŸš€ Quick Start

### Option 1: Automated Setup (Recommended)

The easiest way to get started is using our setup script:

```bash
# 1. Clone the repository
git clone https://huggingface.co/spaces/holistic-ai/AgentGraph
cd AgentGraph

# 2. Run the setup script
./setup.sh
```

The script will:

- Guide you through environment configuration
- Prompt for your OpenAI API key
- Choose between Docker or local development setup
- Automatically handle all dependencies and services

### Option 2: Manual Docker Setup

If you prefer manual control:

```bash
# 1. Clone and setup environment
git clone https://huggingface.co/spaces/holistic-ai/AgentGraph
cd AgentGraph
cp .env.example .env
# Edit .env and add your OpenAI API key

# 2. Build and run with Docker
docker build -t agentgraph .
docker run -d --name agentgraph-app -p 7860:7860 --env-file .env agentgraph

# 3. Access the application
open http://localhost:7860
```

### Option 3: Local Development

For development work:

```bash
# 1. Setup environment
cp .env.example .env
# Edit .env with your API keys

# 2. Quick setup (installs dependencies and starts development server)
python main.py --first-run

# Or step by step:
python main.py --setup        # Set up environment
python main.py --init-db      # Initialize database
python main.py --dev          # Start development servers
```

## πŸ”§ Configuration

### Required Environment Variables

- `OPENAI_API_KEY`: Your OpenAI API key (required for knowledge extraction)

### Optional Environment Variables

- `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY`: For AI monitoring integration
- `OPENAI_MODEL_NAME`: Model to use (default: gpt-4o-mini)
- `DB_URI`: Database connection string (default: SQLite)

See `.env.example` for all available configuration options.

## πŸ“‹ Features

- πŸ“Š **Real-time Agent Monitoring**: Track agent behavior and performance metrics
- πŸ•ΈοΈ **Knowledge Graph Extraction**: Extract and visualize knowledge graphs from agent traces
- πŸ“ˆ **Interactive Dashboards**: Comprehensive monitoring and analytics interface
- πŸ”„ **Trace Analysis**: Analyze agent execution flows and decision patterns
- 🎨 **Graph Visualization**: Beautiful interactive knowledge graph visualizations
- πŸ”¬ **Causal Analysis**: Advanced causal inference and component analysis
- πŸ§ͺ **Perturbation Testing**: Security and robustness evaluation
- πŸ”— **Platform Integration**: Connect to LangSmith, Langfuse, and other monitoring platforms

## πŸ—οΈ Architecture

AgentGraph follows a 5-stage pipeline architecture:

1. **Input Processing**: Trace upload, analysis, and chunking
2. **Knowledge Extraction**: Multi-agent CrewAI-based extraction
3. **Prompt Reconstruction**: Template extraction and context resolution
4. **Perturbation Testing**: Robustness and security evaluation
5. **Causal Analysis**: Causal inference and relationship analysis

## πŸ› οΈ Technology Stack

- **Backend**: FastAPI + Python 3.11+
- **Frontend**: React + TypeScript + Vite
- **Knowledge Extraction**: Multi-agent CrewAI system
- **Visualization**: Cytoscape, D3.js, React Force Graph
- **AI Integration**: OpenAI, LiteLLM, Langfuse, LangSmith
- **Database**: SQLAlchemy (SQLite/PostgreSQL/MySQL)
- **Deployment**: Docker, Hugging Face Spaces ready

## πŸ“– Usage

1. **Upload Traces**: Import agent execution traces in various formats
2. **Configure Processing**: Choose extraction methods and parameters
3. **Extract Knowledge**: Automatically generate knowledge graphs
4. **Analyze & Visualize**: Explore graphs, relationships, and patterns
5. **Test Robustness**: Run perturbation tests and security evaluations
6. **Causal Analysis**: Understand causal relationships and component influences

## πŸ› Troubleshooting

### Environment Variable Issues

If you see "Invalid API key" errors:

```bash
# Check your configuration
python -c "from utils.config import debug_config; debug_config()"

# Restart Docker container after updating .env
docker restart agentgraph-app
```

### Common Issues

- **Missing Dependencies**: Run `python main.py --first-run` for automatic setup
- **Port Conflicts**: Change the port with `--port 8080`
- **API Key Problems**: Ensure your `.env` file has the correct format (no quotes or extra spaces)

## 🀝 Contributing

We welcome contributions! Please see our contributing guidelines for details.

## πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

---

Built with ❀️ for AI agent research and monitoring.