MCPcopy
hub / github.com/AstrBotDevs/AstrBot / _request_img_caption

Function _request_img_caption

astrbot/core/astr_main_agent.py:620–645  ·  view source on GitHub ↗
(
    provider_id: str,
    cfg: dict,
    image_urls: list[str],
    plugin_context: Context,
)

Source from the content-addressed store, hash-verified

618
619
620async def _request_img_caption(
621 provider_id: str,
622 cfg: dict,
623 image_urls: list[str],
624 plugin_context: Context,
625) -> str:
626 prov = plugin_context.get_provider_by_id(provider_id)
627 if prov is None:
628 raise ValueError(
629 f"Cannot get image caption because provider `{provider_id}` is not exist.",
630 )
631 if not isinstance(prov, Provider):
632 raise ValueError(
633 f"Cannot get image caption because provider `{provider_id}` is not a valid Provider, it is {type(prov)}.",
634 )
635
636 img_cap_prompt = cfg.get(
637 "image_caption_prompt",
638 "Please describe the image.",
639 )
640 logger.debug("Processing image caption with provider: %s", provider_id)
641 llm_resp = await prov.text_chat(
642 prompt=img_cap_prompt,
643 image_urls=image_urls,
644 )
645 return llm_resp.completion_text
646
647
648async def _ensure_img_caption(

Callers 1

_ensure_img_captionFunction · 0.85

Calls 3

get_provider_by_idMethod · 0.45
getMethod · 0.45
text_chatMethod · 0.45

Tested by

no test coverage detected