Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,13 +1,157 @@
|
|
| 1 |
---
|
| 2 |
-
title: Problem
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
colorTo: indigo
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 6.14.0
|
| 8 |
-
python_version: '3.13'
|
| 9 |
-
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Intern Problem Solver API
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: blue
|
| 5 |
colorTo: indigo
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
+
app_port: 7860
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Intern Problem-Solving API
|
| 12 |
+
|
| 13 |
+
A multi-agent FastAPI backend that helps interns understand real-world problems and build structured thinking. Five specialized agents run in sequence β each feeding context to the next β to deliver a complete analysis with actionable next steps.
|
| 14 |
+
|
| 15 |
+
## Agent Pipeline
|
| 16 |
+
|
| 17 |
+
```
|
| 18 |
+
Input β [1] Problem Analyst β [2] Root Cause β [3] Solutions β [4] Action Plan β [5] Thinking Coach
|
| 19 |
+
```
|
| 20 |
+
|
| 21 |
+
| Agent | Job |
|
| 22 |
+
|-------|-----|
|
| 23 |
+
| Problem Analyst | Identifies core problem, stakeholders, known vs unknown |
|
| 24 |
+
| Root Cause Analyst | Breaks down WHY the problem exists across technical, process, and people dimensions |
|
| 25 |
+
| Solution Brainstorm | Generates 7 diverse ideas β quick wins, medium-term, strategic, and unconventional |
|
| 26 |
+
| Action Planner | 3 concrete next steps the intern can start immediately |
|
| 27 |
+
| Thinking Coach | Honest feedback on the intern's framing β are they a problem solver or task executor? |
|
| 28 |
+
|
| 29 |
+
---
|
| 30 |
+
|
| 31 |
+
## Endpoints
|
| 32 |
+
|
| 33 |
+
| Method | Endpoint | Returns |
|
| 34 |
+
|--------|----------|---------|
|
| 35 |
+
| `GET` | `/` | API info and endpoint list |
|
| 36 |
+
| `GET` | `/health` | Health check |
|
| 37 |
+
| `POST` | `/analyze` | Full analysis as JSON |
|
| 38 |
+
| `POST` | `/analyze/stream` | Server-sent events β streams each agent live |
|
| 39 |
+
| `POST` | `/analyze/pdf` | Downloadable PDF report |
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## Request Body
|
| 44 |
+
|
| 45 |
+
All three `POST` endpoints accept the same JSON body:
|
| 46 |
+
|
| 47 |
+
```json
|
| 48 |
+
{
|
| 49 |
+
"content": "Paste your problem, transcript, or blocker here",
|
| 50 |
+
"intern_name": "Your Name",
|
| 51 |
+
"intern_role": "AI Developer Intern",
|
| 52 |
+
"intern_goal": "What you are trying to achieve this week"
|
| 53 |
+
}
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
| Field | Required | Default |
|
| 57 |
+
|-------|----------|---------|
|
| 58 |
+
| `content` | β
Yes | β |
|
| 59 |
+
| `intern_name` | No | `"Intern"` |
|
| 60 |
+
| `intern_role` | No | `"AI Developer Intern"` |
|
| 61 |
+
| `intern_goal` | No | `""` |
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## Response β `/analyze`
|
| 66 |
+
|
| 67 |
+
```json
|
| 68 |
+
{
|
| 69 |
+
"problem_statement": "## Core Problem\n...",
|
| 70 |
+
"root_causes": "## Root Cause Analysis\n...",
|
| 71 |
+
"solutions": "## Solution Ideas\n...",
|
| 72 |
+
"action_plan": "## Your Next Steps\n...",
|
| 73 |
+
"thinking_feedback": "## Thinking Feedback\n..."
|
| 74 |
+
}
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## Response β `/analyze/stream`
|
| 80 |
+
|
| 81 |
+
Server-sent events. Each event is a JSON object on a `data:` line:
|
| 82 |
+
|
| 83 |
+
```
|
| 84 |
+
data: {"event": "agent_start", "agent": "analyst", "label": "Problem Analyst"}
|
| 85 |
+
|
| 86 |
+
data: {"event": "token", "agent": "analyst", "text": "## Core Problem\n"}
|
| 87 |
+
|
| 88 |
+
data: {"event": "agent_done", "agent": "analyst"}
|
| 89 |
+
|
| 90 |
+
data: {"event": "done"}
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
Event types:
|
| 94 |
+
|
| 95 |
+
| Event | Fields | Meaning |
|
| 96 |
+
|-------|--------|---------|
|
| 97 |
+
| `agent_start` | `agent`, `label` | Agent has started running |
|
| 98 |
+
| `token` | `agent`, `text` | Next streamed token from this agent |
|
| 99 |
+
| `agent_done` | `agent` | Agent finished |
|
| 100 |
+
| `done` | β | All 5 agents complete |
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## Setup
|
| 105 |
+
|
| 106 |
+
### Environment Variable
|
| 107 |
+
|
| 108 |
+
Set this as a **Secret** in your HuggingFace Space settings:
|
| 109 |
+
|
| 110 |
+
```
|
| 111 |
+
ANTHROPIC_API_KEY=sk-ant-...
|
| 112 |
+
```
|
| 113 |
+
|
| 114 |
+
Do not put it in the Dockerfile or commit it to the repo.
|
| 115 |
+
|
| 116 |
+
### Files Required
|
| 117 |
+
|
| 118 |
+
```
|
| 119 |
+
main.py
|
| 120 |
+
requirements.txt
|
| 121 |
+
Dockerfile
|
| 122 |
+
README.md
|
| 123 |
+
```
|
| 124 |
+
|
| 125 |
+
---
|
| 126 |
+
|
| 127 |
+
## Local Development
|
| 128 |
+
|
| 129 |
+
```bash
|
| 130 |
+
# Install dependencies
|
| 131 |
+
pip install -r requirements.txt
|
| 132 |
+
|
| 133 |
+
# Run with your API key
|
| 134 |
+
ANTHROPIC_API_KEY=sk-ant-... uvicorn main:app --reload --port 7860
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
API docs available at `http://localhost:7860/docs` once running.
|
| 138 |
+
|
| 139 |
+
---
|
| 140 |
+
|
| 141 |
+
## Client
|
| 142 |
+
|
| 143 |
+
The frontend (`client.html`) is a standalone HTML file β no build step, no framework. Host it anywhere: a second HF Space (static SDK), GitHub Pages, or just open it locally in a browser.
|
| 144 |
+
|
| 145 |
+
Point the **Backend API URL** field in the client to this Space's URL:
|
| 146 |
+
```
|
| 147 |
+
https://your-username-intern-problem-solver.hf.space
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
---
|
| 151 |
+
|
| 152 |
+
## Stack
|
| 153 |
+
|
| 154 |
+
- **FastAPI** β API framework
|
| 155 |
+
- **Anthropic SDK** β claude-sonnet-4-6 for all agents
|
| 156 |
+
- **ReportLab** β PDF generation
|
| 157 |
+
- **Uvicorn** β ASGI server
|