File size: 3,880 Bytes
f846157
1fb5c33
 
 
f846157
1fb5c33
f846157
 
1fb5c33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
title: AI Agent Workspace
colorFrom: purple
colorTo: blue
sdk: docker
app_port: 7860
---

<p align="center">
  <h1>πŸ€– AI Agent Workspace</h1>
  <p><i>A customizable autonomous AI agent for research, coding, and ML workflows</i></p>
</p>

---

## What This Is

A fork of the [ML Intern](https://hf.co/spaces/smolagents/ml-intern) architecture β€” an autonomous AI agent that researches, writes code, and ships projects using the Hugging Face ecosystem.

**Key capabilities:**
- πŸ”¬ **Research** β€” Search papers, datasets, models, and documentation
- πŸ’» **Code** β€” Write, test, and execute Python scripts in sandboxes
- πŸš€ **Deploy** β€” Launch training jobs, manage repos, push to Hub
- πŸ“š **Learn** β€” Read documentation and GitHub repos to understand APIs

## Architecture

```
User (Web UI / CLI)
    ↕
FastAPI Backend (SSE events)
    ↕
Agent Loop (LiteLLM + tool router)
    ↕
Tools: HF docs | Papers | Datasets | GitHub | Jobs | Sandbox | MCP
```

**Stack:**
- **Frontend:** React + Vite + TypeScript
- **Backend:** FastAPI + SSE streaming
- **Agent:** LiteLLM (multi-provider) + custom tool system
- **Tools:** Hugging Face APIs, GitHub, sandbox execution, MCP servers

## Quick Start

### Local CLI

```bash
git clone https://huggingface.co/spaces/ScottzillaSystems/ml-intern-custom
cd ml-intern-custom

# Install dependencies (requires Python 3.11+, uv)
uv sync

# Run interactive mode
python -m agent.main

# Or headless
python -m agent.main "your task here"
```

### Environment Variables

Create `.env`:
```bash
# Required
HF_TOKEN=hf_...                    # Hugging Face token

# Optional - for non-HF-router models
ANTHROPIC_API_KEY=sk-ant-...       # Claude models
OPENAI_API_KEY=sk-...              # OpenAI models
GITHUB_TOKEN=ghp_...               # GitHub code search
```

### Web UI

The Space runs the web UI automatically. For local dev:
```bash
cd frontend && npm install && npm run dev   # Vite dev server
cd backend && python main.py                 # FastAPI backend
```

## Customization Guide

### 1. Change the Model

Edit `configs/frontend_agent_config.json` or `configs/cli_agent_config.json`:

```json
{
  "model_name": "moonshotai/Kimi-K2.6",
  "mcpServers": { ... }
}
```

**Available models via HF Router (free tier):**
- `moonshotai/Kimi-K2.6`
- `MiniMaxAI/MiniMax-M2.7`
- `zai-org/GLM-5.1`

**Or any LiteLLM-compatible model:**
- `anthropic/claude-sonnet-4-5-20250929`
- `openai/gpt-4o`
- `google/gemini-2.5-pro`

### 2. Add/Remove Tools

Edit `agent/core/tools.py`:

```python
def create_builtin_tools(local_mode=False):
    tools = [
        # Your custom tools here
        ToolSpec(name="my_tool", ...),
        # ... existing tools
    ]
    return tools
```

### 3. Add MCP Servers

Edit `configs/frontend_agent_config.json`:

```json
{
  "mcpServers": {
    "my-server": {
      "transport": "http",
      "url": "https://my-mcp-server.com/mcp",
      "headers": { "Authorization": "Bearer ${MY_TOKEN}" }
    }
  }
}
```

### 4. Customize System Prompt

Edit `agent/prompts/system_prompt.yaml` to change the agent's personality and instructions.

### 5. Change Branding

- Frontend: Edit `frontend/src/theme.ts` for colors
- Frontend: Edit `frontend/src/components/WelcomeScreen/WelcomeScreen.tsx` for welcome text
- Backend: Edit `backend/main.py` for API metadata

## Project Structure

```
agent/
  core/           # Agent loop, session, context manager
  tools/          # Tool implementations (HF, GitHub, sandbox, etc.)
  prompts/        # System prompts
  main.py         # CLI entry point
backend/
  main.py         # FastAPI app
  routes/         # API endpoints
  session_manager.py
frontend/
  src/            # React components
configs/
  frontend_agent_config.json
  cli_agent_config.json
```

## Original

Based on [smolagents/ml-intern](https://hf.co/spaces/smolagents/ml-intern) by Hugging Face.