feat: support image inputs in assistant tests
This commit is contained in:
@@ -14,6 +14,7 @@ from db.session import SessionLocal
|
||||
from models import RuntimeModelResource
|
||||
from services.config_resolver import resolve_runtime_config
|
||||
from services.runtime_variables import prepare_dynamic_config
|
||||
from services.test_case_assets import load_test_asset_bytes
|
||||
from services.test_runs.errors import TestExecutionError
|
||||
from services.test_runs.evaluator import EvaluationEngine
|
||||
from services.test_runs.text_runner import (
|
||||
@@ -178,6 +179,19 @@ class TestRunOrchestrator:
|
||||
snapshot = dict(row.case_snapshot or {})
|
||||
definition = TestCaseDefinition.model_validate(snapshot)
|
||||
max_attempts = row.max_attempts
|
||||
try:
|
||||
image_assets = await load_test_asset_bytes(session, definition)
|
||||
except Exception as exc:
|
||||
await self._mark_error(
|
||||
run_case_id,
|
||||
TestExecutionError(
|
||||
code="TEST_IMAGE_READ_FAILED",
|
||||
message=str(exc) or "测试图片无法读取",
|
||||
stage="pipeline",
|
||||
retryable=True,
|
||||
),
|
||||
)
|
||||
return
|
||||
|
||||
for attempt in range(1, max_attempts + 1):
|
||||
if control.stop_event.is_set():
|
||||
@@ -212,6 +226,7 @@ class TestRunOrchestrator:
|
||||
attempt_cfg,
|
||||
definition,
|
||||
timeout_seconds=timeout_seconds,
|
||||
image_assets=image_assets,
|
||||
on_turn_complete=save_turn_progress,
|
||||
on_startup_complete=save_startup_progress,
|
||||
)
|
||||
@@ -346,6 +361,11 @@ class TestRunOrchestrator:
|
||||
"id": turn.id,
|
||||
"index": turn.index,
|
||||
"userInput": turn.user_input,
|
||||
"image": (
|
||||
turn.image.model_dump(mode="json", by_alias=True)
|
||||
if turn.image is not None
|
||||
else None
|
||||
),
|
||||
"assistantReply": turn.assistant_reply,
|
||||
"toolCalls": [item.as_result() for item in turn.tool_calls],
|
||||
"runtimeRecords": list(turn.runtime_records),
|
||||
|
||||
Reference in New Issue
Block a user