You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
from astrbot . api import AstrBotPlugin
from astrbot . api . event import AstrMessageEvent
from astrbot . api . llm import LLMRequest
plugin = AstrBotPlugin (
" astrbot_plugin_channel_meta_inject " ,
" 渠道元数据注入 " ,
" 1.0.0 " ,
" custom "
)
@plugin.on_llm_request
async def inject_meta ( event : AstrMessageEvent , llm_req : LLMRequest ) :
plat = event . get_platform_name ( )
umo = event . unified_msg_origin
sender_id = event . get_sender_id ( )
is_group = event . is_group ( )
# 注入到请求顶层extra_params( 透传给agentx/openai兼容接口)
llm_req . extra_params [ " ast_platform " ] = plat
llm_req . extra_params [ " ast_sender_id " ] = sender_id
llm_req . extra_params [ " ast_unified_msg_origin " ] = umo
llm_req . extra_params [ " ast_is_group " ] = is_group
plugin . register ( )