fix: split large style consensus requests
这个提交存在于:
父节点
a5ff567272
当前提交
0feb76f214
共有 8 个文件被更改,包括 177 次插入 和 40 次删除
|
|
@ -1,3 +1,7 @@
|
||||||
|
## 1.0.58
|
||||||
|
|
||||||
|
- Split large style consensus requests into grouped multi-image analysis plus a compact final merge to reduce provider timeouts.
|
||||||
|
|
||||||
## 1.0.57
|
## 1.0.57
|
||||||
|
|
||||||
- Make the persisted plugin-data selection authoritative for the dedicated cross-analysis route.
|
- Make the persisted plugin-data selection authoritative for the dedicated cross-analysis route.
|
||||||
|
|
|
||||||
|
|
@ -1427,6 +1427,9 @@ class AdvancedStyleSetService:
|
||||||
)
|
)
|
||||||
if provider is None:
|
if provider is None:
|
||||||
raise ApiError(ErrorCode.MODEL_CAPABILITY_UNCONFIRMED, "advanced style consensus route is unavailable", {"route_name": route_name})
|
raise ApiError(ErrorCode.MODEL_CAPABILITY_UNCONFIRMED, "advanced style consensus route is unavailable", {"route_name": route_name})
|
||||||
|
analysis_strategy = "single_pass"
|
||||||
|
try:
|
||||||
|
if len(sources) <= 4 or previous_cases:
|
||||||
request = VisionRecognitionRequest(
|
request = VisionRecognitionRequest(
|
||||||
display_name=f"{record.display_name} / cross-image style consensus",
|
display_name=f"{record.display_name} / cross-image style consensus",
|
||||||
image_uri=image_urls[0],
|
image_uri=image_urls[0],
|
||||||
|
|
@ -1459,7 +1462,115 @@ class AdvancedStyleSetService:
|
||||||
"automatic_review_feedback": automatic_review_feedback,
|
"automatic_review_feedback": automatic_review_feedback,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
try:
|
recognition = provider.recognize_material(request)
|
||||||
|
else:
|
||||||
|
analysis_strategy = "grouped_two_stage"
|
||||||
|
groups = [sources[index:index + 4] for index in range(0, len(sources), 4)]
|
||||||
|
partial_analyses: list[dict[str, Any]] = []
|
||||||
|
for group_index, group in enumerate(groups):
|
||||||
|
group_reports = [item for item in source_reports if item["source_id"] in {source.source_id for source in group}]
|
||||||
|
group_urls = [
|
||||||
|
_storage_image_data_url(source.source_image_uri, {}, self.storage)[0]
|
||||||
|
for source in group
|
||||||
|
]
|
||||||
|
partial_request = VisionRecognitionRequest(
|
||||||
|
display_name=f"{record.display_name} / style consensus group {group_index + 1}",
|
||||||
|
image_uri=group_urls[0],
|
||||||
|
image_uris=tuple(group_urls[1:]),
|
||||||
|
prompt=json.dumps(
|
||||||
|
{
|
||||||
|
"analysis_mode": "partial_style_consensus",
|
||||||
|
"source_reports": group_reports,
|
||||||
|
"source_ids": [source.source_id for source in group],
|
||||||
|
},
|
||||||
|
ensure_ascii=False,
|
||||||
|
),
|
||||||
|
metadata={
|
||||||
|
"recognition_instruction": _consensus_instruction(
|
||||||
|
source_ids=[source.source_id for source in group],
|
||||||
|
style_adjustment=style_adjustment,
|
||||||
|
style_adjustment_plan=style_adjustment_plan,
|
||||||
|
validation_instruction=None,
|
||||||
|
has_previous_validation=False,
|
||||||
|
),
|
||||||
|
"style_set": True,
|
||||||
|
"consensus_id": consensus_id,
|
||||||
|
"analysis_mode": "partial_style_consensus",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
partial = provider.recognize_material(partial_request)
|
||||||
|
structured = partial.structured_data if isinstance(partial.structured_data, dict) else {}
|
||||||
|
partial_analyses.append(
|
||||||
|
{
|
||||||
|
"group_index": group_index,
|
||||||
|
"source_ids": [source.source_id for source in group],
|
||||||
|
"prompt": partial.prompt,
|
||||||
|
"negative_prompt": partial.negative_prompt,
|
||||||
|
"tags": partial.tags,
|
||||||
|
"confidence": partial.confidence,
|
||||||
|
"description": partial.description,
|
||||||
|
"analysis": {
|
||||||
|
key: structured.get(key)
|
||||||
|
for key in (
|
||||||
|
"consensus_style",
|
||||||
|
"artist_signature",
|
||||||
|
"variable_style_features",
|
||||||
|
"source_content_features",
|
||||||
|
"content_leakage_exclusions",
|
||||||
|
"feature_evidence",
|
||||||
|
"generation_capsules",
|
||||||
|
"prompt_priority_groups",
|
||||||
|
"scale_capsules",
|
||||||
|
"semantic_risk_audit",
|
||||||
|
)
|
||||||
|
if key in structured
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
representative_sources = [group[0] for group in groups[:2]]
|
||||||
|
final_urls = [
|
||||||
|
_storage_image_data_url(source.source_image_uri, {}, self.storage)[0]
|
||||||
|
for source in representative_sources
|
||||||
|
]
|
||||||
|
image_manifest = [
|
||||||
|
{
|
||||||
|
"image_index": index,
|
||||||
|
"kind": "representative_source_reference",
|
||||||
|
"source_id": source.source_id,
|
||||||
|
"image_uri": source.source_image_uri,
|
||||||
|
}
|
||||||
|
for index, source in enumerate(representative_sources)
|
||||||
|
]
|
||||||
|
request = VisionRecognitionRequest(
|
||||||
|
display_name=f"{record.display_name} / final style consensus",
|
||||||
|
image_uri=final_urls[0],
|
||||||
|
image_uris=tuple(final_urls[1:]),
|
||||||
|
prompt=json.dumps(
|
||||||
|
{
|
||||||
|
"analysis_mode": "final_style_consensus",
|
||||||
|
"source_ids": [source.source_id for source in sources],
|
||||||
|
"partial_analyses": partial_analyses,
|
||||||
|
"style_adjustment_plan": style_adjustment_plan,
|
||||||
|
"human_style_feedback": style_adjustment,
|
||||||
|
},
|
||||||
|
ensure_ascii=False,
|
||||||
|
),
|
||||||
|
metadata={
|
||||||
|
"recognition_instruction": _consensus_instruction(
|
||||||
|
source_ids=[item.source_id for item in sources],
|
||||||
|
style_adjustment=style_adjustment,
|
||||||
|
style_adjustment_plan=style_adjustment_plan,
|
||||||
|
validation_instruction=_optional_text(consensus.metadata.get("validation_instruction")),
|
||||||
|
has_previous_validation=False,
|
||||||
|
),
|
||||||
|
"style_set": True,
|
||||||
|
"consensus_id": consensus_id,
|
||||||
|
"analysis_mode": "final_style_consensus",
|
||||||
|
"image_manifest": image_manifest,
|
||||||
|
"style_adjustment_plan": style_adjustment_plan,
|
||||||
|
},
|
||||||
|
)
|
||||||
recognition = provider.recognize_material(request)
|
recognition = provider.recognize_material(request)
|
||||||
except VisionProviderError as exc:
|
except VisionProviderError as exc:
|
||||||
raise ApiError(ErrorCode.GENERATION_FAILED, "advanced style cross-image analysis failed", _vision_provider_error(exc)) from None
|
raise ApiError(ErrorCode.GENERATION_FAILED, "advanced style cross-image analysis failed", _vision_provider_error(exc)) from None
|
||||||
|
|
@ -1526,6 +1637,7 @@ class AdvancedStyleSetService:
|
||||||
},
|
},
|
||||||
"comparison_context": comparison_payload,
|
"comparison_context": comparison_payload,
|
||||||
"automatic_review_feedback": automatic_review_feedback,
|
"automatic_review_feedback": automatic_review_feedback,
|
||||||
|
"analysis_strategy": analysis_strategy,
|
||||||
"image_manifest": image_manifest,
|
"image_manifest": image_manifest,
|
||||||
"effective_style_prompt": effective_prompt,
|
"effective_style_prompt": effective_prompt,
|
||||||
"effective_style_negative_prompt": effective_negative_prompt,
|
"effective_style_negative_prompt": effective_negative_prompt,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
plugin:
|
plugin:
|
||||||
name: astrbot_plugin_imagestudio
|
name: astrbot_plugin_imagestudio
|
||||||
display_name: ImageStudio
|
display_name: ImageStudio
|
||||||
version: 1.0.57
|
version: 1.0.58
|
||||||
|
|
||||||
features:
|
features:
|
||||||
quick_profile: true
|
quick_profile: true
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ from core.runtime_paths import resolve_config_path
|
||||||
from database.db_helper import load_config_payload
|
from database.db_helper import load_config_payload
|
||||||
|
|
||||||
|
|
||||||
PLUGIN_VERSION = "1.0.57"
|
PLUGIN_VERSION = "1.0.58"
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
|
||||||
4
frontend/package-lock.json
自动生成
4
frontend/package-lock.json
自动生成
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "astrbot-plugin-imagestudio-frontend",
|
"name": "astrbot-plugin-imagestudio-frontend",
|
||||||
"version": "1.0.57",
|
"version": "1.0.58",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "astrbot-plugin-imagestudio-frontend",
|
"name": "astrbot-plugin-imagestudio-frontend",
|
||||||
"version": "1.0.57",
|
"version": "1.0.58",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.2.0",
|
"@vitejs/plugin-vue": "^5.2.0",
|
||||||
"pinia": "^2.3.0",
|
"pinia": "^2.3.0",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "astrbot-plugin-imagestudio-frontend",
|
"name": "astrbot-plugin-imagestudio-frontend",
|
||||||
"version": "1.0.57",
|
"version": "1.0.58",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ name: astrbot_plugin_imagestudio
|
||||||
display_name: ImageStudio
|
display_name: ImageStudio
|
||||||
desc: AstrBot >=4.25 ImageStudio role asset and image-generation workspace for Windows, Linux, macOS and Docker.
|
desc: AstrBot >=4.25 ImageStudio role asset and image-generation workspace for Windows, Linux, macOS and Docker.
|
||||||
short_desc: AstrBot 鍐呯殑瑙掕壊璧勪骇銆佸伐浣滄祦涓庡浘鐗囩敓鎴愮鐞嗗伐浣滃彴銆?
|
short_desc: AstrBot 鍐呯殑瑙掕壊璧勪骇銆佸伐浣滄祦涓庡浘鐗囩敓鎴愮鐞嗗伐浣滃彴銆?
|
||||||
version: 1.0.57
|
version: 1.0.58
|
||||||
author: YokiiroBW
|
author: YokiiroBW
|
||||||
repo: "http://192.168.31.210:18085/YokiiroBW/astrbot_plugin_imagestudio"
|
repo: "http://192.168.31.210:18085/YokiiroBW/astrbot_plugin_imagestudio"
|
||||||
astrbot_version: ">=4.25.0,<5"
|
astrbot_version: ">=4.25.0,<5"
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,11 @@ class _StyleVisionProvider:
|
||||||
structured_data=_style_structures(prompt),
|
structured_data=_style_structures(prompt),
|
||||||
)
|
)
|
||||||
|
|
||||||
reports = json.loads(str(request.prompt or "{}"))["source_reports"]
|
payload = json.loads(str(request.prompt or "{}"))
|
||||||
|
reports = payload.get("source_reports") or [
|
||||||
|
{"source_id": source_id}
|
||||||
|
for source_id in payload.get("source_ids", [])
|
||||||
|
]
|
||||||
source_ids = [str(item["source_id"]) for item in reports]
|
source_ids = [str(item["source_id"]) for item in reports]
|
||||||
instruction = str(request.metadata.get("recognition_instruction") or "")
|
instruction = str(request.metadata.get("recognition_instruction") or "")
|
||||||
adjustment = "cooler shadows" if "cooler shadows" in instruction else ""
|
adjustment = "cooler shadows" if "cooler shadows" in instruction else ""
|
||||||
|
|
@ -554,6 +558,23 @@ class AdvancedStyleSetWorkflowTests(unittest.TestCase):
|
||||||
self.assertIsNotNone(record)
|
self.assertIsNotNone(record)
|
||||||
self.assertEqual(record.status, "awaiting_review")
|
self.assertEqual(record.status, "awaiting_review")
|
||||||
|
|
||||||
|
def test_large_consensus_uses_grouped_two_stage_vision_requests(self) -> None:
|
||||||
|
fixture = _fixture(self.root)
|
||||||
|
_import_id, consensus = _execute_source_stage(fixture, 8)
|
||||||
|
|
||||||
|
_execute_consensus(fixture, consensus)
|
||||||
|
|
||||||
|
consensus_requests = fixture.vision.requests[8:]
|
||||||
|
self.assertEqual(len(consensus_requests), 3)
|
||||||
|
self.assertEqual([1 + len(item.image_uris) for item in consensus_requests], [4, 4, 2])
|
||||||
|
self.assertEqual(
|
||||||
|
[json.loads(str(item.prompt)).get("analysis_mode") for item in consensus_requests],
|
||||||
|
["partial_style_consensus", "partial_style_consensus", "final_style_consensus"],
|
||||||
|
)
|
||||||
|
completed = fixture.advanced.get_style_consensus_run(consensus.consensus_id)
|
||||||
|
self.assertIsNotNone(completed)
|
||||||
|
self.assertEqual(completed.result.get("analysis_strategy"), "grouped_two_stage")
|
||||||
|
|
||||||
def test_style_normalization_preserves_profile_attributes_and_intact_capsule_phrases(self) -> None:
|
def test_style_normalization_preserves_profile_attributes_and_intact_capsule_phrases(self) -> None:
|
||||||
service = MaterialNormalizationService()
|
service = MaterialNormalizationService()
|
||||||
phrase = "highly glossy, sharp specular highlights on hair, skin, and eyes"
|
phrase = "highly glossy, sharp specular highlights on hair, skin, and eyes"
|
||||||
|
|
|
||||||
正在加载…
添加表格
在新工单中引用