mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-11-25 01:52:07 +08:00
docs(plugin): document send_message timeout parameter (#2923)
send_message now waits 60s by default and accepts a keyword-only `timeout` (langbot-app/langbot-plugin-sdk#219). Document the parameter, its validation, the fact that a timeout does not cancel the host send, and the SDK/Runtime version requirement in zh/en/ja. Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
multica-agent
parent
6a9f5733ba
commit
7aed3be5cb
@@ -94,6 +94,8 @@ async def send_message(
|
||||
target_type: str,
|
||||
target_id: str,
|
||||
message_chain: platform_message.MessageChain,
|
||||
*,
|
||||
timeout: float | None = None,
|
||||
) -> None:
|
||||
"""Send a message to a session"""
|
||||
|
||||
@@ -104,8 +106,23 @@ await self.plugin.send_message(
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Plain(text="Hello, world!")]),
|
||||
)
|
||||
|
||||
# Allow more time for media messages such as images
|
||||
await self.plugin.send_message(
|
||||
bot_uuid="de639861-be05-4018-859b-c2e2d3e0d603",
|
||||
target_type="person",
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Image(url="https://example.com/a.png")]),
|
||||
timeout=180,
|
||||
)
|
||||
```
|
||||
|
||||
`timeout` is how many seconds the plugin waits for LangBot to finish sending. It defaults to 60 seconds, must be passed as a keyword argument, and must be a positive number; otherwise `ValueError` is raised. Images, files and voice messages are uploaded to the platform before they are sent and can take longer, so raise it when needed. A timeout only means the plugin stops waiting: it does not cancel a send already in progress in LangBot, so do not resend right away after a timeout, or the message may be delivered twice.
|
||||
|
||||
<Info>
|
||||
Requires a `langbot-plugin` release after 0.7.22: plugins need that SDK version to pass `timeout`, and the Plugin Runtime needs it to apply the 60-second default and the plugin's timeout. Version 0.7.22 and earlier wait a fixed 15 seconds.
|
||||
</Info>
|
||||
|
||||
### Get Configured LLM Model List
|
||||
|
||||
Returns a list of UUIDs for all configured LLM models.
|
||||
|
||||
@@ -94,6 +94,8 @@ async def send_message(
|
||||
target_type: str,
|
||||
target_id: str,
|
||||
message_chain: platform_message.MessageChain,
|
||||
*,
|
||||
timeout: float | None = None,
|
||||
) -> None:
|
||||
"""セッションにメッセージを送信する"""
|
||||
|
||||
@@ -104,8 +106,23 @@ await self.plugin.send_message(
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Plain(text="Hello, world!")]),
|
||||
)
|
||||
|
||||
# 画像などのメディアメッセージでは待ち時間を明示的に延ばせます
|
||||
await self.plugin.send_message(
|
||||
bot_uuid="de639861-be05-4018-859b-c2e2d3e0d603",
|
||||
target_type="person",
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Image(url="https://example.com/a.png")]),
|
||||
timeout=180,
|
||||
)
|
||||
```
|
||||
|
||||
`timeout` はプラグインが LangBot の送信完了を待つ秒数です。デフォルトは 60 秒で、キーワード引数としてのみ指定でき、正の数である必要があります。そうでない場合は `ValueError` が発生します。画像・ファイル・音声などのメディアメッセージは送信前にメッセージプラットフォームへアップロードされるため時間がかかることがあり、必要に応じて大きくしてください。タイムアウトはプラグインが待つのをやめるだけで、LangBot で進行中の送信は取り消されません。重複送信を避けるため、タイムアウト後にすぐ再送しないでください。
|
||||
|
||||
<Info>
|
||||
0.7.22 より後にリリースされる `langbot-plugin` が必要です。`timeout` を渡すにはプラグインがその SDK を使う必要があり、60 秒のデフォルトとプラグイン指定のタイムアウトを適用するには Plugin Runtime もそのバージョンである必要があります。0.7.22 以前は 15 秒固定で待機します。
|
||||
</Info>
|
||||
|
||||
### 設定済みLLMモデルリストの取得
|
||||
|
||||
設定されたすべてのLLMモデルのUUIDのリストを返します。
|
||||
|
||||
@@ -94,6 +94,8 @@ async def send_message(
|
||||
target_type: str,
|
||||
target_id: str,
|
||||
message_chain: platform_message.MessageChain,
|
||||
*,
|
||||
timeout: float | None = None,
|
||||
) -> None:
|
||||
"""Send a message to a session"""
|
||||
|
||||
@@ -104,8 +106,23 @@ await self.plugin.send_message(
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Plain(text="Hello, world!")]),
|
||||
)
|
||||
|
||||
# 发送图片等媒体消息时可显式延长等待时间
|
||||
await self.plugin.send_message(
|
||||
bot_uuid="de639861-be05-4018-859b-c2e2d3e0d603",
|
||||
target_type="person",
|
||||
target_id="1010553892",
|
||||
message_chain=platform_message.MessageChain([platform_message.Image(url="https://example.com/a.png")]),
|
||||
timeout=180,
|
||||
)
|
||||
```
|
||||
|
||||
`timeout` 是插件等待 LangBot 完成发送的秒数,默认 60 秒,只能以关键字参数传入,必须为正数,否则抛出 `ValueError`。图片、文件、语音等媒体消息需要先上传到消息平台再发送,耗时可能更长,可按需调大。超时只表示插件不再等待,不会取消 LangBot 中正在进行的发送,因此超时后不要直接重发,以免重复发送。
|
||||
|
||||
<Info>
|
||||
需要 0.7.22 之后发布的 `langbot-plugin`:插件使用该版本 SDK 才能传入 `timeout`,Plugin Runtime 升级到该版本后才会采用 60 秒默认值和插件指定的超时。0.7.22 及更早版本固定等待 15 秒。
|
||||
</Info>
|
||||
|
||||
### 获取已配置的 LLM 模型列表
|
||||
|
||||
返回由所有已配置的 LLM 模型 UUID 组成的列表。
|
||||
|
||||
Reference in New Issue
Block a user