AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.channel

FeishuChannel

class FeishuChannel(ChannelBase)
源码Source agentscope/app/channel/_feishu/_channel.py:91–1367

Feishu 渠道,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.channel 包,继承自 ChannelBase。核心成员包括 start_listening、chat_name、chat_kind、send_response、send_reaction、remove_reaction。

Feishu platform channel (SDK long-connection mode). Declared in agentscope.app.channel. Extends ChannelBase.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Credentials类class
凭证,把智能体接入外部消息渠道与企业平台。
Feishu bot application credentials.
Config类class
配置,保存相关配置项。
Feishu platform options.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(channel_id: str, credentials: 'FeishuChannel.Credentials', config: 'FeishuChannel.Config') -> None
初始化 `FeishuChannel` 实例。
Read the credentials and options from the validated models.

属性摘要Property Summary

属性Property说明Description
channel_id
获取渠道标识。
The unique channel instance identifier.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
channel_type—
渠道类型字段。
'feishu'
display_name—
展示名称字段。
'Feishu (Lark)'
description—
`description` 字段。
'Group and direct-message bot with card interactions.'
icon_url—
`icon_url` 字段。
'https://www.google.com/s2/favicons?domain=feishu.cn&sz=128'
platform_bot_id_field—
`platform_bot_id_field` 字段。
'app_id'
credential_binding—
凭证绑定字段。
FeishuCredentialBinding
capabilities—
能力字段。
ChannelCapability(text=True, markdown=True, image=True, file=True, interactive=True, streaming=True, max_message_length=4000)

方法摘要Method Summary

方法Method说明Description
async def start_listening(emit: Callable[[ChannelEvent | ChannelConfirmationResultEvent], Awaitable[None]]) -> Noneasync
启动 `start_listening`。
Open the HTTP client, run the WS client (reconnecting with backoff), and close everything on exit.
async def chat_name(chat_id: str) -> strasync
设置聊天名称。
The chat's title (cached per chat); ``""`` when unavailable — a 1:1 chat, a not-yet-named group, or a missing ``im:chat`` scope.
async def chat_kind(chat_id: str) -> ChatKind | Noneasync
设置聊天种类。
Group vs 1:1 for a chat — from the inbound cache, else the get-chat API (``chat_mode``). ``None`` when unknown.
async def send_response(event: ChannelEvent, events: AsyncIterator[dict]) -> Noneasync
发送响应。
Stream the reply into a live CardKit card, presenting an approval card when the run parks; fall back to one-shot text if the streaming card cannot be created.
async def send_reaction(event: ChannelEvent, emoji_type: str) -> str | Noneasync
发送 `send_reaction`。
Add an emoji reaction to the inbound message.
async def remove_reaction(event: ChannelEvent, reaction_id: str) -> Noneasync
移除 `remove_reaction`。
Remove a reaction previously added by :meth:`send_reaction`.
async def list_bot_chats() -> list[dict]async
列出 `list_bot_chats`。
List the chats the bot is in as ``{chat_id, name, chat_type}``.
async def list_tools(workspace: 'WorkspaceBase', channel_user_id: str | None = None) -> list['ToolBase']async
列出当前连接可用的工具。
Expose the Feishu send/discovery tools to the agent.
async def send_message_to(receive_id: str, receive_id_type: str, text: str) -> dict | Noneasync
发送消息到。
Send a plain-text message to an arbitrary receive_id.
async def send_file_to(receive_id: str, receive_id_type: str, data: bytes, file_name: str) -> dict | Noneasync
发送文件到。
Upload a file (→ file_key) then send it to a receive_id.
async def send_image_to(receive_id: str, receive_id_type: str, data: bytes) -> dict | Noneasync
发送图像到。
Upload an image (→ image_key) then send it to a receive_id.
async def list_chat_members(chat_id: str) -> list[dict]async
列出聊天成员。
List a group's members as ``{open_id, name}`` dicts.
async def aclose() -> Noneasync
返回 `aclose` 结果。
Close the HTTP client this instance opened lazily.

构造器详情Constructor Detail

FeishuChannel

def __init__(channel_id: str, credentials: 'FeishuChannel.Credentials', config: 'FeishuChannel.Config') -> None

初始化 FeishuChannel 实例。

Read the credentials and options from the validated models.

参数Parameters
名称Name类型Type说明Description
channel_idstr渠道标识(类型 `str`)。This channel instance's unique id.
credentials'FeishuChannel.Credentials'凭证(类型 `'FeishuChannel.Credentials'`)。Validated app id + secret.
config'FeishuChannel.Config'配置对象(类型 `'FeishuChannel.Config'`)。Validated platform options.
源码Source agentscope/app/channel/_feishu/_channel.py:141–174

属性详情Attribute Detail

channel_type

 = 'feishu'

渠道类型字段。

The channel type field.

源码Source agentscope/app/channel/_feishu/_channel.py:94

display_name

 = 'Feishu (Lark)'

展示名称字段。

The display name field.

源码Source agentscope/app/channel/_feishu/_channel.py:95

description

 = 'Group and direct-message bot with card interactions.'

description 字段。

The description field.

源码Source agentscope/app/channel/_feishu/_channel.py:96

icon_url

 = 'https://www.google.com/s2/favicons?domain=feishu.cn&sz=128'

icon_url 字段。

The icon url field.

源码Source agentscope/app/channel/_feishu/_channel.py:97

platform_bot_id_field

 = 'app_id'

platform_bot_id_field 字段。

The platform bot id field field.

源码Source agentscope/app/channel/_feishu/_channel.py:98

credential_binding

 = FeishuCredentialBinding

凭证绑定字段。

The credential binding field.

源码Source agentscope/app/channel/_feishu/_channel.py:99

capabilities

 = ChannelCapability(text=True, markdown=True, image=True, file=True, interactive=True, streaming=True, max_message_length=4000)

能力字段。

The capabilities field.

源码Source agentscope/app/channel/_feishu/_channel.py:131

属性详情Property Detail

channel_id

def channel_id() -> str

获取渠道标识。

The unique channel instance identifier.

返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/channel/_feishu/_channel.py:177–179

方法详情Method Detail

start_listening

async def start_listening(emit: Callable[[ChannelEvent | ChannelConfirmationResultEvent], Awaitable[None]]) -> None
async

启动 start_listening。

Open the HTTP client, run the WS client (reconnecting with backoff), and close everything on exit.

参数Parameters
名称Name类型Type说明Description
emitCallable[[ChannelEvent | ChannelConfirmationResultEvent], Awaitable[None]]用于入站事件的网关回调。Gateway callback for inbound events.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_feishu/_channel.py:183–274

chat_name

async def chat_name(chat_id: str) -> str
async

设置聊天名称。

The chat's title (cached per chat); "" when unavailable — a 1:1 chat, a not-yet-named group, or a missing im:chat scope.

参数Parameters
名称Name类型Type说明Description
chat_idstr聊天标识(类型 `str`)。The chat to look up.
返回Returns str
返回字符串结果。Returns a string.
源码Source agentscope/app/channel/_feishu/_channel.py:461–479

chat_kind

async def chat_kind(chat_id: str) -> ChatKind | None
async

设置聊天种类。

Group vs 1:1 for a chat — from the inbound cache, else the get-chat API (chat_mode).

参数Parameters
名称Name类型Type说明Description
chat_idstr聊天标识(类型 `str`)。The chat to classify.
返回Returns ChatKind | None
返回ChatKind|None。Returns chat kind none.
源码Source agentscope/app/channel/_feishu/_channel.py:481–498

send_response

async def send_response(event: ChannelEvent, events: AsyncIterator[dict]) -> None
async

发送响应。

Stream the reply into a live CardKit card, presenting an approval card when the run parks; fall back to one-shot text if the streaming card cannot be created.

参数Parameters
名称Name类型Type说明Description
eventChannelEvent发送目标(聊天标识)。The send target (chat id).
eventsAsyncIterator[dict]运行's 会话事件。The run's session events.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_feishu/_channel.py:654–734

send_reaction

async def send_reaction(event: ChannelEvent, emoji_type: str) -> str | None
async

发送 send_reaction。

Add an emoji reaction to the inbound message.

参数Parameters
名称Name类型Type说明Description
eventChannelEvent消息到 ReAct 到。The message to react to.
emoji_typestremoji 类型(类型 `str`)。The Feishu emoji type (e.g. `"OnIt"`).
返回Returns str | None
返回str|None。`str | None`: The reaction id for removal, or `None`.
源码Source agentscope/app/channel/_feishu/_channel.py:872–895

remove_reaction

async def remove_reaction(event: ChannelEvent, reaction_id: str) -> None
async

移除 remove_reaction。

Remove a reaction previously added by :meth:send_reaction.

参数Parameters
名称Name类型Type说明Description
eventChannelEvent事件(类型 `ChannelEvent`)。The reacted-to message.
reaction_idstrreaction 标识(类型 `str`)。The reaction id to remove.
返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_feishu/_channel.py:897–914

list_bot_chats

async def list_bot_chats() -> list[dict]
async

列出 list_bot_chats。

List the chats the bot is in as {chat_id, name, chat_type}.

返回Returns list[dict]
返回dict列表。Returns a list of dict.
源码Source agentscope/app/channel/_feishu/_channel.py:916–939

list_tools

async def list_tools(workspace: 'WorkspaceBase', channel_user_id: str | None = None) -> list['ToolBase']
async

列出当前连接可用的工具。

Expose the Feishu send/discovery tools to the agent.

参数Parameters
名称Name类型Type说明Description
workspace'WorkspaceBase'工作区(类型 `'WorkspaceBase'`)。The calling session's workspace; the send-file tools read their payload from its backend by absolute path.
channel_user_id默认default Nonestr | None渠道用户标识(类型 `str | None`)。The platform user the session acts as, passed through to the inherited tools.
返回Returns list['ToolBase']
返回'ToolBase'列表。`list[ToolBase]`: The Feishu agent tools.
源码Source agentscope/app/channel/_feishu/_channel.py:941–973

send_message_to

async def send_message_to(receive_id: str, receive_id_type: str, text: str) -> dict | None
async

发送消息到。

Send a plain-text message to an arbitrary receive_id.

参数Parameters
名称Name类型Type说明Description
receive_idstr接收标识(类型 `str`)。The recipient id.
receive_id_typestr接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc.
textstr消息文本。The message text.
返回Returns dict | None
返回dict|None。`dict | None`: The Feishu API response, or `None` on error.
源码Source agentscope/app/channel/_feishu/_channel.py:977–1001

send_file_to

async def send_file_to(receive_id: str, receive_id_type: str, data: bytes, file_name: str) -> dict | None
async

发送文件到。

Upload a file (→ file_key) then send it to a receive_id.

参数Parameters
名称Name类型Type说明Description
receive_idstr接收标识(类型 `str`)。The recipient id.
receive_id_typestr接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc.
databytes文件字节。The file bytes.
file_namestr文件's 展示名称。The file's display name.
返回Returns dict | None
返回dict|None。`dict | None`: The send response, or `None` on error.
源码Source agentscope/app/channel/_feishu/_channel.py:1003–1037

send_image_to

async def send_image_to(receive_id: str, receive_id_type: str, data: bytes) -> dict | None
async

发送图像到。

Upload an image (→ image_key) then send it to a receive_id.

参数Parameters
名称Name类型Type说明Description
receive_idstr接收标识(类型 `str`)。The recipient id.
receive_id_typestr接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc.
databytes图像字节。The image bytes.
返回Returns dict | None
返回dict|None。`dict | None`: The send response, or `None` on error.
源码Source agentscope/app/channel/_feishu/_channel.py:1039–1071

list_chat_members

async def list_chat_members(chat_id: str) -> list[dict]
async

列出聊天成员。

List a group's members as {open_id, name} dicts.

参数Parameters
名称Name类型Type说明Description
chat_idstr聊天标识(类型 `str`)。The group whose members to list.
返回Returns list[dict]
返回dict列表。`list[dict]`: One `{open_id, name}` per member.
源码Source agentscope/app/channel/_feishu/_channel.py:1073–1105

aclose

async def aclose() -> None
async

返回 aclose 结果。

The connection loop closes its own in start_listening; this covers the client-only instances, which never run it.

返回Returns None
无返回值。No value is returned.
源码Source agentscope/app/channel/_feishu/_channel.py:1159–1168

嵌套类详情Nested Class Detail

Credentials

class Credentials

凭证,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.channel 包。

Feishu bot application credentials. Declared in agentscope.app.channel.

Config

class Config

配置,保存相关配置项。位于 agentscope.app.channel 包。

Feishu platform options. Declared in agentscope.app.channel.

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.