Adam Cseresznye commited on
Commit ·
e7633a1
1
Parent(s): 9a32423
update UI, tests
Browse files- tests/unit/test_acquisition_agent.py +10 -20
- tests/unit/test_synthesis_agent.py +1 -1
- ui/pages.py +7 -2
tests/unit/test_acquisition_agent.py
CHANGED
|
@@ -95,7 +95,7 @@ async def test_acquisition_enriches_state_success(monkeypatch):
|
|
| 95 |
new_state = await agent.process(state)
|
| 96 |
|
| 97 |
assert new_state.passages is not None
|
| 98 |
-
assert len(new_state.passages) ==
|
| 99 |
pdf_passages = [p for p in new_state.passages if p["text_source"] == "pdf"]
|
| 100 |
assert len(pdf_passages) == 1
|
| 101 |
p = pdf_passages[0]
|
|
@@ -125,9 +125,7 @@ async def test_acquisition_timeout_skips(monkeypatch):
|
|
| 125 |
|
| 126 |
new_state = await agent.process(state)
|
| 127 |
assert new_state.passages is not None
|
| 128 |
-
assert len(new_state.passages) ==
|
| 129 |
-
p = new_state.passages[0]
|
| 130 |
-
assert p["text_source"] == "abstract"
|
| 131 |
|
| 132 |
|
| 133 |
@pytest.mark.unit
|
|
@@ -149,9 +147,7 @@ async def test_acquisition_http_404_skips(monkeypatch):
|
|
| 149 |
|
| 150 |
new_state = await agent.process(state)
|
| 151 |
assert new_state.passages is not None
|
| 152 |
-
assert len(new_state.passages) ==
|
| 153 |
-
p = new_state.passages[0]
|
| 154 |
-
assert p["text_source"] == "abstract"
|
| 155 |
|
| 156 |
|
| 157 |
@pytest.mark.unit
|
|
@@ -175,9 +171,7 @@ async def test_acquisition_malformed_pdf_skips(monkeypatch):
|
|
| 175 |
new_state = await agent.process(state)
|
| 176 |
# should be skipped
|
| 177 |
assert new_state.passages is not None
|
| 178 |
-
assert len(new_state.passages) ==
|
| 179 |
-
p = new_state.passages[0]
|
| 180 |
-
assert p["text_source"] == "abstract"
|
| 181 |
|
| 182 |
|
| 183 |
@pytest.mark.unit
|
|
@@ -200,11 +194,9 @@ async def test_acquisition_zero_successes_appends_error(monkeypatch):
|
|
| 200 |
|
| 201 |
new_state = await agent.process(state)
|
| 202 |
assert new_state.passages is not None
|
| 203 |
-
assert len(new_state.passages) ==
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
# No error since abstracts are acquired
|
| 207 |
-
assert not new_state.errors
|
| 208 |
|
| 209 |
|
| 210 |
@pytest.mark.unit
|
|
@@ -240,9 +232,7 @@ async def test_acquisition_get_raises_timeout(monkeypatch):
|
|
| 240 |
|
| 241 |
new_state = await agent.process(state)
|
| 242 |
assert new_state.passages is not None
|
| 243 |
-
assert len(new_state.passages) ==
|
| 244 |
-
p = new_state.passages[0]
|
| 245 |
-
assert p["text_source"] == "abstract"
|
| 246 |
|
| 247 |
|
| 248 |
@pytest.mark.unit
|
|
@@ -275,9 +265,9 @@ async def test_acquisition_parallel_10_with_2_failures(monkeypatch):
|
|
| 275 |
new_state = await agent.process(state)
|
| 276 |
elapsed = time.monotonic() - start
|
| 277 |
|
| 278 |
-
# successful should be 5 PDFs (target limit)
|
| 279 |
passages = new_state.passages or []
|
| 280 |
-
assert len(passages) ==
|
| 281 |
pdf_passages = [p for p in passages if p["text_source"] == "pdf"]
|
| 282 |
assert len(pdf_passages) == 5
|
| 283 |
# requirement: return in under 4 seconds in real world; here ensure it's fast
|
|
|
|
| 95 |
new_state = await agent.process(state)
|
| 96 |
|
| 97 |
assert new_state.passages is not None
|
| 98 |
+
assert len(new_state.passages) == 1
|
| 99 |
pdf_passages = [p for p in new_state.passages if p["text_source"] == "pdf"]
|
| 100 |
assert len(pdf_passages) == 1
|
| 101 |
p = pdf_passages[0]
|
|
|
|
| 125 |
|
| 126 |
new_state = await agent.process(state)
|
| 127 |
assert new_state.passages is not None
|
| 128 |
+
assert len(new_state.passages) == 0
|
|
|
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
@pytest.mark.unit
|
|
|
|
| 147 |
|
| 148 |
new_state = await agent.process(state)
|
| 149 |
assert new_state.passages is not None
|
| 150 |
+
assert len(new_state.passages) == 0
|
|
|
|
|
|
|
| 151 |
|
| 152 |
|
| 153 |
@pytest.mark.unit
|
|
|
|
| 171 |
new_state = await agent.process(state)
|
| 172 |
# should be skipped
|
| 173 |
assert new_state.passages is not None
|
| 174 |
+
assert len(new_state.passages) == 0
|
|
|
|
|
|
|
| 175 |
|
| 176 |
|
| 177 |
@pytest.mark.unit
|
|
|
|
| 194 |
|
| 195 |
new_state = await agent.process(state)
|
| 196 |
assert new_state.passages is not None
|
| 197 |
+
assert len(new_state.passages) == 0
|
| 198 |
+
# Error since no PDFs acquired
|
| 199 |
+
assert new_state.errors
|
|
|
|
|
|
|
| 200 |
|
| 201 |
|
| 202 |
@pytest.mark.unit
|
|
|
|
| 232 |
|
| 233 |
new_state = await agent.process(state)
|
| 234 |
assert new_state.passages is not None
|
| 235 |
+
assert len(new_state.passages) == 0
|
|
|
|
|
|
|
| 236 |
|
| 237 |
|
| 238 |
@pytest.mark.unit
|
|
|
|
| 265 |
new_state = await agent.process(state)
|
| 266 |
elapsed = time.monotonic() - start
|
| 267 |
|
| 268 |
+
# successful should be 5 PDFs (target limit)
|
| 269 |
passages = new_state.passages or []
|
| 270 |
+
assert len(passages) == 5
|
| 271 |
pdf_passages = [p for p in passages if p["text_source"] == "pdf"]
|
| 272 |
assert len(pdf_passages) == 5
|
| 273 |
# requirement: return in under 4 seconds in real world; here ensure it's fast
|
tests/unit/test_synthesis_agent.py
CHANGED
|
@@ -204,7 +204,7 @@ def test_agent_initialization():
|
|
| 204 |
"""SynthesisAgent should initialize with default temperature."""
|
| 205 |
agent = SynthesisAgent()
|
| 206 |
|
| 207 |
-
assert agent.temperature == 0.
|
| 208 |
assert agent.router is not None
|
| 209 |
|
| 210 |
|
|
|
|
| 204 |
"""SynthesisAgent should initialize with default temperature."""
|
| 205 |
agent = SynthesisAgent()
|
| 206 |
|
| 207 |
+
assert agent.temperature == 0.15
|
| 208 |
assert agent.router is not None
|
| 209 |
|
| 210 |
|
ui/pages.py
CHANGED
|
@@ -274,7 +274,12 @@ def init_ui(fastapi_app):
|
|
| 274 |
).props("no-spinner")
|
| 275 |
|
| 276 |
ui.label("Necthrall").classes(
|
| 277 |
-
"text-2xl md:text-4xl font-bold text-slate-800 leading-none pb-1 md:pb-2"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
)
|
| 279 |
|
| 280 |
# About button
|
|
@@ -472,7 +477,7 @@ def init_ui(fastapi_app):
|
|
| 472 |
# Center everything on all sizes: branding and links stacked and centered
|
| 473 |
with ui.column().classes("w-full items-center gap-2 text-center"):
|
| 474 |
ui.label(
|
| 475 |
-
f"© {str(datetime.date.today().year)} Necthrall.
|
| 476 |
).classes("font-bold")
|
| 477 |
ui.label(
|
| 478 |
"AI can make mistakes. Always verify important citations."
|
|
|
|
| 274 |
).props("no-spinner")
|
| 275 |
|
| 276 |
ui.label("Necthrall").classes(
|
| 277 |
+
"text-2xl md:text-4xl font-bold text-slate-800 leading-none pb-1 md:pb-2 cursor-pointer"
|
| 278 |
+
).on(
|
| 279 |
+
"click",
|
| 280 |
+
lambda e=None: ui.run_javascript(
|
| 281 |
+
"if (window.location.pathname !== '/') { window.location.href = '/'; } else { window.location.reload(); }"
|
| 282 |
+
),
|
| 283 |
)
|
| 284 |
|
| 285 |
# About button
|
|
|
|
| 477 |
# Center everything on all sizes: branding and links stacked and centered
|
| 478 |
with ui.column().classes("w-full items-center gap-2 text-center"):
|
| 479 |
ui.label(
|
| 480 |
+
f"© {str(datetime.date.today().year)} Necthrall. All rights reserved."
|
| 481 |
).classes("font-bold")
|
| 482 |
ui.label(
|
| 483 |
"AI can make mistakes. Always verify important citations."
|