Spaces:
Running on Zero
Running on Zero
fix: avoid embedding work during bootstrap
Browse filesCo-authored-by: Codex <noreply@openai.com>
- app.py +1 -1
- hackathon_advisor/data.py +12 -0
- static/app.js +1 -1
- static/index.html +1 -1
- tests/test_app.py +7 -1
- tests/test_frontend_copy.py +1 -1
app.py
CHANGED
|
@@ -134,7 +134,7 @@ def bootstrap() -> dict:
|
|
| 134 |
"voice": voice_transcriber.status().to_dict(),
|
| 135 |
**trace_metadata(index),
|
| 136 |
"top_projects": [project.to_public_dict() for project in index.top_projects(limit=8)],
|
| 137 |
-
"whitespace": [item.to_dict() for item in index.
|
| 138 |
"goal_options": GOALS,
|
| 139 |
"goal_profiles": goal_profiles(),
|
| 140 |
"default_goals": GOALS[:3],
|
|
|
|
| 134 |
"voice": voice_transcriber.status().to_dict(),
|
| 135 |
**trace_metadata(index),
|
| 136 |
"top_projects": [project.to_public_dict() for project in index.top_projects(limit=8)],
|
| 137 |
+
"whitespace": [item.to_dict() for item in index.starter_directions(limit=5)],
|
| 138 |
"goal_options": GOALS,
|
| 139 |
"goal_profiles": goal_profiles(),
|
| 140 |
"default_goals": GOALS[:3],
|
hackathon_advisor/data.py
CHANGED
|
@@ -319,6 +319,18 @@ class ProjectIndex:
|
|
| 319 |
items.sort(key=lambda item: item.score, reverse=True)
|
| 320 |
return items[:limit]
|
| 321 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
def _embed_query(self, query: str) -> Sequence[float]:
|
| 323 |
if self._query_embedder is None:
|
| 324 |
from hackathon_advisor.llama_embedding import create_llama_cpp_embedder
|
|
|
|
| 319 |
items.sort(key=lambda item: item.score, reverse=True)
|
| 320 |
return items[:limit]
|
| 321 |
|
| 322 |
+
def starter_directions(self, limit: int = 5) -> list[WhitespaceItem]:
|
| 323 |
+
return [
|
| 324 |
+
WhitespaceItem(
|
| 325 |
+
label=seed.label,
|
| 326 |
+
pitch=seed.pitch,
|
| 327 |
+
evidence="Press this direction to test it against the current project map.",
|
| 328 |
+
score=0.0,
|
| 329 |
+
nearby_projects=(),
|
| 330 |
+
)
|
| 331 |
+
for seed in WHITESPACE_SEEDS[:limit]
|
| 332 |
+
]
|
| 333 |
+
|
| 334 |
def _embed_query(self, query: str) -> Sequence[float]:
|
| 335 |
if self._query_embedder is None:
|
| 336 |
from hackathon_advisor.llama_embedding import create_llama_cpp_embedder
|
static/app.js
CHANGED
|
@@ -1097,7 +1097,7 @@ function renderCitations(echoes) {
|
|
| 1097 |
function renderWhitespace(items) {
|
| 1098 |
whitespaceEl.innerHTML = "";
|
| 1099 |
if (!items.length) {
|
| 1100 |
-
whitespaceEl.innerHTML = `<div class="empty">No
|
| 1101 |
return;
|
| 1102 |
}
|
| 1103 |
for (const item of items.slice(0, 4)) {
|
|
|
|
| 1097 |
function renderWhitespace(items) {
|
| 1098 |
whitespaceEl.innerHTML = "";
|
| 1099 |
if (!items.length) {
|
| 1100 |
+
whitespaceEl.innerHTML = `<div class="empty">No starting directions are loaded yet.</div>`;
|
| 1101 |
return;
|
| 1102 |
}
|
| 1103 |
for (const item of items.slice(0, 4)) {
|
static/index.html
CHANGED
|
@@ -266,7 +266,7 @@
|
|
| 266 |
</section>
|
| 267 |
|
| 268 |
<section class="section">
|
| 269 |
-
<div class="eyebrow">
|
| 270 |
<div id="whitespace" class="whitespace-list"></div>
|
| 271 |
</section>
|
| 272 |
</aside>
|
|
|
|
| 266 |
</section>
|
| 267 |
|
| 268 |
<section class="section">
|
| 269 |
+
<div class="eyebrow">Directions to test</div>
|
| 270 |
<div id="whitespace" class="whitespace-list"></div>
|
| 271 |
</section>
|
| 272 |
</aside>
|
tests/test_app.py
CHANGED
|
@@ -68,7 +68,12 @@ def test_health_exposes_index_metadata() -> None:
|
|
| 68 |
assert len(payload["snapshot_digest"]) == 64
|
| 69 |
|
| 70 |
|
| 71 |
-
def test_bootstrap_exposes_index_metadata() -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
payload = bootstrap()
|
| 73 |
|
| 74 |
assert payload["index_algorithm"] == "llama-cpp-embedding-v1"
|
|
@@ -77,6 +82,7 @@ def test_bootstrap_exposes_index_metadata() -> None:
|
|
| 77 |
assert payload["runtime"]["tool_count"] >= 8
|
| 78 |
assert payload["voice"]["backend"] == "nemo-asr"
|
| 79 |
assert payload["top_projects"]
|
|
|
|
| 80 |
assert payload["default_goals"] == payload["goal_options"][:3]
|
| 81 |
assert [goal["id"] for goal in payload["goal_profiles"]] == payload["goal_options"]
|
| 82 |
assert payload["goal_profiles"][0]["label"] == "Local-first"
|
|
|
|
| 68 |
assert len(payload["snapshot_digest"]) == 64
|
| 69 |
|
| 70 |
|
| 71 |
+
def test_bootstrap_exposes_index_metadata(monkeypatch) -> None:
|
| 72 |
+
def fail_query_embedder(_: str) -> tuple[float, ...]:
|
| 73 |
+
raise AssertionError("bootstrap should not load the runtime query embedder")
|
| 74 |
+
|
| 75 |
+
monkeypatch.setattr(index, "_query_embedder", fail_query_embedder)
|
| 76 |
+
|
| 77 |
payload = bootstrap()
|
| 78 |
|
| 79 |
assert payload["index_algorithm"] == "llama-cpp-embedding-v1"
|
|
|
|
| 82 |
assert payload["runtime"]["tool_count"] >= 8
|
| 83 |
assert payload["voice"]["backend"] == "nemo-asr"
|
| 84 |
assert payload["top_projects"]
|
| 85 |
+
assert payload["whitespace"]
|
| 86 |
assert payload["default_goals"] == payload["goal_options"][:3]
|
| 87 |
assert [goal["id"] for goal in payload["goal_profiles"]] == payload["goal_options"]
|
| 88 |
assert payload["goal_profiles"][0]["label"] == "Local-first"
|
tests/test_frontend_copy.py
CHANGED
|
@@ -6,7 +6,7 @@ def test_main_interface_copy_is_builder_facing() -> None:
|
|
| 6 |
app_js = Path("static/app.js").read_text(encoding="utf-8")
|
| 7 |
combined = f"{html}\n{app_js}"
|
| 8 |
|
| 9 |
-
assert "
|
| 10 |
assert "Closest project echoes" in html
|
| 11 |
assert "Press Plan to draft build steps for the selected idea." in app_js
|
| 12 |
assert "Loading an example idea board." in app_js
|
|
|
|
| 6 |
app_js = Path("static/app.js").read_text(encoding="utf-8")
|
| 7 |
combined = f"{html}\n{app_js}"
|
| 8 |
|
| 9 |
+
assert "Directions to test" in html
|
| 10 |
assert "Closest project echoes" in html
|
| 11 |
assert "Press Plan to draft build steps for the selected idea." in app_js
|
| 12 |
assert "Loading an example idea board." in app_js
|