Skip to content

Commit

Permalink
[WIP] translate tutorial into chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Mar 6, 2024
1 parent 996bc94 commit d7d3a2c
Show file tree
Hide file tree
Showing 9 changed files with 421 additions and 62 deletions.
115 changes: 115 additions & 0 deletions docs/sphinx_doc/source/tutorial/101-agentscope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
(101-agentscope)=

# About AgentScope

In this tutorial, we will provide an overview of AgentScope by answering
several questions, including what's AgentScope, what can AgentScope provide,
and why we should choose AgentScope. Let's get started!

## What is AgentScope?

AgentScope is a developer-centric multi-agent platform, which enables
developers to build their LLM-empowered multi-agent applications with less
effort.

With the advance of large language models, developers are able to build
diverse applications.
In order to connect LLMs to data and services and solve complex tasks,
AgentScope provides a series of development tools and components for ease of
development.
It features
- **usability**,
- **robustness**, and
- **the support of multi-modal data** and
- **distributed deployment**.

## Key Concepts

### Message
Message is a carrier of information (e.g. instructions, multi-modal
data, and dialogue). In AgentScope, message is a Python dict subclass
with `name` and `content` as necessary fields, and `url` as an optional
field referring to additional resources.

### Agent
Agent is an autonomous entity capable of interacting with environment and
agents, and taking actions to change the environment. In AgentScope, an
agent takes message as input and generates corresponding response message.

### Service
Service refers to the functional APIs that enable agents to perform
specific tasks. In AgentScope, services are categorized into model API
services, which are channels to use the LLMs, and general API services,
which provide a variety of tool functions.

### Workflow
Workflow represents ordered sequences of agent executions and message
exchanges between agents, analogous to computational graphs in TensorFlow,
but with the flexibility to accommodate non-DAG structures.


## Why AgentScope?

**Exceptional usability for developers.**
AgentScope provides high usability for developers with flexible syntactic
sugars, ready-to-use components, and pre-built examples.

**Robust fault tolerance for diverse models and APIs.**
AgentScope ensures robust fault tolerance for diverse models, APIs, and
allows developers to build customized fault-tolerant strategies.

**Extensive compatibility for multi-modal application.**
AgentScope supports multi-modal data (e.g., files, images, audio and videos)
in both dialog presentation, message transmission and data storage.

**Optimized efficiency for distributed multi-agent operations.** AgentScope
introduces an actor-based distributed mechanism that enables centralized
programming of complex distributed workflows, and automatic parallel
optimization.


## How is AgentScope designed?

[]()

The architecture of AgentScope comprises three hierarchical layers. The
layers provide supports for multi-agent applications from different levels,
including elementary and advanced functionalities of a single agent
(**utility layer**), resources and runtime management (**manager and wrapper
layer**), and agent-level to workflow-level programming interfaces (**agent
layer**). AgentScope introduces intuitive abstractions designed to fulfill
the diverse functionalities inherent to each layer and simplify the
complicated interlayer dependencies when building multi-agent systems.
Furthermore, we offer programming interfaces and default mechanisms to
strengthen the resilience of multi-agent systems against faults within
different layers.

## AgentScope Code Structure

```bash
AgentScope
├── src
│ ├── agentscope
| ├── agents # Core components and implementations pertaining to agents.
| ├── memory # Structures for agent memory.
| ├── models # Interfaces for integrating diverse model APIs.
| ├── pipeline # Fundamental components and implementations for running pipelines.
| ├── rpc # Rpc module for agent distributed deployment.
| ├── service # Services offering functions independent of memory and state.
| | ├── web # WebUI used to show dialogs.
| ├── utils # Auxiliary utilities and helper functions.
| ├── message.py # Definitions and implementations of messaging between agents.
| ├── prompt.py # Prompt engineering module for model input.
| ├── ... ..
| ├── ... ..
├── scripts # Scripts for launching local Model API
├── examples # Pre-built examples of different applications.
├── docs # Documentation tool for API reference.
├── tests # Unittest modules for continuous integration.
├── LICENSE # The official licensing agreement for AgentScope usage.
└── setup.py # Setup script for installing.
├── ... ..
└── ... ..
```

[[Return to the top]](#fundamental-concepts)
46 changes: 0 additions & 46 deletions docs/sphinx_doc/source/tutorial/102-concepts.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(101-installation)=
(102-installation)=

# Installation

Expand Down
40 changes: 28 additions & 12 deletions docs/sphinx_doc/source/tutorial/103-example.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
(103-example)=
(103-start)=

# Getting Started with a Simple Example
# Quick Start

AgentScope is a versatile platform for building and running multi-agent applications. We provide various pre-built examples that will help you quickly understand how to create and use multi-agent for various applications. In this tutorial, you will learn how to set up a **simple agent-based interaction**.
AgentScope is designed with a flexible communication mechanism.
In this tutorial, we will introduce the basic usage of AgentScope via a
simple standalone conversation between two agents (e.g. user and assistant
agents).

## Step1: Prepare Model Configs
## Step1: Prepare Model

Agent is the basic composition and communication unit in AgentScope. To initialize a model-based agent, you need to prepare your configs for avaliable models. AgentScope supports a variety of APIs for pre-trained models. Here is a table outlining the supported APIs and the type of arguments required for each:
AgentScope decouples the deployment and invocation of models to better build multi-agent applications.

| Model Usage | Model Type Argument in AgentScope | Supported APIs |
| --------------------------- | --------------------------------- |-----------------------------------------------------------------------------|
| Text generation | `openai` | Standard *OpenAI* chat API, FastChat and vllm |
| Image generation | `openai_dall_e` | *DALL-E* API for generating images |
| Embedding | `openai_embedding` | API for text embeddings |
| General usages in POST | `post_api` | *Huggingface* and *ModelScope* Inference API, and other customized post API |
In terms of model deployment, users can use third-party model services such
as OpenAI API, HuggingFace/ModelScope Inference API, and can also quickly
deploy local open-source model services through the [scripts]
(https://github.com/modelscope/agentscope/blob/main/scripts/README.md) in
the repository. Currently, we support building basic model services quickly
using Flask with Transformers (or ModelScope), and also support deploying
local model services through FastChat and vllm inference engines.

While in terms of model invocation, AgentScope provides a `ModelWrapper` class to encapsulate OpenAI API and RESTful Post Request calls.
Currently, the supported OpenAI APIs include Chat, Image generation, and Embedding.
Users can specify the model service by setting different model configs.


| Model Usage | Supported APIs |
| --------------------------- |-----------------------------------------------------------------------------|
| Text generation | Standard *OpenAI* chat API, FastChat and vllm |
| Image generation | *DALL-E* API for generating images |
| Embedding | API for text embeddings |
| General usages in POST | *Huggingface* and *ModelScope* Inference API, and other customized post API |

Each API has its specific configuration requirements. For example, to configure an OpenAI API, you would need to fill out the following fields in the model config in a dict, a yaml file or a json file:

Expand All @@ -29,7 +45,7 @@ model_config = {

For open-source models, we support integration with various model interfaces such as HuggingFace, ModelScope, FastChat, and vllm. You can find scripts on deploying these services in the `scripts` directory, and we defer the detailed instructions to [[Using Different Model Sources with Model API]](203-model).

You can register your configuration by calling AgentScope's initilization method as follow. Besides, you can also load more than one config by calling init mutliple times.
You can register your configuration by calling AgentScope's initialization method as follow. Besides, you can also load more than one config by calling init multiple times.

```python
import agentscope
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_doc/source/tutorial/104-usecase.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Let the adventure begin to unlock the potential of multi-agent applications with

## Getting Started

Firstly, ensure that you have installed and configured AgentScope properly. Besides, we will involve the basic concepts of `Model API`, `Agent`, `Msg`, and `Pipeline,` as described in [Tutorial-Concept](102-concepts). The overview of this tutorial is shown below:
Firstly, ensure that you have installed and configured AgentScope properly. Besides, we will involve the basic concepts of `Model API`, `Agent`, `Msg`, and `Pipeline,` as described in [Tutorial-Concept](101-agentscope). The overview of this tutorial is shown below:

- [Crafting Your First Application](#crafting-your-first-application)
- [Getting Started](#getting-started)
Expand Down
4 changes: 2 additions & 2 deletions docs/sphinx_doc/source/tutorial/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ AgentScope is an innovative multi-agent platform designed to empower developers

### Getting Started

- [Installation Guide](101-installation)
- [Fundamental Concepts](102-concepts)
- [Installation Guide](102-installation)
- [Fundamental Concepts](101-agentscope)
- [Getting Started with a Simple Example](103-example)
- [Crafting Your First Application](104-usecase)
- [Logging and WebUI](105-logging)
Expand Down
91 changes: 91 additions & 0 deletions docs/sphinx_doc/source/tutorial/zh/101-agentscope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
(101-agentscope)=

# 关于AgentScope

在此教程中,我们将通过回答问题的方式向您介绍AgentScope,包括什么是AgentScope,AgentScope
能做什么,以及我们为什么应该选择AgentScope。让我们开始吧!

## 什么是AgentScope?

AgentScope是以开发者为中心的多智能体平台,它使开发者能够更轻松地构建基于大语言模型的多智能体应用程序。

大模型的出现使得开发者能够构建多样化的应用程序,为了连接大语言模型和数据以及服务,并更好地解
决复杂任务,AgentScope提供了一系列的开发工具和组件来提高开发效率。AgentScope以
- **易用性**
- **鲁棒性**
- **支持多模态数据**
- **分布式部署**

为特点。

## 关键概念

### 信息(Message)
是信息的载体(例如指令、多模态数据和对话内容)。在AgentScope中,消息是Python字典的子类,
具有`name``content`作为必要字段,`url`作为可选字段并指向额外的资源。

### 智能体(Agent)
是能够与环境和其他智能体交互,并采取行动改变环境的自主实体。在AgentScope中,
智能体以消息作为输入,并生成相应的响应消息。

### 服务(Service)
是使智能体能够执行特定任务的功能性API。在AgentScope中,服务分为模型API服务
(用于使用大预言模型)和通用API服务(提供各种工具函数)。

### 工作流(Workflow)
表示智能体执行和智能体之间的消息交换的有序序列,类似于TensorFlow中的计算图,
但其并不一定是DAG结构。


## 为什么选择AgentScope?

**面向开发者的易用性。**
AgentScope为开发者提供了高易用性,包括灵活易用的语法糖、即拿即用的组件和预构建的multi-agent样例。

**可靠稳定的容错机制。**
AgentScope确保了对多种模型和APIs的容错性,并允许开发者构建定制的容错策略。

**全面兼容多模态数据。**
AgentScope支持多模态数据(例如文件、图像、音频和视频)的对话展示、消息传输和数据存储。

**高效分布式运行效率。**
AgentScope引入了基于actor的分布式机制,使得复杂的分布式工作流的集中式编程和自动并行优化成为可能。

## AgentScope是如何设计的?

[]()

AgentScope由三个层次的层次结构组成。
这些层次提供了对多智能体应用程序的支持,包括单个智能体的基本和高级功能(实用程序层)、资源和运行时管理(管理器和包装层)以及智能体级到工作流级的编程接口(智能体层)。
AgentScope引入了直观的抽象,旨在满足每个层次固有的多样化功能,并简化构建多智能体系统时的复杂层间依赖关系。
此外,我们提供了编程接口和默认机制,以增强多智能体系统在不同层次上对故障的韧性。

## AgentScope代码结构

```bash
AgentScope
├── src
│ ├── agentscope
| ├── agents # 与智能体相关的核心组件和实现。
| ├── memory # 智能体记忆相关的结构。
| ├── models # 用于集成不同模型API的接口。
| ├── pipeline # 基础组件和实现,用于运行工作流。
| ├── rpc # Rpc模块,用于智能体分布式部署。
| ├── service # 为智能体提供各种功能的服务。
| | ├── web # 基于网页的用户交互界面。
| ├── utils # 辅助工具和帮助函数。
| ├── prompt.py # 提示工程模块。
| ├── message.py # 智能体之间消息传递的定义和实现。
| ├── ... ..
| ├── ... ..
├── scripts # 用于启动本地模型API的脚本。
├── examples # 不同应用程序的预构建示例。
├── docs # 教程和API参考文档。
├── tests # 单元测试模块,用于持续集成。
├── LICENSE # AgentScope使用的官方许可协议。
└── setup.py # 用于安装的设置脚本。
├── ... ..
└── ... ..
```

[[返回顶端]](#关于agentscope)
Loading

0 comments on commit d7d3a2c

Please sign in to comment.