hedit 0.6.1a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hedit-0.6.1a0/PKG-INFO +279 -0
- hedit-0.6.1a0/README.md +232 -0
- hedit-0.6.1a0/hedit.egg-info/PKG-INFO +279 -0
- hedit-0.6.1a0/hedit.egg-info/SOURCES.txt +59 -0
- hedit-0.6.1a0/hedit.egg-info/dependency_links.txt +1 -0
- hedit-0.6.1a0/hedit.egg-info/entry_points.txt +2 -0
- hedit-0.6.1a0/hedit.egg-info/requires.txt +27 -0
- hedit-0.6.1a0/hedit.egg-info/top_level.txt +1 -0
- hedit-0.6.1a0/pyproject.toml +129 -0
- hedit-0.6.1a0/setup.cfg +4 -0
- hedit-0.6.1a0/src/__init__.py +5 -0
- hedit-0.6.1a0/src/agents/__init__.py +1 -0
- hedit-0.6.1a0/src/agents/annotation_agent.py +227 -0
- hedit-0.6.1a0/src/agents/assessment_agent.py +98 -0
- hedit-0.6.1a0/src/agents/evaluation_agent.py +242 -0
- hedit-0.6.1a0/src/agents/feedback_summarizer.py +119 -0
- hedit-0.6.1a0/src/agents/feedback_triage_agent.py +636 -0
- hedit-0.6.1a0/src/agents/state.py +110 -0
- hedit-0.6.1a0/src/agents/validation_agent.py +104 -0
- hedit-0.6.1a0/src/agents/vision_agent.py +142 -0
- hedit-0.6.1a0/src/agents/workflow.py +341 -0
- hedit-0.6.1a0/src/api/__init__.py +1 -0
- hedit-0.6.1a0/src/api/main.py +934 -0
- hedit-0.6.1a0/src/api/models.py +261 -0
- hedit-0.6.1a0/src/api/security.py +337 -0
- hedit-0.6.1a0/src/cli/__init__.py +5 -0
- hedit-0.6.1a0/src/cli/client.py +282 -0
- hedit-0.6.1a0/src/cli/commands/__init__.py +1 -0
- hedit-0.6.1a0/src/cli/config.py +272 -0
- hedit-0.6.1a0/src/cli/main.py +576 -0
- hedit-0.6.1a0/src/cli/output.py +289 -0
- hedit-0.6.1a0/src/scripts/__init__.py +1 -0
- hedit-0.6.1a0/src/scripts/process_feedback.py +179 -0
- hedit-0.6.1a0/src/utils/__init__.py +1 -0
- hedit-0.6.1a0/src/utils/error_remediation.py +455 -0
- hedit-0.6.1a0/src/utils/github_client.py +244 -0
- hedit-0.6.1a0/src/utils/hed_comprehensive_guide.py +377 -0
- hedit-0.6.1a0/src/utils/hed_rules.py +319 -0
- hedit-0.6.1a0/src/utils/image_processing.py +227 -0
- hedit-0.6.1a0/src/utils/json_schema_loader.py +149 -0
- hedit-0.6.1a0/src/utils/openrouter_llm.py +68 -0
- hedit-0.6.1a0/src/utils/schema_loader.py +108 -0
- hedit-0.6.1a0/src/validation/__init__.py +1 -0
- hedit-0.6.1a0/src/validation/hed_validator.py +312 -0
- hedit-0.6.1a0/src/version.py +14 -0
- hedit-0.6.1a0/tests/test_api_endpoints.py +370 -0
- hedit-0.6.1a0/tests/test_cli_client.py +294 -0
- hedit-0.6.1a0/tests/test_cli_config.py +229 -0
- hedit-0.6.1a0/tests/test_cli_integration.py +304 -0
- hedit-0.6.1a0/tests/test_cli_main.py +307 -0
- hedit-0.6.1a0/tests/test_error_remediation.py +348 -0
- hedit-0.6.1a0/tests/test_feedback_integration.py +463 -0
- hedit-0.6.1a0/tests/test_feedback_triage.py +538 -0
- hedit-0.6.1a0/tests/test_github_client.py +212 -0
- hedit-0.6.1a0/tests/test_integration_openrouter.py +508 -0
- hedit-0.6.1a0/tests/test_json_schema_loader.py +253 -0
- hedit-0.6.1a0/tests/test_schema_loader.py +76 -0
- hedit-0.6.1a0/tests/test_security.py +357 -0
- hedit-0.6.1a0/tests/test_state.py +32 -0
- hedit-0.6.1a0/tests/test_validation.py +292 -0
- hedit-0.6.1a0/tests/test_version.py +33 -0
hedit-0.6.1a0/PKG-INFO
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hedit
|
|
3
|
+
Version: 0.6.1a0
|
|
4
|
+
Summary: Multi-agent system for HED annotation generation and validation
|
|
5
|
+
Author-email: Annotation Garden Initiative <info@annotation.garden>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://annotation.garden/hedit
|
|
8
|
+
Project-URL: Documentation, https://github.com/Annotation-Garden/hedit#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/Annotation-Garden/hedit
|
|
10
|
+
Project-URL: Issues, https://github.com/Annotation-Garden/hedit/issues
|
|
11
|
+
Keywords: hed,annotation,neuroscience,bids,cli
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: >=3.12
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: langgraph>=0.2.0
|
|
22
|
+
Requires-Dist: langchain>=0.3.0
|
|
23
|
+
Requires-Dist: langchain-community>=0.3.0
|
|
24
|
+
Requires-Dist: langchain-core>=0.3.0
|
|
25
|
+
Requires-Dist: langchain-openai>=0.3.0
|
|
26
|
+
Requires-Dist: fastapi>=0.121.0
|
|
27
|
+
Requires-Dist: uvicorn[standard]>=0.38.0
|
|
28
|
+
Requires-Dist: pydantic>=2.12.0
|
|
29
|
+
Requires-Dist: python-multipart>=0.0.17
|
|
30
|
+
Requires-Dist: aiofiles>=25.1.0
|
|
31
|
+
Requires-Dist: httpx>=0.28.0
|
|
32
|
+
Requires-Dist: hedtools>=0.5.0
|
|
33
|
+
Requires-Dist: lxml>=5.3.0
|
|
34
|
+
Requires-Dist: beautifulsoup4>=4.12.3
|
|
35
|
+
Requires-Dist: pillow>=11.0.0
|
|
36
|
+
Requires-Dist: typer>=0.20.0
|
|
37
|
+
Requires-Dist: rich>=14.0.0
|
|
38
|
+
Requires-Dist: platformdirs>=4.5.0
|
|
39
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest>=8.3.0; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest-asyncio>=0.24.0; extra == "dev"
|
|
44
|
+
Requires-Dist: ruff>=0.7.0; extra == "dev"
|
|
45
|
+
Requires-Dist: black>=24.8.0; extra == "dev"
|
|
46
|
+
Requires-Dist: mypy>=1.11.0; extra == "dev"
|
|
47
|
+
|
|
48
|
+
# HEDit
|
|
49
|
+
|
|
50
|
+
[](https://github.com/Annotation-Garden/hedit/actions/workflows/test.yml)
|
|
51
|
+
[](https://codecov.io/gh/Annotation-Garden/hedit)
|
|
52
|
+
|
|
53
|
+
Multi-agent system for converting natural language event descriptions into valid HED (Hierarchical Event Descriptors) annotations. Part of the [Annotation Garden Initiative](https://annotation.garden).
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- **Multi-Agent Architecture**: Uses LangGraph to orchestrate specialized agents
|
|
58
|
+
- **Annotation Agent**: Generates HED tags using JSON schema vocabulary (short-form tags)
|
|
59
|
+
- **Validation Agent**: Validates HED compliance with detailed error feedback
|
|
60
|
+
- **Evaluation Agent**: Assesses faithfulness & suggests closest tag matches
|
|
61
|
+
- **Assessment Agent**: Identifies missing elements & dimensions
|
|
62
|
+
|
|
63
|
+
- **JSON Schema Support**: Uses official HED JSON schemas with short-form tags and extensionAllowed detection
|
|
64
|
+
- **Intelligent Validation**: Multi-stage validation with feedback loops and closest match suggestions
|
|
65
|
+
- **Local LLM Serving**: Uses Ollama with `gpt-oss:20b` model (20B parameters)
|
|
66
|
+
- **GPU Acceleration**: Optimized for NVIDIA RTX 4090 with CUDA support
|
|
67
|
+
- **Scalable**: Designed for 10-15 concurrent users
|
|
68
|
+
- **Auto-Configuration**: Model automatically pulled on first Docker start
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
📚 **[Full Documentation](docs/)** - Comprehensive guides for users, deployers, and developers
|
|
73
|
+
|
|
74
|
+
**Quick Links**:
|
|
75
|
+
- [Usage Guide](docs/guides/usage.md) - Getting started with HEDit
|
|
76
|
+
- **[Deployment Guide](DEPLOYMENT.md)** - Choose your deployment option (production, local GPU, or local dev)
|
|
77
|
+
- [API Reference](docs/api/) - API documentation
|
|
78
|
+
- [Development Guide](docs/development/) - Contribute to HEDit
|
|
79
|
+
|
|
80
|
+
## Deployment Options
|
|
81
|
+
|
|
82
|
+
HEDit supports multiple deployment scenarios. Choose the one that fits your needs:
|
|
83
|
+
|
|
84
|
+
### For Production (Recommended)
|
|
85
|
+
Deploy to a server or cloud platform with API key authentication, audit logging, and auto-updates.
|
|
86
|
+
**→ See [DEPLOYMENT.md](DEPLOYMENT.md) and [deploy/README.md](deploy/README.md)**
|
|
87
|
+
|
|
88
|
+
### For Local GPU Development
|
|
89
|
+
Run completely offline with Ollama and local GPU (requires NVIDIA RTX 3090/4090+).
|
|
90
|
+
**→ See [docs/deployment/docker-quickstart.md](docs/deployment/docker-quickstart.md)**
|
|
91
|
+
|
|
92
|
+
### For Quick Local Testing
|
|
93
|
+
Use your local Python environment with OpenRouter API (no GPU needed).
|
|
94
|
+
**→ See [Local Development Setup](#local-development-setup) below**
|
|
95
|
+
|
|
96
|
+
**Not sure which to choose?** See the [Deployment Decision Matrix](DEPLOYMENT.md#quick-decision-matrix)
|
|
97
|
+
|
|
98
|
+
## Architecture
|
|
99
|
+
|
|
100
|
+
```mermaid
|
|
101
|
+
flowchart LR
|
|
102
|
+
Start([Input]) --> Schema[(JSON Schema<br/>Vocabulary)]
|
|
103
|
+
Schema --> Ann[Annotation Agent]
|
|
104
|
+
|
|
105
|
+
Ann --> Val{Validation}
|
|
106
|
+
Val -->|Invalid<br/>retry| ValErr[Syntax Errors]
|
|
107
|
+
ValErr --> Ann
|
|
108
|
+
Val -->|Max attempts| Fail[Failed]
|
|
109
|
+
|
|
110
|
+
Val -->|Valid| Eval{Evaluation}
|
|
111
|
+
Eval -->|Not faithful| EvalErr[Tag Suggestions<br/>Extension Warnings]
|
|
112
|
+
EvalErr --> Ann
|
|
113
|
+
|
|
114
|
+
Eval -->|Faithful| Assess{Assessment}
|
|
115
|
+
Assess -->|Incomplete| AssErr[Missing Elements]
|
|
116
|
+
AssErr -.Optional.-> Ann
|
|
117
|
+
|
|
118
|
+
Assess -->|Complete| Success[Final Annotation]
|
|
119
|
+
AssErr -->|Report| Success
|
|
120
|
+
Success --> End([Output])
|
|
121
|
+
Fail --> End
|
|
122
|
+
|
|
123
|
+
style Start fill:#e1f5ff
|
|
124
|
+
style End fill:#e1f5ff
|
|
125
|
+
style Ann fill:#fff4e1
|
|
126
|
+
style Val fill:#ffe1e1
|
|
127
|
+
style Eval fill:#e1ffe1
|
|
128
|
+
style Assess fill:#f0e1ff
|
|
129
|
+
style Success fill:#e1ffe1
|
|
130
|
+
style Fail fill:#ffe1e1
|
|
131
|
+
style Schema fill:#e8e8e8
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Legend:**
|
|
135
|
+
- 🔄 **Solid arrows**: Automatic loops
|
|
136
|
+
- ⋯⋯ **Dotted arrows**: Optional refinement
|
|
137
|
+
- 🔵 Input/Output | 🟡 Annotation | 🔴 Validation | 🟢 Evaluation | 🟣 Assessment
|
|
138
|
+
|
|
139
|
+
### Workflow Details
|
|
140
|
+
|
|
141
|
+
1. **Annotation Loop** (Automatic):
|
|
142
|
+
- Generates HED annotation using short-form tags
|
|
143
|
+
- Uses complete HED syntax rules (parentheses, curly braces, #, /)
|
|
144
|
+
- Considers extensionAllowed tags for extensions
|
|
145
|
+
- Maximum validation attempts: 5 (configurable)
|
|
146
|
+
|
|
147
|
+
2. **Validation Loop** (Automatic):
|
|
148
|
+
- Checks syntax and tag validity
|
|
149
|
+
- Provides specific error codes and messages
|
|
150
|
+
- Loops back to annotation agent if errors found
|
|
151
|
+
- Stops if max attempts reached
|
|
152
|
+
|
|
153
|
+
3. **Evaluation Loop** (Automatic):
|
|
154
|
+
- Assesses faithfulness to original description
|
|
155
|
+
- Validates tags against JSON schema vocabulary
|
|
156
|
+
- Suggests closest matches for invalid tags
|
|
157
|
+
- Warns about non-portable tag extensions
|
|
158
|
+
- Loops back if not faithful
|
|
159
|
+
|
|
160
|
+
4. **Assessment Loop** (Optional):
|
|
161
|
+
- Final completeness check
|
|
162
|
+
- Identifies missing dimensions
|
|
163
|
+
- Can trigger optional refinement or report only
|
|
164
|
+
- Configurable behavior
|
|
165
|
+
|
|
166
|
+
## Installation
|
|
167
|
+
|
|
168
|
+
### Docker (Recommended - Self-Contained)
|
|
169
|
+
- Docker with NVIDIA Container Toolkit
|
|
170
|
+
- Docker Compose
|
|
171
|
+
- All dependencies (Python, Node.js, HED schemas, validator) included in image!
|
|
172
|
+
|
|
173
|
+
### Local Development
|
|
174
|
+
- Python 3.11+
|
|
175
|
+
- CUDA-capable GPU (for LLM serving)
|
|
176
|
+
- Node.js 18+ (for HED JavaScript validator)
|
|
177
|
+
- Conda (recommended)
|
|
178
|
+
|
|
179
|
+
### Quick Start (Docker)
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Clone repository
|
|
183
|
+
cd /path/to/hedit
|
|
184
|
+
|
|
185
|
+
# Build and start (auto-pulls model and includes all HED resources)
|
|
186
|
+
docker-compose up -d
|
|
187
|
+
|
|
188
|
+
# Monitor first start (~10-20 min for model download)
|
|
189
|
+
docker-compose logs -f
|
|
190
|
+
|
|
191
|
+
# Verify
|
|
192
|
+
curl http://localhost:38427/health
|
|
193
|
+
|
|
194
|
+
# Open frontend
|
|
195
|
+
open frontend/index.html
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Local Development Setup
|
|
199
|
+
|
|
200
|
+
1. **Create conda environment**:
|
|
201
|
+
```bash
|
|
202
|
+
source ~/miniconda3/etc/profile.d/conda.sh
|
|
203
|
+
conda create -n hedit python=3.11 -y
|
|
204
|
+
conda activate hedit
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
2. **Install dependencies**:
|
|
208
|
+
```bash
|
|
209
|
+
pip install -e ".[dev]"
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
3. **Clone HED resources** (if not using Docker):
|
|
213
|
+
```bash
|
|
214
|
+
# NOTE: Using forked hed-schemas with fix for JSON inheritance attributes
|
|
215
|
+
# TODO: Revert to hed-standard/hed-schemas once upstream fix is merged
|
|
216
|
+
git clone -b fix/json-inheritance-attributes https://github.com/neuromechanist/hed-schemas.git ../hed-schemas
|
|
217
|
+
git clone https://github.com/hed-standard/hed-javascript.git ../hed-javascript
|
|
218
|
+
cd ../hed-javascript && npm install && npm run build && cd -
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Usage
|
|
222
|
+
|
|
223
|
+
### Start the Backend Server
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
uvicorn src.api.main:app --reload --host 0.0.0.0 --port 38427
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### API Endpoints
|
|
230
|
+
|
|
231
|
+
- `POST /annotate`: Generate HED annotation from natural language
|
|
232
|
+
- `POST /validate`: Validate HED annotation
|
|
233
|
+
- `GET /health`: Health check
|
|
234
|
+
- API URL: `http://localhost:38427`
|
|
235
|
+
|
|
236
|
+
## Development
|
|
237
|
+
|
|
238
|
+
### Run Tests
|
|
239
|
+
```bash
|
|
240
|
+
pytest
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Code Quality
|
|
244
|
+
```bash
|
|
245
|
+
ruff check src/ tests/
|
|
246
|
+
ruff format src/ tests/
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Coverage Report
|
|
250
|
+
```bash
|
|
251
|
+
pytest --cov=src --cov-report=html
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Project Structure
|
|
255
|
+
|
|
256
|
+
```
|
|
257
|
+
hedit/
|
|
258
|
+
├── src/
|
|
259
|
+
│ ├── agents/ # LangGraph agent implementations
|
|
260
|
+
│ ├── validation/ # HED validation integration
|
|
261
|
+
│ ├── utils/ # Helper utilities
|
|
262
|
+
│ └── api/ # FastAPI backend
|
|
263
|
+
├── frontend/ # Web UI
|
|
264
|
+
├── tests/ # Test suite
|
|
265
|
+
├── docs/ # Documentation
|
|
266
|
+
└── .context/
|
|
267
|
+
└── plan.md # Project roadmap
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
MIT
|
|
273
|
+
|
|
274
|
+
## References
|
|
275
|
+
|
|
276
|
+
- [HED Standard](https://www.hedtags.org/)
|
|
277
|
+
- [HED Schemas](https://github.com/hed-standard/hed-schemas)
|
|
278
|
+
- [HED JavaScript Validator](https://github.com/hed-standard/hed-javascript)
|
|
279
|
+
- [LangGraph](https://github.com/langchain-ai/langgraph)
|
hedit-0.6.1a0/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# HEDit
|
|
2
|
+
|
|
3
|
+
[](https://github.com/Annotation-Garden/hedit/actions/workflows/test.yml)
|
|
4
|
+
[](https://codecov.io/gh/Annotation-Garden/hedit)
|
|
5
|
+
|
|
6
|
+
Multi-agent system for converting natural language event descriptions into valid HED (Hierarchical Event Descriptors) annotations. Part of the [Annotation Garden Initiative](https://annotation.garden).
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- **Multi-Agent Architecture**: Uses LangGraph to orchestrate specialized agents
|
|
11
|
+
- **Annotation Agent**: Generates HED tags using JSON schema vocabulary (short-form tags)
|
|
12
|
+
- **Validation Agent**: Validates HED compliance with detailed error feedback
|
|
13
|
+
- **Evaluation Agent**: Assesses faithfulness & suggests closest tag matches
|
|
14
|
+
- **Assessment Agent**: Identifies missing elements & dimensions
|
|
15
|
+
|
|
16
|
+
- **JSON Schema Support**: Uses official HED JSON schemas with short-form tags and extensionAllowed detection
|
|
17
|
+
- **Intelligent Validation**: Multi-stage validation with feedback loops and closest match suggestions
|
|
18
|
+
- **Local LLM Serving**: Uses Ollama with `gpt-oss:20b` model (20B parameters)
|
|
19
|
+
- **GPU Acceleration**: Optimized for NVIDIA RTX 4090 with CUDA support
|
|
20
|
+
- **Scalable**: Designed for 10-15 concurrent users
|
|
21
|
+
- **Auto-Configuration**: Model automatically pulled on first Docker start
|
|
22
|
+
|
|
23
|
+
## Documentation
|
|
24
|
+
|
|
25
|
+
📚 **[Full Documentation](docs/)** - Comprehensive guides for users, deployers, and developers
|
|
26
|
+
|
|
27
|
+
**Quick Links**:
|
|
28
|
+
- [Usage Guide](docs/guides/usage.md) - Getting started with HEDit
|
|
29
|
+
- **[Deployment Guide](DEPLOYMENT.md)** - Choose your deployment option (production, local GPU, or local dev)
|
|
30
|
+
- [API Reference](docs/api/) - API documentation
|
|
31
|
+
- [Development Guide](docs/development/) - Contribute to HEDit
|
|
32
|
+
|
|
33
|
+
## Deployment Options
|
|
34
|
+
|
|
35
|
+
HEDit supports multiple deployment scenarios. Choose the one that fits your needs:
|
|
36
|
+
|
|
37
|
+
### For Production (Recommended)
|
|
38
|
+
Deploy to a server or cloud platform with API key authentication, audit logging, and auto-updates.
|
|
39
|
+
**→ See [DEPLOYMENT.md](DEPLOYMENT.md) and [deploy/README.md](deploy/README.md)**
|
|
40
|
+
|
|
41
|
+
### For Local GPU Development
|
|
42
|
+
Run completely offline with Ollama and local GPU (requires NVIDIA RTX 3090/4090+).
|
|
43
|
+
**→ See [docs/deployment/docker-quickstart.md](docs/deployment/docker-quickstart.md)**
|
|
44
|
+
|
|
45
|
+
### For Quick Local Testing
|
|
46
|
+
Use your local Python environment with OpenRouter API (no GPU needed).
|
|
47
|
+
**→ See [Local Development Setup](#local-development-setup) below**
|
|
48
|
+
|
|
49
|
+
**Not sure which to choose?** See the [Deployment Decision Matrix](DEPLOYMENT.md#quick-decision-matrix)
|
|
50
|
+
|
|
51
|
+
## Architecture
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
flowchart LR
|
|
55
|
+
Start([Input]) --> Schema[(JSON Schema<br/>Vocabulary)]
|
|
56
|
+
Schema --> Ann[Annotation Agent]
|
|
57
|
+
|
|
58
|
+
Ann --> Val{Validation}
|
|
59
|
+
Val -->|Invalid<br/>retry| ValErr[Syntax Errors]
|
|
60
|
+
ValErr --> Ann
|
|
61
|
+
Val -->|Max attempts| Fail[Failed]
|
|
62
|
+
|
|
63
|
+
Val -->|Valid| Eval{Evaluation}
|
|
64
|
+
Eval -->|Not faithful| EvalErr[Tag Suggestions<br/>Extension Warnings]
|
|
65
|
+
EvalErr --> Ann
|
|
66
|
+
|
|
67
|
+
Eval -->|Faithful| Assess{Assessment}
|
|
68
|
+
Assess -->|Incomplete| AssErr[Missing Elements]
|
|
69
|
+
AssErr -.Optional.-> Ann
|
|
70
|
+
|
|
71
|
+
Assess -->|Complete| Success[Final Annotation]
|
|
72
|
+
AssErr -->|Report| Success
|
|
73
|
+
Success --> End([Output])
|
|
74
|
+
Fail --> End
|
|
75
|
+
|
|
76
|
+
style Start fill:#e1f5ff
|
|
77
|
+
style End fill:#e1f5ff
|
|
78
|
+
style Ann fill:#fff4e1
|
|
79
|
+
style Val fill:#ffe1e1
|
|
80
|
+
style Eval fill:#e1ffe1
|
|
81
|
+
style Assess fill:#f0e1ff
|
|
82
|
+
style Success fill:#e1ffe1
|
|
83
|
+
style Fail fill:#ffe1e1
|
|
84
|
+
style Schema fill:#e8e8e8
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Legend:**
|
|
88
|
+
- 🔄 **Solid arrows**: Automatic loops
|
|
89
|
+
- ⋯⋯ **Dotted arrows**: Optional refinement
|
|
90
|
+
- 🔵 Input/Output | 🟡 Annotation | 🔴 Validation | 🟢 Evaluation | 🟣 Assessment
|
|
91
|
+
|
|
92
|
+
### Workflow Details
|
|
93
|
+
|
|
94
|
+
1. **Annotation Loop** (Automatic):
|
|
95
|
+
- Generates HED annotation using short-form tags
|
|
96
|
+
- Uses complete HED syntax rules (parentheses, curly braces, #, /)
|
|
97
|
+
- Considers extensionAllowed tags for extensions
|
|
98
|
+
- Maximum validation attempts: 5 (configurable)
|
|
99
|
+
|
|
100
|
+
2. **Validation Loop** (Automatic):
|
|
101
|
+
- Checks syntax and tag validity
|
|
102
|
+
- Provides specific error codes and messages
|
|
103
|
+
- Loops back to annotation agent if errors found
|
|
104
|
+
- Stops if max attempts reached
|
|
105
|
+
|
|
106
|
+
3. **Evaluation Loop** (Automatic):
|
|
107
|
+
- Assesses faithfulness to original description
|
|
108
|
+
- Validates tags against JSON schema vocabulary
|
|
109
|
+
- Suggests closest matches for invalid tags
|
|
110
|
+
- Warns about non-portable tag extensions
|
|
111
|
+
- Loops back if not faithful
|
|
112
|
+
|
|
113
|
+
4. **Assessment Loop** (Optional):
|
|
114
|
+
- Final completeness check
|
|
115
|
+
- Identifies missing dimensions
|
|
116
|
+
- Can trigger optional refinement or report only
|
|
117
|
+
- Configurable behavior
|
|
118
|
+
|
|
119
|
+
## Installation
|
|
120
|
+
|
|
121
|
+
### Docker (Recommended - Self-Contained)
|
|
122
|
+
- Docker with NVIDIA Container Toolkit
|
|
123
|
+
- Docker Compose
|
|
124
|
+
- All dependencies (Python, Node.js, HED schemas, validator) included in image!
|
|
125
|
+
|
|
126
|
+
### Local Development
|
|
127
|
+
- Python 3.11+
|
|
128
|
+
- CUDA-capable GPU (for LLM serving)
|
|
129
|
+
- Node.js 18+ (for HED JavaScript validator)
|
|
130
|
+
- Conda (recommended)
|
|
131
|
+
|
|
132
|
+
### Quick Start (Docker)
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Clone repository
|
|
136
|
+
cd /path/to/hedit
|
|
137
|
+
|
|
138
|
+
# Build and start (auto-pulls model and includes all HED resources)
|
|
139
|
+
docker-compose up -d
|
|
140
|
+
|
|
141
|
+
# Monitor first start (~10-20 min for model download)
|
|
142
|
+
docker-compose logs -f
|
|
143
|
+
|
|
144
|
+
# Verify
|
|
145
|
+
curl http://localhost:38427/health
|
|
146
|
+
|
|
147
|
+
# Open frontend
|
|
148
|
+
open frontend/index.html
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Local Development Setup
|
|
152
|
+
|
|
153
|
+
1. **Create conda environment**:
|
|
154
|
+
```bash
|
|
155
|
+
source ~/miniconda3/etc/profile.d/conda.sh
|
|
156
|
+
conda create -n hedit python=3.11 -y
|
|
157
|
+
conda activate hedit
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
2. **Install dependencies**:
|
|
161
|
+
```bash
|
|
162
|
+
pip install -e ".[dev]"
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
3. **Clone HED resources** (if not using Docker):
|
|
166
|
+
```bash
|
|
167
|
+
# NOTE: Using forked hed-schemas with fix for JSON inheritance attributes
|
|
168
|
+
# TODO: Revert to hed-standard/hed-schemas once upstream fix is merged
|
|
169
|
+
git clone -b fix/json-inheritance-attributes https://github.com/neuromechanist/hed-schemas.git ../hed-schemas
|
|
170
|
+
git clone https://github.com/hed-standard/hed-javascript.git ../hed-javascript
|
|
171
|
+
cd ../hed-javascript && npm install && npm run build && cd -
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Usage
|
|
175
|
+
|
|
176
|
+
### Start the Backend Server
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
uvicorn src.api.main:app --reload --host 0.0.0.0 --port 38427
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### API Endpoints
|
|
183
|
+
|
|
184
|
+
- `POST /annotate`: Generate HED annotation from natural language
|
|
185
|
+
- `POST /validate`: Validate HED annotation
|
|
186
|
+
- `GET /health`: Health check
|
|
187
|
+
- API URL: `http://localhost:38427`
|
|
188
|
+
|
|
189
|
+
## Development
|
|
190
|
+
|
|
191
|
+
### Run Tests
|
|
192
|
+
```bash
|
|
193
|
+
pytest
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Code Quality
|
|
197
|
+
```bash
|
|
198
|
+
ruff check src/ tests/
|
|
199
|
+
ruff format src/ tests/
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Coverage Report
|
|
203
|
+
```bash
|
|
204
|
+
pytest --cov=src --cov-report=html
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Project Structure
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
hedit/
|
|
211
|
+
├── src/
|
|
212
|
+
│ ├── agents/ # LangGraph agent implementations
|
|
213
|
+
│ ├── validation/ # HED validation integration
|
|
214
|
+
│ ├── utils/ # Helper utilities
|
|
215
|
+
│ └── api/ # FastAPI backend
|
|
216
|
+
├── frontend/ # Web UI
|
|
217
|
+
├── tests/ # Test suite
|
|
218
|
+
├── docs/ # Documentation
|
|
219
|
+
└── .context/
|
|
220
|
+
└── plan.md # Project roadmap
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
226
|
+
|
|
227
|
+
## References
|
|
228
|
+
|
|
229
|
+
- [HED Standard](https://www.hedtags.org/)
|
|
230
|
+
- [HED Schemas](https://github.com/hed-standard/hed-schemas)
|
|
231
|
+
- [HED JavaScript Validator](https://github.com/hed-standard/hed-javascript)
|
|
232
|
+
- [LangGraph](https://github.com/langchain-ai/langgraph)
|