Skip to content

Commit 1bf0a73

Browse files
committed
refactor(alias): reorganize file structure and refine documentation
1 parent 7f8023b commit 1bf0a73

File tree

11 files changed

+45
-46
lines changed

11 files changed

+45
-46
lines changed

alias/README.md

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,12 @@ After the first startup, you can log in with the superuser credentials configure
373373

374374
### 🌐 Basic Usage -- AgentScope Runtime Deployment
375375

376-
Alias now supports rapid startup based on [AgentScope-runtime](https://github.com/agentscope-ai/agentscope-runtime/), providing an out-of-the-box WebUI (powered by the AgentScope Runtime WebUI).
376+
Alias is now fully compatible with [AgentScope Runtime](https://github.com/agentscope-ai/agentscope-runtime/), enabling you to quickly deploy Alias as a standardized backend service. Once launched, you can easily invoke Alias capabilities via the accompanying AgentScope Runtime API.
377377

378378
#### 1. Prerequisites
379379

380-
* **Sandbox & API Keys**: Please refer to the previous sections [🐳 Sandbox Setup](#-sandbox-setup-optional) and [🔑 API Keys Configuration](#-api-keys-configuration) to complete the basic environment setup.
381-
* **Configure Environment Variables**: Copy the example environment file from the project root:
380+
* **Sandbox & API Keys**: Please refer to the previous sections [🐳 Sandbox Setup (Optional)](#-sandbox-setup-optional) and [🔑 API Keys Configuration](#-api-keys-configuration) to complete the basic environment setup.
381+
* **Environment Variables**: Copy the example environment file from the project root:
382382
```bash
383383
cp .env.example .env
384384
```
@@ -387,69 +387,67 @@ Alias now supports rapid startup based on [AgentScope-runtime](https://github.co
387387
docker run -d -p 6379:6379 --name alias-redis redis:7-alpine
388388
```
389389

390-
#### 2. Installation and Sandbox Startup
390+
#### 2. Installation & Sandbox Launch
391391

392-
Install the package in editable mode from the project root. This will automatically install the `alias_agent_runtime` command-line tool:
392+
Install the package in editable mode from the project root. This will automatically install the `alias_agent_runtime` CLI tool:
393393
```bash
394394
pip install -e .
395395
```
396396

397-
To ensure features like code execution and file operations work correctly, start the sandbox server in a separate terminal:
397+
To ensure proper code execution and file operations, start the sandbox server in a separate terminal:
398398
```bash
399399
runtime-sandbox-server --extension src/alias/runtime/alias_sandbox/alias_sandbox.py
400400
```
401401

402-
#### 3. Start AgentScope Runtime Service
402+
#### 3. Launching AgentScope Runtime Service
403403

404-
##### Option A: Using the Command Line Interface (Recommended)
404+
You can choose to start the service via the CLI or Python code, depending on your use case.
405405

406-
Use the `alias_agent_runtime` command to launch both the backend service and the WebUI with a single command:
406+
##### Option A: Using CLI (Recommended)
407+
Use the `alias_agent_runtime` command to launch the backend service with one click:
407408

408409
```bash
409-
alias_agent_runtime --host 127.0.0.1 --port 8090 --chat-mode general --web-ui
410+
alias_agent_runtime --host 127.0.0.1 --port 8090 --chat-mode general
410411
```
411412

412413
**Parameter Descriptions**:
413-
* `--host` / `--port`: Specifies the host address and port for the service (default port is 8090).
414-
* `--chat-mode`: Sets the operational mode. Available options: `general`, `dr`, `browser`, `ds`, `finance` (defaults to `general`).
415-
* `--web-ui`: Enables the AgentScope Runtime WebUI. If this flag is omitted, the WebUI will not be started.
414+
* `--host` / `--port`: Specify the service address and port (default port is 8090).
415+
* `--chat-mode`: Set the running mode. Options: `general`, `dr`, `browser`, `ds`, `finance` (default: `general`).
416+
* `--web-ui`: (Optional) Enable AgentScope Runtime WebUI for a visual interaction interface. Skip this if you only need the API.
416417

417-
> **Note**: When launching with `--web-ui` for the first time, the system will automatically install necessary frontend dependencies. This process may take a few minutes; please be patient.
418+
> **Note**: When enabling `--web-ui` for the first time, the system will automatically install necessary frontend dependencies. This may take a few minutes.
418419

419-
##### Option B: Programmatic Usage (Recommended for Developers)
420-
421-
If you prefer to integrate or customize the startup logic within your Python code, you can use `AliasRunner` in conjunction with `AgentApp` as shown below:
420+
##### Option B: Using Python Code (Recommended for Developers)
421+
If you wish to integrate or customize the launch logic within Python, you can use `AliasRunner` and `AgentApp` as shown below:
422422

423423
```python
424424
from agentscope_runtime.engine.app import AgentApp
425425
from alias.server.runtime.runner.alias_runner import AliasRunner
426426
427427
# 1. Initialize AliasRunner
428-
# Available default_chat_mode options: "general", "dr", "browser", "ds", "finance"
428+
# default_chat_mode options: "general", "dr", "browser", "ds", "finance"
429429
runner = AliasRunner(
430430
default_chat_mode="general",
431431
)
432432
433-
# 2. Create an AgentApp instance
433+
# 2. Create AgentApp instance
434434
agent_app = AgentApp(
435435
runner=runner,
436436
app_name="Alias",
437437
app_description="An LLM-empowered agent built on AgentScope and AgentScope-Runtime",
438438
)
439439
440440
# 3. Run the service
441-
# Setting web_ui=True will also launch the frontend interface (default port: 5173)
442-
agent_app.run(host="127.0.0.1", port=8090, web_ui=True)
441+
# Set web_ui=True to enable the visual debugging interface
442+
agent_app.run(host="127.0.0.1", port=8090)
443443
```
444444

445-
#### 4. Access the Application
446-
447-
Once the service is running, you can interact with Alias via the following addresses:
445+
#### 4. Accessing the Application
448446

449-
* **Frontend Interface**: `http://localhost:5173`
450-
* **Runtime API Service**: `http://localhost:8090/process`
447+
Once the service is running, you can access Alias via:
451448

452-
Through the WebUI, you can intuitively track the agent's reasoning process, tool invocation traces, and other execution details.
449+
* **Runtime API Access**: Send standard HTTP POST requests to `http://localhost:8090/process`. This is the primary method for integrating Alias into third-party frontends or backend workflows.
450+
* **Visual Monitoring (Optional)**: If started with the `--web-ui` flag, visit `http://localhost:5173`. This interface allows developers to observe the agent's reasoning process, tool execution traces, and other debugging information.
453451
454452
455453
## ⚖️ License

alias/README_ZH.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ bash script/start_memory_service.sh
373373

374374
### 🌐 基础用法 -- AgentScope Runtime 部署
375375

376-
Alias 现在支持基于 [AgentScope-runtime](https://github.com/agentscope-ai/agentscope-runtime/) 快速启动,并提供开箱即用的 WebUI 交互界面(基于AgentScope Runtime 的 WebUI)
376+
Alias 现已适配 [AgentScope Runtime](https://github.com/agentscope-ai/agentscope-runtime/),您可以利用 AgentScope Runtime 将 Alias 快速部署为标准后端服务。启动后,通过配套的 AgentScope Runtime API 即可轻松调用 Alias 所提供的服务
377377

378378
#### 1. 前期准备
379379

@@ -401,17 +401,19 @@ runtime-sandbox-server --extension src/alias/runtime/alias_sandbox/alias_sandbox
401401

402402
#### 3. 启动 AgentScope Runtime 服务
403403

404+
您可以根据使用场景,选择通过命令行或 Python 代码启动服务。
405+
404406
##### 选项 A:使用命令行工具(推荐)
405-
使用 `alias_agent_runtime` 命令一键启动后端服务及 WebUI 界面
407+
使用 `alias_agent_runtime` 命令一键启动后端服务
406408

407409
```bash
408-
alias_agent_runtime --host 127.0.0.1 --port 8090 --chat-mode general --web-ui
410+
alias_agent_runtime --host 127.0.0.1 --port 8090 --chat-mode general
409411
```
410412

411413
**参数说明**
412414
* `--host` / `--port`: 指定服务的运行地址和端口(默认端口为 8090)。
413415
* `--chat-mode`: 设置运行模式,可选 `general`, `dr`, `browser`, `ds`, `finance`(默认为 `general`)。
414-
* `--web-ui` : 启用 AgentScope Runtime WebUI。若未指定该参数,则默认不启动 WebUI
416+
* `--web-ui` : (可选) 启用 AgentScope Runtime WebUI 以开启可视化交互界面。若仅需调用 API,请忽略此参数
415417

416418
> **注意**:首次启动并开启 `--web-ui` 时,系统会自动安装必要的前端依赖包,可能需要花费几分钟时间,请耐心等待。
417419

@@ -436,18 +438,16 @@ agent_app = AgentApp(
436438
)
437439
438440
# 3. 运行服务
439-
# web_ui=True 将同时启动前端交互界面(默认端口 5173)
440-
agent_app.run(host="127.0.0.1", port=8090, web_ui=True)
441+
# 如需启用可视化调试界面,可设置 web_ui=True
442+
agent_app.run(host="127.0.0.1", port=8090)
441443
```
442444

443445
#### 4. 访问应用程序
444446

445-
服务启动后,您可以通过访问以下地址与 Alias 进行交互:
446-
447-
* **前端交互界面**`http://localhost:5173`
448-
* **Runtime API 服务**`http://localhost:8090/process`
447+
服务启动后,您可以通过以下方式访问 Alias:
449448

450-
通过 WebUI,您可以直观地查看智能体的思考过程以及工具调用轨迹等信息。
449+
* **Runtime API 调用**:通过标准 HTTP POST 请求访问 `http://localhost:8090/process`。这是将 Alias 集成至第三方前端或后端工作流的主要方式。
450+
* **可视化监控 (可选)**:若启动时开启了 `--web-ui` 参数,可通过 `http://localhost:5173` 访问 WebUI。该界面主要用于开发者观察智能体的思考过程以及工具调用轨迹等调试信息。
451451

452452
## ⚖️ 许可证
453453

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# -*- coding: utf-8 -*-
22
"""Runtime module for Alias"""
33

4-
__all__ = ["alias_sandbox"]
4+
__all__ = ["alias_sandbox", "runtime_compat"]
55

66
# Import submodule to make it accessible via alias.runtime.alias_sandbox
77
from . import alias_sandbox # noqa: E402, F401
8+
from . import runtime_compat # noqa: E402, F401
File renamed without changes.

alias/src/alias/server/runtime/adapter/__init__.py renamed to alias/src/alias/runtime/runtime_compat/adapter/__init__.py

File renamed without changes.

alias/src/alias/server/runtime/adapter/alias_stream_adapter.py renamed to alias/src/alias/runtime/runtime_compat/adapter/alias_stream_adapter.py

File renamed without changes.
File renamed without changes.

alias/src/alias/server/runtime/runner/alias_runner.py renamed to alias/src/alias/runtime/runtime_compat/runner/alias_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
)
2626
from alias.server.core.task_manager import task_manager
2727
from alias.server.exceptions.base import BaseError
28-
from alias.server.runtime.adapter.alias_stream_adapter import (
28+
from alias.runtime.runtime_compat.adapter.alias_stream_adapter import (
2929
adapt_alias_message_stream,
3030
)
3131
from alias.server.schemas.chat import ChatRequest

alias/src/alias/server/runtime/runner/alias_runner_singleton.py renamed to alias/src/alias/runtime/runtime_compat/runner/alias_runner_singleton.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import asyncio
33
from typing import Optional
4-
from alias.server.runtime.runner.alias_runner import AliasRunner
4+
from alias.runtime.runtime_compat.runner.alias_runner import AliasRunner
55

66
_lock: Optional[asyncio.Lock] = None
77
_runner: Optional[AliasRunner] = None

alias/src/alias/server/alias_agent_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22
from agentscope_runtime.engine.app import AgentApp
33

4-
from alias.server.runtime.runner.alias_runner import AliasRunner
4+
from alias.runtime.runtime_compat.runner.alias_runner import AliasRunner
55

66
PORT = 8090
77

0 commit comments

Comments
 (0)