agentscope.app.channelFeishuChannel
class FeishuChannel(ChannelBase)
agentscope/app/channel/_feishu/_channel.py:91–1367Feishu 渠道,把智能体接入外部消息渠道与企业平台。位于 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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
channel_id | str | 渠道标识(类型 `str`)。This channel instance's unique id. |
credentials | 'FeishuChannel.Credentials' | 凭证(类型 `'FeishuChannel.Credentials'`)。Validated app id + secret. |
config | 'FeishuChannel.Config' | 配置对象(类型 `'FeishuChannel.Config'`)。Validated platform options. |
agentscope/app/channel/_feishu/_channel.py:141–174属性详情Attribute Detail
channel_type
= 'feishu'渠道类型字段。
The channel type field.
agentscope/app/channel/_feishu/_channel.py:94display_name
= 'Feishu (Lark)'展示名称字段。
The display name field.
agentscope/app/channel/_feishu/_channel.py:95description
= 'Group and direct-message bot with card interactions.'description 字段。
The description field.
agentscope/app/channel/_feishu/_channel.py:96icon_url
= 'https://www.google.com/s2/favicons?domain=feishu.cn&sz=128'icon_url 字段。
The icon url field.
agentscope/app/channel/_feishu/_channel.py:97platform_bot_id_field
= 'app_id'platform_bot_id_field 字段。
The platform bot id field field.
agentscope/app/channel/_feishu/_channel.py:98credential_binding
= FeishuCredentialBinding凭证绑定字段。
The credential binding field.
agentscope/app/channel/_feishu/_channel.py:99capabilities
= ChannelCapability(text=True, markdown=True, image=True, file=True, interactive=True, streaming=True, max_message_length=4000)能力字段。
The capabilities field.
agentscope/app/channel/_feishu/_channel.py:131属性详情Property Detail
channel_id
def channel_id() -> str
获取渠道标识。
The unique channel instance identifier.
agentscope/app/channel/_feishu/_channel.py:177–179方法详情Method Detail
start_listening
async def start_listening(emit: Callable[[ChannelEvent | ChannelConfirmationResultEvent], Awaitable[None]]) -> None
启动 start_listening。
Open the HTTP client, run the WS client (reconnecting with backoff), and close everything on exit.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
emit | Callable[[ChannelEvent | ChannelConfirmationResultEvent], Awaitable[None]] | 用于入站事件的网关回调。Gateway callback for inbound events. |
agentscope/app/channel/_feishu/_channel.py:183–274chat_name
async def chat_name(chat_id: str) -> str
设置聊天名称。
The chat's title (cached per chat); "" when unavailable — a 1:1 chat, a not-yet-named group, or a missing im:chat scope.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chat_id | str | 聊天标识(类型 `str`)。The chat to look up. |
agentscope/app/channel/_feishu/_channel.py:461–479chat_kind
async def chat_kind(chat_id: str) -> ChatKind | None
设置聊天种类。
Group vs 1:1 for a chat — from the inbound cache, else the get-chat API (chat_mode).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chat_id | str | 聊天标识(类型 `str`)。The chat to classify. |
agentscope/app/channel/_feishu/_channel.py:481–498send_response
async def send_response(event: ChannelEvent, events: AsyncIterator[dict]) -> None
发送响应。
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | ChannelEvent | 发送目标(聊天标识)。The send target (chat id). |
events | AsyncIterator[dict] | 运行's 会话事件。The run's session events. |
agentscope/app/channel/_feishu/_channel.py:654–734send_reaction
async def send_reaction(event: ChannelEvent, emoji_type: str) -> str | None
发送 send_reaction。
Add an emoji reaction to the inbound message.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | ChannelEvent | 消息到 ReAct 到。The message to react to. |
emoji_type | str | emoji 类型(类型 `str`)。The Feishu emoji type (e.g. `"OnIt"`). |
agentscope/app/channel/_feishu/_channel.py:872–895remove_reaction
async def remove_reaction(event: ChannelEvent, reaction_id: str) -> None
移除 remove_reaction。
Remove a reaction previously added by :meth:send_reaction.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | ChannelEvent | 事件(类型 `ChannelEvent`)。The reacted-to message. |
reaction_id | str | reaction 标识(类型 `str`)。The reaction id to remove. |
agentscope/app/channel/_feishu/_channel.py:897–914list_bot_chats
async def list_bot_chats() -> list[dict]
列出 list_bot_chats。
List the chats the bot is in as {chat_id, name, chat_type}.
agentscope/app/channel/_feishu/_channel.py:916–939list_tools
async def list_tools(workspace: 'WorkspaceBase', channel_user_id: str | None = None) -> list['ToolBase']
列出当前连接可用的工具。
Expose the Feishu send/discovery tools to the agent.
| 名称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 None | str | None | 渠道用户标识(类型 `str | None`)。The platform user the session acts as, passed through to the inherited tools. |
agentscope/app/channel/_feishu/_channel.py:941–973send_message_to
async def send_message_to(receive_id: str, receive_id_type: str, text: str) -> dict | None
发送消息到。
Send a plain-text message to an arbitrary receive_id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
receive_id | str | 接收标识(类型 `str`)。The recipient id. |
receive_id_type | str | 接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc. |
text | str | 消息文本。The message text. |
agentscope/app/channel/_feishu/_channel.py:977–1001send_file_to
async def send_file_to(receive_id: str, receive_id_type: str, data: bytes, file_name: str) -> dict | None
发送文件到。
Upload a file (→ file_key) then send it to a receive_id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
receive_id | str | 接收标识(类型 `str`)。The recipient id. |
receive_id_type | str | 接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc. |
data | bytes | 文件字节。The file bytes. |
file_name | str | 文件's 展示名称。The file's display name. |
agentscope/app/channel/_feishu/_channel.py:1003–1037send_image_to
async def send_image_to(receive_id: str, receive_id_type: str, data: bytes) -> dict | None
发送图像到。
Upload an image (→ image_key) then send it to a receive_id.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
receive_id | str | 接收标识(类型 `str`)。The recipient id. |
receive_id_type | str | 接收标识类型(类型 `str`)。`"chat_id"` / `"open_id"` / etc. |
data | bytes | 图像字节。The image bytes. |
agentscope/app/channel/_feishu/_channel.py:1039–1071list_chat_members
async def list_chat_members(chat_id: str) -> list[dict]
列出聊天成员。
List a group's members as {open_id, name} dicts.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
chat_id | str | 聊天标识(类型 `str`)。The group whose members to list. |
agentscope/app/channel/_feishu/_channel.py:1073–1105aclose
async def aclose() -> None
返回 aclose 结果。
The connection loop closes its own in start_listening; this covers the client-only instances, which never run it.
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.