Skip to content

Commit fd4fe84

Browse files
fix: docs (AstrBotDevs#8229)
* Update listen-message-event.md * Update other.md * Update send-message.md * Update ai.md * Update ai.md * Update send-message.md * Update listen-message-event.md * Delete docs/zh/dev/star/guides/env.md * Delete docs/en/dev/star/guides/env.md * Update simple.md * Update discord.md * Update discord.md * Update matrix.md * Update matrix.md * Update index.md * Update index.md * Update openapi.md * Update ppio.md * Update ppio.md * Update function-calling.md * Update function-calling.md * Update config.mjs * docs: add EN desktop deployment page * Update plugin.md * Update ai.md * Update ai.md * Update ai.md * Update desktop.md
1 parent f5bd4f3 commit fd4fe84

24 files changed

Lines changed: 257 additions & 148 deletions

File tree

docs/.vitepress/config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ export default defineConfig({
287287
collapsed: false,
288288
items: [
289289
{ text: "Package Manager", link: "/astrbot/package" },
290+
{ text: "Desktop Client", link: "/astrbot/desktop" },
290291
{ text: "One-click Launcher", link: "/astrbot/launcher" },
291292
{ text: "Docker", link: "/astrbot/docker" },
292293
{ text: "Kubernetes", link: "/astrbot/kubernetes" },

docs/en/deploy/astrbot/desktop.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Deploy with AstrBot Desktop Client
2+
3+
`AstrBot-desktop` is designed for quick local deployment of AstrBot on your personal computer, supporting Windows, macOS, and Linux.
4+
5+
Among the various deployment options, the desktop client is best suited for personal local use. It is not recommended for long-term server operation or production environments. For production deployments, consider [Docker](/en/deploy/astrbot/docker) or [Kubernetes](/en/deploy/astrbot/kubernetes) instead.
6+
7+
Compared to command-line or container-based solutions, the desktop client offers an out-of-the-box experience, ideal for users who want to get started without dealing with environment setup.
8+
9+
Repository: [AstrBotDevs/AstrBot-desktop](https://github.com/AstrBotDevs/AstrBot-desktop)
10+
11+
## Who Is It For
12+
13+
- Users who want quick local deployment with a graphical interface.
14+
- Beginners who don't want to manually manage Docker / Python environments.
15+
- Personal devices that stay online, primarily for individual or small team daily use.
16+
17+
## Key Features
18+
19+
- Multi-platform installers, ready to use after download.
20+
- GUI-based configuration, lowering the barrier for first-time deployment.
21+
- Suitable as a locally resident client.
22+
23+
## Download and Install
24+
25+
1. Open [AstrBot-desktop Releases](https://github.com/AstrBotDevs/AstrBot-desktop/releases).
26+
2. Download the installer for your operating system (e.g. `.exe`, `.dmg`, `.rpm`, `.deb`).
27+
3. Launch the desktop client after installation and follow the setup wizard to complete initialization.
28+
29+
## Difference from Launcher Deployment
30+
31+
- Desktop client: focuses on an out-of-the-box GUI experience.
32+
- Launcher deployment: focuses on automated script-based startup, suitable for users who prefer a traditional deployment workflow.
33+
- See [Launcher Deployment](/en/deploy/astrbot/launcher).

docs/en/dev/openapi.md

Lines changed: 99 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,113 @@ X-API-Key: abk_xxx
2626
- `POST /api/v1/chat`: request body must include `username`
2727
- `GET /api/v1/chat/sessions`: query params must include `username`
2828

29+
## Scope Permissions
30+
31+
When creating an API Key, you can configure `scopes`. Each scope controls the range of accessible endpoints:
32+
33+
| Scope | Purpose | Accessible Endpoints |
34+
| --- | --- | --- |
35+
| `chat` | Access chat capabilities and query sessions | `POST /api/v1/chat`, `GET /api/v1/chat/sessions` |
36+
| `config` | Retrieve available config file list | `GET /api/v1/configs` |
37+
| `file` | Upload attachment files and get `attachment_id` | `POST /api/v1/file` |
38+
| `im` | Send proactive IM messages, query bot/platform list | `POST /api/v1/im/message`, `GET /api/v1/im/bots` |
39+
40+
If the API Key does not include the required scope for the target endpoint, the request will return `403 Insufficient API key scope`.
41+
2942
## Common Endpoints
3043

44+
**Chat**
45+
46+
Interact with AstrBot's built-in Agent. Supports plugin calls, tool calls, and other capabilities — consistent with IM-side chat.
47+
3148
- `POST /api/v1/chat`: send chat message (SSE stream, server generates UUID when `session_id` is omitted)
3249
- `GET /api/v1/chat/sessions`: list sessions for a specific `username` with pagination
3350
- `GET /api/v1/configs`: list available config files
51+
52+
**File Upload**
53+
3454
- `POST /api/v1/file`: upload attachment
35-
- `POST /api/v1/im/message`: proactive message via UMO
55+
56+
**Proactive IM Messages**
57+
58+
- `POST /api/v1/im/message`: send a proactive message via UMO
3659
- `GET /api/v1/im/bots`: list bot/platform IDs
3760

61+
## `message` Field Format (Important)
62+
63+
The `message` field in `POST /api/v1/chat` and `POST /api/v1/im/message` supports two formats:
64+
65+
1. String: plain text message
66+
2. Array: message segments (message chain)
67+
68+
### 1. Plain Text Format
69+
70+
```json
71+
{
72+
"message": "Hello"
73+
}
74+
```
75+
76+
### 2. Message Segment Array Format
77+
78+
```json
79+
{
80+
"message": [
81+
{ "type": "plain", "text": "Please see this file" },
82+
{ "type": "file", "attachment_id": "9a2f8c72-e7af-4c0e-b352-111111111111" }
83+
]
84+
}
85+
```
86+
87+
Supported `type` values:
88+
89+
| type | Required Fields | Optional Fields | Description |
90+
| --- | --- | --- | --- |
91+
| `plain` | `text` | - | Text segment |
92+
| `reply` | `message_id` | `selected_text` | Quote-reply a message |
93+
| `image` | `attachment_id` | - | Image attachment segment |
94+
| `record` | `attachment_id` | - | Audio attachment segment |
95+
| `file` | `attachment_id` | - | Generic file segment |
96+
| `video` | `attachment_id` | - | Video attachment segment |
97+
98+
* The `reply` segment is currently only supported for `/api/v1/chat`, not for `POST /api/v1/im/message`.
99+
100+
Notes:
101+
102+
- `attachment_id` comes from the upload result of `POST /api/v1/file`.
103+
- `reply` cannot be the only segment; at least one content segment (e.g. `plain/image/file/...`) is required.
104+
- A request with only `reply` or empty content will return an error.
105+
106+
### `message` Usage in Chat API
107+
108+
`POST /api/v1/chat` additionally requires `username`, with optional `session_id` (a UUID is auto-generated if omitted).
109+
110+
```json
111+
{
112+
"username": "alice",
113+
"session_id": "my_session_001",
114+
"message": [
115+
{ "type": "plain", "text": "Please summarize this PDF" },
116+
{ "type": "file", "attachment_id": "9a2f8c72-e7af-4c0e-b352-111111111111" }
117+
],
118+
"enable_streaming": true
119+
}
120+
```
121+
122+
### `message` Usage in IM Message API
123+
124+
`POST /api/v1/im/message` requires `umo` + `message`.
125+
126+
```json
127+
{
128+
"umo": "webchat:FriendMessage:openapi_probe",
129+
"message": [
130+
{ "type": "plain", "text": "This is a proactive message" },
131+
{ "type": "image", "attachment_id": "9a2f8c72-e7af-4c0e-b352-222222222222" }
132+
]
133+
}
134+
```
135+
38136
## Example
39137

40138
```bash

docs/en/dev/star/guides/ai.md

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,21 @@ In the example below, we define a Main Agent responsible for delegating tasks to
157157
Define Tools:
158158

159159
```py
160+
from astrbot.api import logger
161+
from astrbot.core.agent.run_context import ContextWrapper
162+
from astrbot.core.agent.tool import FunctionTool, ToolExecResult, ToolSet
163+
from astrbot.core.astr_agent_context import AstrAgentContext
164+
from pydantic import Field
165+
from pydantic.dataclasses import dataclass
166+
167+
160168
@dataclass
161169
class AssignAgentTool(FunctionTool[AstrAgentContext]):
162170
"""Main agent uses this tool to decide which sub-agent to delegate a task to."""
163171

164172
name: str = "assign_agent"
165173
description: str = "Assign an agent to a task based on the given query"
166-
parameters: dict = field(
174+
parameters: dict = Field(
167175
default_factory=lambda: {
168176
"type": "object",
169177
"properties": {
@@ -178,7 +186,7 @@ class AssignAgentTool(FunctionTool[AstrAgentContext]):
178186

179187
async def call(
180188
self, context: ContextWrapper[AstrAgentContext], **kwargs
181-
) -> str | CallToolResult:
189+
) -> ToolExecResult:
182190
# Here you would implement the actual agent assignment logic.
183191
# For demonstration purposes, we'll return a dummy response.
184192
return "Based on the query, you should assign agent 1."
@@ -190,7 +198,7 @@ class WeatherTool(FunctionTool[AstrAgentContext]):
190198

191199
name: str = "weather"
192200
description: str = "Get weather information for a location"
193-
parameters: dict = field(
201+
parameters: dict = Field(
194202
default_factory=lambda: {
195203
"type": "object",
196204
"properties": {
@@ -205,7 +213,7 @@ class WeatherTool(FunctionTool[AstrAgentContext]):
205213

206214
async def call(
207215
self, context: ContextWrapper[AstrAgentContext], **kwargs
208-
) -> str | CallToolResult:
216+
) -> ToolExecResult:
209217
city = kwargs["city"]
210218
# Here you would implement the actual weather fetching logic.
211219
# For demonstration purposes, we'll return a dummy response.
@@ -218,7 +226,7 @@ class SubAgent1(FunctionTool[AstrAgentContext]):
218226

219227
name: str = "subagent1_name"
220228
description: str = "subagent1_description"
221-
parameters: dict = field(
229+
parameters: dict = Field(
222230
default_factory=lambda: {
223231
"type": "object",
224232
"properties": {
@@ -233,7 +241,7 @@ class SubAgent1(FunctionTool[AstrAgentContext]):
233241

234242
async def call(
235243
self, context: ContextWrapper[AstrAgentContext], **kwargs
236-
) -> str | CallToolResult:
244+
) -> ToolExecResult:
237245
ctx = context.context.context
238246
event = context.context.event
239247
logger.info(f"the llm context messages: {context.messages}")
@@ -255,7 +263,7 @@ class SubAgent2(FunctionTool[AstrAgentContext]):
255263

256264
name: str = "subagent2_name"
257265
description: str = "subagent2_description"
258-
parameters: dict = field(
266+
parameters: dict = Field(
259267
default_factory=lambda: {
260268
"type": "object",
261269
"properties": {
@@ -270,7 +278,7 @@ class SubAgent2(FunctionTool[AstrAgentContext]):
270278

271279
async def call(
272280
self, context: ContextWrapper[AstrAgentContext], **kwargs
273-
) -> str | CallToolResult:
281+
) -> ToolExecResult:
274282
return "I am useless :(, you shouldn't call me :("
275283
```
276284

@@ -335,6 +343,32 @@ class Conversation:
335343

336344
:::
337345

346+
### Quickly Adding LLM Records to a Conversation `add_message_pair`
347+
348+
```py
349+
from astrbot.core.agent.message import (
350+
AssistantMessageSegment,
351+
UserMessageSegment,
352+
TextPart,
353+
)
354+
355+
conv_mgr = self.context.conversation_manager
356+
provider_id = await self.context.get_current_chat_provider_id(event.unified_msg_origin)
357+
curr_cid = await conv_mgr.get_curr_conversation_id(event.unified_msg_origin)
358+
user_msg = UserMessageSegment(content=[TextPart(text="hi")])
359+
llm_resp = await self.context.llm_generate(
360+
chat_provider_id=provider_id, # Chat model ID
361+
contexts=[user_msg], # When prompt is not specified, contexts is used as input; if both prompt and contexts are provided, prompt is appended to the end of the LLM input
362+
)
363+
await conv_mgr.add_message_pair(
364+
cid=curr_cid,
365+
user_message=user_msg,
366+
assistant_message=AssistantMessageSegment(
367+
content=[TextPart(text=llm_resp.completion_text)]
368+
),
369+
)
370+
```
371+
338372
### Main Methods
339373

340374
#### `new_conversation`

docs/en/dev/star/guides/env.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

docs/en/dev/star/guides/listen-message-event.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,22 @@ async def on_astrbot_loaded(self):
250250

251251
```
252252

253+
#### On Waiting for LLM Request
254+
255+
This hook is triggered when AstrBot is preparing to call the LLM but has not yet acquired the session lock.
256+
257+
It is suitable for sending feedback such as "Waiting for request..." to the user, or for obtaining the LLM request outside the lock without waiting for it to be released.
258+
259+
```python
260+
from astrbot.api.event import filter, AstrMessageEvent
261+
262+
@filter.on_waiting_llm_request()
263+
async def on_waiting_llm(self, event: AstrMessageEvent):
264+
await event.send(event.plain_result("🤔 Waiting for request..."))
265+
```
266+
267+
> You cannot use yield to send messages here. If you need to send, please use the `event.send()` method directly.
268+
253269
#### On LLM Request
254270

255271
In AstrBot's default execution flow, the `on_llm_request` hook is triggered before calling the LLM.

docs/en/dev/star/guides/send-message.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Sending Messages
32

43
## Passive Messages
@@ -93,14 +92,14 @@ from astrbot.api.event import filter, AstrMessageEvent
9392
async def test(self, event: AstrMessageEvent):
9493
from astrbot.api.message_components import Video
9594
# fromFileSystem requires the user's protocol client and bot to be on the same system.
96-
music = Video.fromFileSystem(
95+
video = Video.fromFileSystem(
9796
path="test.mp4"
9897
)
9998
# More universal approach
100-
music = Video.fromURL(
99+
video = Video.fromURL(
101100
url="https://example.com/video.mp4"
102101
)
103-
yield event.chain_result([music])
102+
yield event.chain_result([video])
104103
```
105104

106105
![Sending video messages](https://files.astrbot.app/docs/source/images/plugin/db93a2bb-671c-4332-b8ba-9a91c35623c2.png)

docs/en/dev/star/guides/simple.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ Explanation:
3939
> The file containing the plugin class must be named `main.py`.
4040
4141
All handler functions must be written within the plugin class. To keep content concise, in subsequent sections, we may omit the plugin class definition.
42-
```
42+

docs/en/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ layout: home
44

55
hero:
66
name: >-
7-
<a href="https://trendshift.io/repositories/12875" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12875" alt="Soulter%2FAstrBot | Trendshift" style="width: 250px; height: 55px; margin-bottom: 16px;" width="250" height="55"/></a>
7+
<a href="https://trendshift.io/repositories/21369" target="_blank"><img src="https://trendshift.io/api/badge/repositories/21369" alt="AstrBotDevs%2FAstrBot | Trendshift" style="width: 250px; height: 55px; margin-bottom: 16px;" width="250" height="55"/></a>
88
text: "Agentic AI assistant for personal and group chats"
99
tagline: Connect any IM / 1000+ plugins / General Agent Orchestration
1010
actions:

docs/en/platform/discord.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ If you find this tedious, you can directly use administrator permissions, but it
5555
![Generated URL location](https://files.astrbot.app/docs/source/images/discord/image-5.png)
5656

5757
6. Enter your Discord server, your bot should now show as online
58+
5859
![Bot online](https://files.astrbot.app/docs/source/images/discord/image-7.png)
60+
5961
@ mention the bot you just created (or don't mention it), type `/help`. If it responds successfully, the test is successful.
6062

6163
## Pre-acknowledgment Emoji

0 commit comments

Comments
 (0)