@@ -483,15 +483,13 @@ async def _request_img_caption(
483483async def pre_caption_images (
484484 event : AstrMessageEvent ,
485485 plugin_context : Context ,
486+ cfg : dict ,
486487) -> None :
487488 """在 session lock 外提前完成图片描述,结果写入 event extra。
488489
489490 由 pipeline 在获取 session lock 之前调用,避免图片描述慢速 LLM
490491 调用占用 session lock,阻塞后续消息处理。
491492 """
492- cfg = plugin_context .get_config (umo = event .unified_msg_origin ).get (
493- "provider_settings" , {}
494- )
495493 img_cap_prov_id : str = cfg .get ("default_image_caption_provider_id" ) or ""
496494 if not img_cap_prov_id :
497495 return
@@ -519,7 +517,7 @@ async def pre_caption_images(
519517 )
520518 event .set_extra (_PRE_CAPTION_RESULT_KEY , caption or "" )
521519 except Exception as exc : # noqa: BLE001
522- logger .error ("预处理图片描述失败: %s" , exc )
520+ logger .error ("预处理图片描述失败: %s" , exc , exc_info = True )
523521 event .set_extra (_PRE_CAPTION_RESULT_KEY , None )
524522
525523
@@ -530,12 +528,14 @@ async def _ensure_img_caption(
530528 plugin_context : Context ,
531529 image_caption_provider : str ,
532530) -> None :
531+ if event .get_extra ("_skip_img_caption" ):
532+ return
533+
533534 pre_caption = event .get_extra (_PRE_CAPTION_RESULT_KEY )
534- if pre_caption is not None :
535- if pre_caption :
536- req .extra_user_content_parts .append (
537- TextPart (text = f"<image_caption>{ pre_caption } </image_caption>" )
538- )
535+ if pre_caption :
536+ req .extra_user_content_parts .append (
537+ TextPart (text = f"<image_caption>{ pre_caption } </image_caption>" )
538+ )
539539 req .image_urls = []
540540 return
541541
0 commit comments