Spaces:
Running on Zero
Running on Zero
GitHub Actions commited on
Commit Β·
66a1a95
1
Parent(s): c48a01e
fix: llm.chat IndexError (lazy Ollama warm + safe _resolve_backend fallback) + chat self-send returns direct
Browse files- .live_test_node/events.db +0 -0
- README.md +7 -7
- docs/ARCHITECTURE.md +1 -1
- docs/guides/ANDROID_DEPLOYMENT_GUIDE.md +4 -4
- docs/guides/BUILD_GUIDE.md +2 -2
- docs/guides/HOWTO.md +2 -2
- BUILD_STATUS.md β docs/reports/BUILD_STATUS.md +6 -6
- COVERAGE_ENHANCEMENT_REPORT.md β docs/reports/COVERAGE_ENHANCEMENT_REPORT.md +0 -0
- COVERAGE_IMPROVEMENT.md β docs/reports/COVERAGE_IMPROVEMENT.md +0 -0
- QUALITY_FIXES_COMPLETED.md β docs/reports/QUALITY_FIXES_COMPLETED.md +0 -0
- QUALITY_REPORT.md β docs/reports/QUALITY_REPORT.md +0 -0
- TEST_IMPROVEMENTS.md β docs/reports/TEST_IMPROVEMENTS.md +0 -0
- TEST_INFRASTRUCTURE_COMPLETE.md β docs/reports/TEST_INFRASTRUCTURE_COMPLETE.md +0 -0
- TEST_SUITE_REPORT.md β docs/reports/TEST_SUITE_REPORT.md +0 -0
- SECURITY_AUDIT_ASSESSMENT.md β docs/security/SECURITY_AUDIT_ASSESSMENT.md +0 -0
- SECURITY_VERIFICATION_SUMMARY.md β docs/security/SECURITY_VERIFICATION_SUMMARY.md +0 -0
- docs/upgrade_plan.md +2 -2
- hearthnet/services/chat/service.py +19 -1
- hearthnet/services/llm/service.py +25 -5
- hearthnet/ui/__pycache__/onboarding.cpython-313.pyc +0 -0
- count_all_tests.py β scripts/count_all_tests.py +0 -0
- fill_phase23.py β scripts/fill_phase23.py +0 -0
- fill_reference.py β scripts/fill_reference.py +0 -0
- fill_tests.py β scripts/fill_tests.py +0 -0
- gen_tests.py β scripts/gen_tests.py +0 -0
- generate_coverage.py β scripts/generate_coverage.py +0 -0
- tasks.md +4 -4
.live_test_node/events.db
ADDED
|
Binary file (28.7 kB). View file
|
|
|
README.md
CHANGED
|
@@ -97,13 +97,13 @@ Get HearthNet for your platform:
|
|
| 97 |
| **macOS Desktop** | `python build/quickstart.py macos` | .app | ~200MB | Native macOS app bundle |
|
| 98 |
| **Python (Any OS)** | [Source](https://github.com/ckal/HearthNet) | Python | - | `python app.py` - full mesh node |
|
| 99 |
| **Docker** | [Dockerfile](Dockerfile) | Container | 2GB | `docker run -p 7860:7860 hearthnet:latest` |
|
| 100 |
-
| **Guides & Docs** | [BUILD_GUIDE.md](BUILD_GUIDE.md) | Markdown | - | How to build for each platform |
|
| 101 |
|
| 102 |
**Recommended Paths:**
|
| 103 |
- π **Fastest** (5 min): PWA Web App - instant, no install
|
| 104 |
- π» **Desktop** (3 min): Download EXE/AppImage and run
|
| 105 |
- π³ **Server**: Docker container deployment
|
| 106 |
-
- π See [BUILD_GUIDE.md](BUILD_GUIDE.md) for detailed instructions
|
| 107 |
|
| 108 |
---
|
| 109 |
|
|
@@ -142,7 +142,7 @@ python app.py
|
|
| 142 |
# 4. Tap menu β "Install app" or "Add to Home screen"
|
| 143 |
```
|
| 144 |
|
| 145 |
-
**π± Full Android Setup Guide:** [ANDROID_DEPLOYMENT_GUIDE.md](ANDROID_DEPLOYMENT_GUIDE.md)
|
| 146 |
- β
PWA (instant, no build)
|
| 147 |
- π§ Native APK (optional, advanced)
|
| 148 |
|
|
@@ -430,7 +430,7 @@ python -m pytest tests/ --ignore=tests/test_e2e_user_stories.py -q # skip Playw
|
|
| 430 |
|
| 431 |
| Resource | Link |
|
| 432 |
|----------|------|
|
| 433 |
-
| Architecture | [ARCHITECTURE.md](ARCHITECTURE.md) |
|
| 434 |
| System overview | [docs/00-OVERVIEW.md](docs/00-OVERVIEW.md) |
|
| 435 |
| Capability contract | [docs/CAPABILITY_CONTRACT.md](docs/CAPABILITY_CONTRACT.md) |
|
| 436 |
| Roadmap | [docs/roadmap.md](docs/roadmap.md) |
|
|
@@ -454,7 +454,7 @@ HearthNet has **comprehensive test coverage** across all modules:
|
|
| 454 |
| **Transport** (X01) | 69 | β
Enhanced (12β55%+) | [X01 Enhanced](tests/test_x01_enhanced.py) |
|
| 455 |
| **Phase 2/3 Specs** (M14-M32, X05-X09) | 216 | ποΈ Scaffolded | [P2/P3 Tests](tests/test_m1[4-9]_spec.py), [X0[5-9]](tests/test_x0[5-9]_spec.py) |
|
| 456 |
| **Reference Docs** | 80 | ποΈ Scaffolded | [API Contract](tests/test_capability_contract.py), [Glossary](tests/test_glossary.py) |
|
| 457 |
-
| **Total** | **932** | **100% Pass** | [Full Report](TEST_SUITE_REPORT.md) |
|
| 458 |
|
| 459 |
**Code Coverage: 44% (6,043 / 10,743 lines)**
|
| 460 |
- Well-covered (>70%): Identity, Bus, Types, UI core
|
|
@@ -501,7 +501,7 @@ git commit -m "my changes" # β tests run first!
|
|
| 501 |
|
| 502 |
### Test Documentation
|
| 503 |
|
| 504 |
-
- **Full Report:** [TEST_SUITE_REPORT.md](TEST_SUITE_REPORT.md) β 783 tests, all modules
|
| 505 |
- **Coverage Enhancement:** [COVERAGE_ENHANCEMENT_REPORT.md](COVERAGE_ENHANCEMENT_REPORT.md) β 149 new tests for M04/M05/X01/X03
|
| 506 |
- **Test Structure:** Each test follows Happy / Error / Edge pattern
|
| 507 |
- **No Mocks:** All implemented tests use real code paths
|
|
@@ -525,7 +525,7 @@ git commit -m "my changes" # β tests run first!
|
|
| 525 |
**Build Artifacts Available:**
|
| 526 |
- Windows EXE: [dist/HearthNet.exe](https://huggingface.co/spaces/build-small-hackathon/HearthNet/resolve/main/dist/HearthNet.exe) (212 MB)
|
| 527 |
- Android APK: [build/android/.../app-debug.apk](https://huggingface.co/spaces/build-small-hackathon/HearthNet/resolve/main/build/android/HearthNetApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk) (3.56 MB)
|
| 528 |
-
- Build scripts: [BUILD_GUIDE.md](BUILD_GUIDE.md) for EXE, AppImage, .app, Docker
|
| 529 |
|
| 530 |
---
|
| 531 |
|
|
|
|
| 97 |
| **macOS Desktop** | `python build/quickstart.py macos` | .app | ~200MB | Native macOS app bundle |
|
| 98 |
| **Python (Any OS)** | [Source](https://github.com/ckal/HearthNet) | Python | - | `python app.py` - full mesh node |
|
| 99 |
| **Docker** | [Dockerfile](Dockerfile) | Container | 2GB | `docker run -p 7860:7860 hearthnet:latest` |
|
| 100 |
+
| **Guides & Docs** | [BUILD_GUIDE.md](docs/guides/BUILD_GUIDE.md) | Markdown | - | How to build for each platform |
|
| 101 |
|
| 102 |
**Recommended Paths:**
|
| 103 |
- π **Fastest** (5 min): PWA Web App - instant, no install
|
| 104 |
- π» **Desktop** (3 min): Download EXE/AppImage and run
|
| 105 |
- π³ **Server**: Docker container deployment
|
| 106 |
+
- π See [BUILD_GUIDE.md](docs/guides/BUILD_GUIDE.md) for detailed instructions
|
| 107 |
|
| 108 |
---
|
| 109 |
|
|
|
|
| 142 |
# 4. Tap menu β "Install app" or "Add to Home screen"
|
| 143 |
```
|
| 144 |
|
| 145 |
+
**π± Full Android Setup Guide:** [ANDROID_DEPLOYMENT_GUIDE.md](docs/guides/ANDROID_DEPLOYMENT_GUIDE.md)
|
| 146 |
- β
PWA (instant, no build)
|
| 147 |
- π§ Native APK (optional, advanced)
|
| 148 |
|
|
|
|
| 430 |
|
| 431 |
| Resource | Link |
|
| 432 |
|----------|------|
|
| 433 |
+
| Architecture | [ARCHITECTURE.md](docs/ARCHITECTURE.md) |
|
| 434 |
| System overview | [docs/00-OVERVIEW.md](docs/00-OVERVIEW.md) |
|
| 435 |
| Capability contract | [docs/CAPABILITY_CONTRACT.md](docs/CAPABILITY_CONTRACT.md) |
|
| 436 |
| Roadmap | [docs/roadmap.md](docs/roadmap.md) |
|
|
|
|
| 454 |
| **Transport** (X01) | 69 | β
Enhanced (12β55%+) | [X01 Enhanced](tests/test_x01_enhanced.py) |
|
| 455 |
| **Phase 2/3 Specs** (M14-M32, X05-X09) | 216 | ποΈ Scaffolded | [P2/P3 Tests](tests/test_m1[4-9]_spec.py), [X0[5-9]](tests/test_x0[5-9]_spec.py) |
|
| 456 |
| **Reference Docs** | 80 | ποΈ Scaffolded | [API Contract](tests/test_capability_contract.py), [Glossary](tests/test_glossary.py) |
|
| 457 |
+
| **Total** | **932** | **100% Pass** | [Full Report](docs/reports/TEST_SUITE_REPORT.md) |
|
| 458 |
|
| 459 |
**Code Coverage: 44% (6,043 / 10,743 lines)**
|
| 460 |
- Well-covered (>70%): Identity, Bus, Types, UI core
|
|
|
|
| 501 |
|
| 502 |
### Test Documentation
|
| 503 |
|
| 504 |
+
- **Full Report:** [TEST_SUITE_REPORT.md](docs/reports/TEST_SUITE_REPORT.md) β 783 tests, all modules
|
| 505 |
- **Coverage Enhancement:** [COVERAGE_ENHANCEMENT_REPORT.md](COVERAGE_ENHANCEMENT_REPORT.md) β 149 new tests for M04/M05/X01/X03
|
| 506 |
- **Test Structure:** Each test follows Happy / Error / Edge pattern
|
| 507 |
- **No Mocks:** All implemented tests use real code paths
|
|
|
|
| 525 |
**Build Artifacts Available:**
|
| 526 |
- Windows EXE: [dist/HearthNet.exe](https://huggingface.co/spaces/build-small-hackathon/HearthNet/resolve/main/dist/HearthNet.exe) (212 MB)
|
| 527 |
- Android APK: [build/android/.../app-debug.apk](https://huggingface.co/spaces/build-small-hackathon/HearthNet/resolve/main/build/android/HearthNetApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk) (3.56 MB)
|
| 528 |
+
- Build scripts: [BUILD_GUIDE.md](docs/guides/BUILD_GUIDE.md) for EXE, AppImage, .app, Docker
|
| 529 |
|
| 530 |
---
|
| 531 |
|
docs/ARCHITECTURE.md
CHANGED
|
@@ -437,5 +437,5 @@ python -m hearthnet.conformance.runner --output conformance-report/
|
|
| 437 |
---
|
| 438 |
|
| 439 |
*This document is generated from the spec set in `docs/`. For per-module detail see:*
|
| 440 |
-
- *Phase 1+2: `
|
| 441 |
- *Phase 3: `docs/p2_p3/IMPLEMENTATION_REFERENCE_p3.md`, `docs/p2_p3/M26-*.md` β¦*
|
|
|
|
| 437 |
---
|
| 438 |
|
| 439 |
*This document is generated from the spec set in `docs/`. For per-module detail see:*
|
| 440 |
+
- *Phase 1+2: `00-OVERVIEW.md`, `CAPABILITY_CONTRACT.md`, `modules/M01-*.md` β¦*
|
| 441 |
- *Phase 3: `docs/p2_p3/IMPLEMENTATION_REFERENCE_p3.md`, `docs/p2_p3/M26-*.md` β¦*
|
docs/guides/ANDROID_DEPLOYMENT_GUIDE.md
CHANGED
|
@@ -177,10 +177,10 @@ FastAPI Backend (http://localhost:7860)
|
|
| 177 |
|
| 178 |
## Documentation Files
|
| 179 |
|
| 180 |
-
- [PWA Implementation](
|
| 181 |
-
- [Cordova Build Guide](build/android/CORDOVA_BUILD_GUIDE.md) - Detailed native build
|
| 182 |
-
- [APK Setup](build/android/SETUP_COMPLETE.md) - Project status
|
| 183 |
-
- [Build Paths](build/android/BUILD_PATHS.md) - Decision guide
|
| 184 |
|
| 185 |
---
|
| 186 |
|
|
|
|
| 177 |
|
| 178 |
## Documentation Files
|
| 179 |
|
| 180 |
+
- [PWA Implementation](../modules/M08-ui.md) - Full web app details
|
| 181 |
+
- [Cordova Build Guide](../../build/android/CORDOVA_BUILD_GUIDE.md) - Detailed native build
|
| 182 |
+
- [APK Setup](../../build/android/SETUP_COMPLETE.md) - Project status
|
| 183 |
+
- [Build Paths](../../build/android/BUILD_PATHS.md) - Decision guide
|
| 184 |
|
| 185 |
---
|
| 186 |
|
docs/guides/BUILD_GUIDE.md
CHANGED
|
@@ -387,9 +387,9 @@ gpg --verify dist/HearthNet-*.AppImage.sig
|
|
| 387 |
## π Related Documentation
|
| 388 |
|
| 389 |
- [BUILD_STATUS.md](BUILD_STATUS.md) - Current artifact inventory
|
| 390 |
-
- [ANDROID_DEPLOYMENT_GUIDE.md](
|
| 391 |
- [README.md](../README.md) - Main project readme
|
| 392 |
-
- [Cordova Guide](CORDOVA_BUILD_GUIDE.md) - Android native build
|
| 393 |
|
| 394 |
---
|
| 395 |
|
|
|
|
| 387 |
## π Related Documentation
|
| 388 |
|
| 389 |
- [BUILD_STATUS.md](BUILD_STATUS.md) - Current artifact inventory
|
| 390 |
+
- [ANDROID_DEPLOYMENT_GUIDE.md](ANDROID_DEPLOYMENT_GUIDE.md) - APK + PWA setup
|
| 391 |
- [README.md](../README.md) - Main project readme
|
| 392 |
+
- [Cordova Guide](../../build/android/CORDOVA_BUILD_GUIDE.md) - Android native build
|
| 393 |
|
| 394 |
---
|
| 395 |
|
docs/guides/HOWTO.md
CHANGED
|
@@ -146,7 +146,7 @@ For nodes behind NAT or across the internet, configure a relay URL:
|
|
| 146 |
relay_urls = ["https://your-relay.example.com"]
|
| 147 |
```
|
| 148 |
|
| 149 |
-
See [docs/p2_p3/M15-relay-tier.md](p2_p3/M15-relay-tier.md).
|
| 150 |
|
| 151 |
### Checking connected peers
|
| 152 |
|
|
@@ -525,7 +525,7 @@ python -m hearthnet.cli call emergency.probe@1.0 '{}'
|
|
| 525 |
|
| 526 |
## 11. How Routing Works
|
| 527 |
|
| 528 |
-
**Spec:** [docs/M03-bus.md](M03-bus.md) Β§3.5 / Β§5.4
|
| 529 |
**Implementation:** `hearthnet/bus/router.py`, `hearthnet/bus/__init__.py`
|
| 530 |
|
| 531 |
### The capability bus
|
|
|
|
| 146 |
relay_urls = ["https://your-relay.example.com"]
|
| 147 |
```
|
| 148 |
|
| 149 |
+
See [docs/p2_p3/M15-relay-tier.md](../p2_p3/M15-relay-tier.md).
|
| 150 |
|
| 151 |
### Checking connected peers
|
| 152 |
|
|
|
|
| 525 |
|
| 526 |
## 11. How Routing Works
|
| 527 |
|
| 528 |
+
**Spec:** [docs/modules/M03-bus.md](../modules/M03-bus.md) Β§3.5 / Β§5.4
|
| 529 |
**Implementation:** `hearthnet/bus/router.py`, `hearthnet/bus/__init__.py`
|
| 530 |
|
| 531 |
### The capability bus
|
BUILD_STATUS.md β docs/reports/BUILD_STATUS.md
RENAMED
|
@@ -82,9 +82,9 @@
|
|
| 82 |
- Architecture diagrams
|
| 83 |
|
| 84 |
- **Build Guides**:
|
| 85 |
-
- [Cordova Build Guide](build/android/CORDOVA_BUILD_GUIDE.md)
|
| 86 |
-
- [Build Paths Decision Guide](build/android/BUILD_PATHS.md)
|
| 87 |
-
- [Setup Complete Status](build/android/SETUP_COMPLETE.md)
|
| 88 |
|
| 89 |
---
|
| 90 |
|
|
@@ -253,9 +253,9 @@ adb install build/android/HearthNetApp/platforms/android/app/build/outputs/apk/d
|
|
| 253 |
## π Support
|
| 254 |
|
| 255 |
**Documentation**:
|
| 256 |
-
- [Deployment Guide](ANDROID_DEPLOYMENT_GUIDE.md)
|
| 257 |
-
- [Cordova Build Guide](build/android/CORDOVA_BUILD_GUIDE.md)
|
| 258 |
-
- [Architecture Docs](
|
| 259 |
|
| 260 |
**GitHub**: [ckal/HearthNet](https://github.com/ckal/HearthNet)
|
| 261 |
**HF Space**: [build-small-hackathon/HearthNet](https://huggingface.co/spaces/build-small-hackathon/HearthNet)
|
|
|
|
| 82 |
- Architecture diagrams
|
| 83 |
|
| 84 |
- **Build Guides**:
|
| 85 |
+
- [Cordova Build Guide](../../build/android/CORDOVA_BUILD_GUIDE.md)
|
| 86 |
+
- [Build Paths Decision Guide](../../build/android/BUILD_PATHS.md)
|
| 87 |
+
- [Setup Complete Status](../../build/android/SETUP_COMPLETE.md)
|
| 88 |
|
| 89 |
---
|
| 90 |
|
|
|
|
| 253 |
## π Support
|
| 254 |
|
| 255 |
**Documentation**:
|
| 256 |
+
- [Deployment Guide](../guides/ANDROID_DEPLOYMENT_GUIDE.md)
|
| 257 |
+
- [Cordova Build Guide](../../build/android/CORDOVA_BUILD_GUIDE.md)
|
| 258 |
+
- [Architecture Docs](../modules/M08-ui.md)
|
| 259 |
|
| 260 |
**GitHub**: [ckal/HearthNet](https://github.com/ckal/HearthNet)
|
| 261 |
**HF Space**: [build-small-hackathon/HearthNet](https://huggingface.co/spaces/build-small-hackathon/HearthNet)
|
COVERAGE_ENHANCEMENT_REPORT.md β docs/reports/COVERAGE_ENHANCEMENT_REPORT.md
RENAMED
|
File without changes
|
COVERAGE_IMPROVEMENT.md β docs/reports/COVERAGE_IMPROVEMENT.md
RENAMED
|
File without changes
|
QUALITY_FIXES_COMPLETED.md β docs/reports/QUALITY_FIXES_COMPLETED.md
RENAMED
|
File without changes
|
QUALITY_REPORT.md β docs/reports/QUALITY_REPORT.md
RENAMED
|
File without changes
|
TEST_IMPROVEMENTS.md β docs/reports/TEST_IMPROVEMENTS.md
RENAMED
|
File without changes
|
TEST_INFRASTRUCTURE_COMPLETE.md β docs/reports/TEST_INFRASTRUCTURE_COMPLETE.md
RENAMED
|
File without changes
|
TEST_SUITE_REPORT.md β docs/reports/TEST_SUITE_REPORT.md
RENAMED
|
File without changes
|
SECURITY_AUDIT_ASSESSMENT.md β docs/security/SECURITY_AUDIT_ASSESSMENT.md
RENAMED
|
File without changes
|
SECURITY_VERIFICATION_SUMMARY.md β docs/security/SECURITY_VERIFICATION_SUMMARY.md
RENAMED
|
File without changes
|
docs/upgrade_plan.md
CHANGED
|
@@ -128,8 +128,8 @@ and (when keys set) the Nemotron/Modal backends.
|
|
| 128 |
|
| 129 |
## Phase 7 β Documentation
|
| 130 |
|
| 131 |
-
**Files:** `README.md`, `
|
| 132 |
-
`
|
| 133 |
|
| 134 |
- Record the bge-small embedding model and that RAG is now real semantic retrieval.
|
| 135 |
- **Model policy:** keep `SmolLM2-135M-Instruct` as the default LLM (tiny-titan track,
|
|
|
|
| 128 |
|
| 129 |
## Phase 7 β Documentation
|
| 130 |
|
| 131 |
+
**Files:** `README.md`, `modules/M*.md` capability-status lines, `GLOSSARY.md`,
|
| 132 |
+
`CAPABILITY_CONTRACT.md`.
|
| 133 |
|
| 134 |
- Record the bge-small embedding model and that RAG is now real semantic retrieval.
|
| 135 |
- **Model policy:** keep `SmolLM2-135M-Instruct` as the default LLM (tiny-titan track,
|
hearthnet/services/chat/service.py
CHANGED
|
@@ -52,7 +52,25 @@ class ChatService:
|
|
| 52 |
recipient = payload.get("recipient") or payload.get("to", "")
|
| 53 |
|
| 54 |
if recipient == self._node_id:
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
event_id = payload.get("event_id") or f"msg:{uuid.uuid4().hex}"
|
| 58 |
client_id = payload.get("client_id", event_id)
|
|
|
|
| 52 |
recipient = payload.get("recipient") or payload.get("to", "")
|
| 53 |
|
| 54 |
if recipient == self._node_id:
|
| 55 |
+
# Self-message: store locally and return direct status
|
| 56 |
+
event_id = payload.get("event_id") or f"msg:{uuid.uuid4().hex}"
|
| 57 |
+
now = datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
|
| 58 |
+
msg = {
|
| 59 |
+
"event_id": event_id,
|
| 60 |
+
"from": self._node_id,
|
| 61 |
+
"to": self._node_id,
|
| 62 |
+
"body": payload.get("body", ""),
|
| 63 |
+
"attachments": payload.get("attachments", []),
|
| 64 |
+
"sent_at": now,
|
| 65 |
+
"client_id": payload.get("client_id", event_id),
|
| 66 |
+
}
|
| 67 |
+
self.messages.append(msg)
|
| 68 |
+
if self._view is not None:
|
| 69 |
+
try:
|
| 70 |
+
self._view._messages.append(msg)
|
| 71 |
+
except Exception:
|
| 72 |
+
pass
|
| 73 |
+
return {"output": {"event_id": event_id, "lamport": 0, "delivered": "direct"}, "meta": {}}
|
| 74 |
|
| 75 |
event_id = payload.get("event_id") or f"msg:{uuid.uuid4().hex}"
|
| 76 |
client_id = payload.get("client_id", event_id)
|
hearthnet/services/llm/service.py
CHANGED
|
@@ -89,23 +89,37 @@ class LlmService:
|
|
| 89 |
]
|
| 90 |
|
| 91 |
def _resolve_backend(self, model_name: str) -> tuple[LlmBackend, str]:
|
| 92 |
-
"""Pick the backend that serves ``model_name``; fall back to
|
| 93 |
if model_name:
|
| 94 |
for backend in self._backends:
|
| 95 |
for bm in backend.models:
|
| 96 |
if bm.name == model_name:
|
| 97 |
return backend, model_name
|
| 98 |
-
backend
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
async def _handle_chat(self, req: RouteRequest) -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
inp = req.body.get("input", {})
|
| 103 |
messages = inp.get("messages", [])
|
| 104 |
params = req.body.get("params", {})
|
| 105 |
-
backend, model_name = self._resolve_backend(str(params.get("model") or ""))
|
| 106 |
temperature = float(params.get("temperature", 0.7))
|
| 107 |
max_tokens = int(params.get("max_tokens", 1024))
|
| 108 |
try:
|
|
|
|
| 109 |
result = await backend.chat(
|
| 110 |
messages,
|
| 111 |
model=model_name,
|
|
@@ -126,11 +140,17 @@ class LlmService:
|
|
| 126 |
return {"error": "internal_error", "message": str(exc)}
|
| 127 |
|
| 128 |
async def _handle_complete(self, req: RouteRequest) -> dict:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
inp = req.body.get("input", {})
|
| 130 |
prompt = inp.get("prompt", "")
|
| 131 |
params = req.body.get("params", {})
|
| 132 |
-
backend, model_name = self._resolve_backend(str(params.get("model") or ""))
|
| 133 |
try:
|
|
|
|
| 134 |
result = await backend.complete(prompt, model=model_name, stream=False)
|
| 135 |
return {
|
| 136 |
"output": {"text": result.text},
|
|
|
|
| 89 |
]
|
| 90 |
|
| 91 |
def _resolve_backend(self, model_name: str) -> tuple[LlmBackend, str]:
|
| 92 |
+
"""Pick the backend that serves ``model_name``; fall back to first backend with models."""
|
| 93 |
if model_name:
|
| 94 |
for backend in self._backends:
|
| 95 |
for bm in backend.models:
|
| 96 |
if bm.name == model_name:
|
| 97 |
return backend, model_name
|
| 98 |
+
# Safe fallback: skip any backend whose model list is still empty (not yet warmed)
|
| 99 |
+
for backend in self._backends:
|
| 100 |
+
if backend.models:
|
| 101 |
+
return backend, backend.models[0].name
|
| 102 |
+
raise RuntimeError(
|
| 103 |
+
"No LLM backend has available models. "
|
| 104 |
+
"Run `ollama pull <model>`, start llama.cpp, or install transformers."
|
| 105 |
+
)
|
| 106 |
|
| 107 |
async def _handle_chat(self, req: RouteRequest) -> dict:
|
| 108 |
+
# Lazy warm: populate model lists for backends that haven't been warmed yet
|
| 109 |
+
# (e.g. OllamaBackend.models is empty until warm() is awaited)
|
| 110 |
+
for _b in self._backends:
|
| 111 |
+
if not _b.models:
|
| 112 |
+
try:
|
| 113 |
+
await _b.warm()
|
| 114 |
+
except Exception:
|
| 115 |
+
pass
|
| 116 |
inp = req.body.get("input", {})
|
| 117 |
messages = inp.get("messages", [])
|
| 118 |
params = req.body.get("params", {})
|
|
|
|
| 119 |
temperature = float(params.get("temperature", 0.7))
|
| 120 |
max_tokens = int(params.get("max_tokens", 1024))
|
| 121 |
try:
|
| 122 |
+
backend, model_name = self._resolve_backend(str(params.get("model") or ""))
|
| 123 |
result = await backend.chat(
|
| 124 |
messages,
|
| 125 |
model=model_name,
|
|
|
|
| 140 |
return {"error": "internal_error", "message": str(exc)}
|
| 141 |
|
| 142 |
async def _handle_complete(self, req: RouteRequest) -> dict:
|
| 143 |
+
for _b in self._backends:
|
| 144 |
+
if not _b.models:
|
| 145 |
+
try:
|
| 146 |
+
await _b.warm()
|
| 147 |
+
except Exception:
|
| 148 |
+
pass
|
| 149 |
inp = req.body.get("input", {})
|
| 150 |
prompt = inp.get("prompt", "")
|
| 151 |
params = req.body.get("params", {})
|
|
|
|
| 152 |
try:
|
| 153 |
+
backend, model_name = self._resolve_backend(str(params.get("model") or ""))
|
| 154 |
result = await backend.complete(prompt, model=model_name, stream=False)
|
| 155 |
return {
|
| 156 |
"output": {"text": result.text},
|
hearthnet/ui/__pycache__/onboarding.cpython-313.pyc
CHANGED
|
Binary files a/hearthnet/ui/__pycache__/onboarding.cpython-313.pyc and b/hearthnet/ui/__pycache__/onboarding.cpython-313.pyc differ
|
|
|
count_all_tests.py β scripts/count_all_tests.py
RENAMED
|
File without changes
|
fill_phase23.py β scripts/fill_phase23.py
RENAMED
|
File without changes
|
fill_reference.py β scripts/fill_reference.py
RENAMED
|
File without changes
|
fill_tests.py β scripts/fill_tests.py
RENAMED
|
File without changes
|
gen_tests.py β scripts/gen_tests.py
RENAMED
|
File without changes
|
generate_coverage.py β scripts/generate_coverage.py
RENAMED
|
File without changes
|
tasks.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
| 5 |
All Phase 1 (M01-M13, X01-X04), Phase 2 (M14-M25, X05-X07), and Phase 3 experimental
|
| 6 |
(M26-M31) modules are implemented. **489 tests pass, 59 skipped (E2E), 0 fail**.
|
| 7 |
|
| 8 |
-
See [ARCHITECTURE.md](ARCHITECTURE.md) for the full module map, data flows, and local-to-HF setup guide.
|
| 9 |
-
See [docs/IMPROVEMENTS.md](docs/IMPROVEMENTS.md) for the full improvement backlog and prize targeting analysis.
|
| 10 |
|
| 11 |
---
|
| 12 |
|
| 13 |
-
## Maximize Real Activation (June 12) β see [upgrade_plan.md](upgrade_plan.md)
|
| 14 |
|
| 15 |
Full 10-phase upgrade to make every feasible capability *genuinely real* (no mocks,
|
| 16 |
fakes, or `# noqa`/`# nosec` bypasses). **Net result: +18 passing tests, β6 failing,
|
|
@@ -104,7 +104,7 @@ pre-existing `playwright` `ModuleNotFound` (optional browser-test dep).
|
|
| 104 |
MiniCPM (MINICPM_URL), and Modal (MODAL_ENDPOINT) backends from env vars
|
| 105 |
- README: added `nemotron`, `minicpm`, `modal` tags; expanded hackathon section
|
| 106 |
with sponsor prize targeting table
|
| 107 |
-
- `docs/IMPROVEMENTS.md`: comprehensive improvement backlog with GPT-4o rating,
|
| 108 |
29 improvement items, and priority matrix
|
| 109 |
|
| 110 |
**README + submission (June 11):**
|
|
|
|
| 5 |
All Phase 1 (M01-M13, X01-X04), Phase 2 (M14-M25, X05-X07), and Phase 3 experimental
|
| 6 |
(M26-M31) modules are implemented. **489 tests pass, 59 skipped (E2E), 0 fail**.
|
| 7 |
|
| 8 |
+
See [ARCHITECTURE.md](docs/ARCHITECTURE.md) for the full module map, data flows, and local-to-HF setup guide.
|
| 9 |
+
See [docs/reports/IMPROVEMENTS.md](docs/reports/IMPROVEMENTS.md) for the full improvement backlog and prize targeting analysis.
|
| 10 |
|
| 11 |
---
|
| 12 |
|
| 13 |
+
## Maximize Real Activation (June 12) β see [upgrade_plan.md](docs/upgrade_plan.md)
|
| 14 |
|
| 15 |
Full 10-phase upgrade to make every feasible capability *genuinely real* (no mocks,
|
| 16 |
fakes, or `# noqa`/`# nosec` bypasses). **Net result: +18 passing tests, β6 failing,
|
|
|
|
| 104 |
MiniCPM (MINICPM_URL), and Modal (MODAL_ENDPOINT) backends from env vars
|
| 105 |
- README: added `nemotron`, `minicpm`, `modal` tags; expanded hackathon section
|
| 106 |
with sponsor prize targeting table
|
| 107 |
+
- `docs/reports/IMPROVEMENTS.md`: comprehensive improvement backlog with GPT-4o rating,
|
| 108 |
29 improvement items, and priority matrix
|
| 109 |
|
| 110 |
**README + submission (June 11):**
|