fix(media): repair JSON_CONTAINS auto-routing + reconcile stale backend tests
CI / gate (push) Has been cancelled
CI / gate (push) Has been cancelled
Real bug:
- capability_registry.resolve_auto_model and chat_media._build_media_route used
`Column.op("JSON_CONTAINS")(col, val)`, but SQLAlchemy's op() accepts only ONE
argument -> TypeError on every image/video/audio auto-route, silently failing
media generation (caught as "后台生成异常"). Replaced with func.json_contains().
Test reconciliation (no production behavior change):
- tests/test_context_engine.py: tiktoken upgrade made the hardcoded len//2 token
estimates wrong; relax to tokenizer-agnostic assertions and add
structured_memory=None to the _Summary mock (code now branches on it).
- tests/test_regression_r1r2r3.py: R3 FakeModel lacked `name` (code reads m.name);
also the assertion assumed a literal '超时' string, but the failover architecture
catches model-level exceptions and writes a user-understandable error marker
instead. Align the assertion to the real contract: a media failure/timeout must
be written back as a user-understandable error message, never left as '生成中…'.
CI gate: 28 backend pytest + 15 frontend vitest all green.
This commit is contained in:
1 parent
a08ec87b22
commit
d3d8d62b94
4 files changed
+22
-17
No files matched your search
@@ -893,7 +893,7 @@ def _build_media_route(db, capability: str, preferred_id: str = None):
|
||||
|
||||
others = db.query(_AM).filter(
|
||||
_AM.is_enabled == True,
|
||||
_AM.capabilities.op("JSON_CONTAINS")(_AM.capabilities, f'"{capability}"'),
|
||||
func.json_contains(_AM.capabilities, f'"{capability}"'),
|
||||
).order_by(_AM.is_default.desc(), _AM.created_at.asc()).all()
|
||||
for m in others:
|
||||
_add(m)
|
||||
|
||||
Reference in new issue
Block a user