Skip to content

Commit

Permalink
Reformat tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
DavdGao committed Mar 10, 2024
1 parent ff37945 commit baf9cea
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 135 deletions.
74 changes: 37 additions & 37 deletions docs/sphinx_doc/source/tutorial/101-agentscope.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,86 +2,86 @@

# About AgentScope

In this tutorial, we will provide an overview of AgentScope by answering
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
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**,
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
- **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
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 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.
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,
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
**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
**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.**
**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
**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
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
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
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
Furthermore, we offer programming interfaces and default mechanisms to
strengthen the resilience of multi-agent systems against faults within
different layers.

## AgentScope Code Structure
Expand Down
16 changes: 8 additions & 8 deletions docs/sphinx_doc/source/tutorial/103-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# Quick Start

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
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

AgentScope decouples the deployment and invocation of models to better build multi-agent applications.

In terms of model deployment, users can use third-party model services such
as OpenAI API, HuggingFace/ModelScope Inference API, and can also quickly
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
(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.
Expand Down
42 changes: 21 additions & 21 deletions docs/sphinx_doc/source/tutorial/203-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
# Model Service

In AgentScope, the model deployment and invocation are decoupled by `ModelWrapper`.
Developers can specify their own model by providing model configurations,
and AgentScope also provides scripts to support developers to customize
model services.
Developers can specify their own model by providing model configurations,
and AgentScope also provides scripts to support developers to customize
model services.

## Supported Models

Currently, AgentScope supports the following model service APIs:
- OpenAI API, including Chat, image generation (DALL-E), and Embedding.
- Post Request API, model inference services based on Post
requests, including Huggingface/ModelScope Inference API and various
- Post Request API, model inference services based on Post
requests, including Huggingface/ModelScope Inference API and various
post request based model APIs.

## Configuration

In AgentScope, users specify the model configuration through the
`model_configs` parameter in the `agentscope.init` interface.
`model_configs` can be a **dictionary**, **a list of dictionaries**, or a
In AgentScope, users specify the model configuration through the
`model_configs` parameter in the `agentscope.init` interface.
`model_configs` can be a **dictionary**, **a list of dictionaries**, or a
**path** to model configuration file.

```python
Expand Down Expand Up @@ -67,7 +67,7 @@ Among them, the basic parameters include `config_name` and `model_type`, which a
# Basic parameters
"config_name": "gpt-4-temperature-0.0", # Model configuration name
"model_type": "openai", # Correspond to `ModelWrapper` type

# Detailed parameters
# ...
}
Expand All @@ -89,7 +89,7 @@ class OpenAIChatWrapper(OpenAIWrapper):
# ...
```

In the current AgentScope, the supported `model_type` types, the corresponding
In the current AgentScope, the supported `model_type` types, the corresponding
`ModelWrapper` classes, and the supported APIs are as follows:

| Task | model_type | ModelWrapper | Supported APIs |
Expand All @@ -102,9 +102,9 @@ In the current AgentScope, the supported `model_type` types, the corresponding

#### Detailed Parameters

According to the different `ModelWrapper`, the parameters contained in the
detailed parameters are different. However, all detailed parameters will be
used to initialize the instance of the `ModelWrapper` class. Therefore, more
According to the different `ModelWrapper`, the parameters contained in the
detailed parameters are different. However, all detailed parameters will be
used to initialize the instance of the `ModelWrapper` class. Therefore, more
detailed parameter descriptions can be viewed according to the constructor of
their `ModelWrapper` classes.

Expand All @@ -115,16 +115,16 @@ their `ModelWrapper` classes.
# basic parameters
"config_name": "gpt-4_temperature-0.0",
"model_type": "openai",

# detailed parameters
# required parameters
"model_name": "gpt-4", # OpenAI model name

# optional
"api_key": "xxx", # OpenAI API Key, if not provided, it will be read from the environment variable
"organization": "xxx", # Organization name, if not provided, it will be read from the environment variable
"client_args": { # Parameters for initializing the OpenAI API Client
# e.g. "max_retries": 3,
# e.g. "max_retries": 3,
},
"generate_args": { # Parameters passed to the model when calling
# e.g. "temperature": 0.0
Expand All @@ -140,13 +140,13 @@ their `ModelWrapper` classes.
# Basic parameters
"config_name": "gpt-4_temperature-0.0",
"model_type": "post_api",

# Detailed parameters
"api_url": "http://xxx.png",
"headers": {
"headers": {
# e.g. "Authorization": "Bearer xxx",
},

# Optional parameters, need to be configured according to the requirements of the Post request API
"json_args": {
# e.g. "temperature": 0.0
Expand All @@ -157,8 +157,8 @@ their `ModelWrapper` classes.

## Build Model Service from Scratch

For developers who need to build their own model services, AgentScope
provides some scripts to help developers quickly build model services.
For developers who need to build their own model services, AgentScope
provides some scripts to help developers quickly build model services.
You can find these scripts and instructions in the [scripts](https://github.com/modelscope/agentscope/tree/main/scripts)
directory.

Expand Down
62 changes: 31 additions & 31 deletions docs/sphinx_doc/source/tutorial/204-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

# About Service

Service function is a set of multi-functional utility tools that can be
used to enhance the capabilities of agents, such as executing Python code,
web search, file operations, and more.
Service function is a set of multi-functional utility tools that can be
used to enhance the capabilities of agents, such as executing Python code,
web search, file operations, and more.
This tutorial provides an overview of the service functions available in
AgentScope and how to use them to enhance the capabilities of your agents.

Expand Down Expand Up @@ -33,33 +33,33 @@ The following table outlines the various Service functions by type. These functi
| | `write_json_file` | Serialize a Python object to JSON and write to a file. |
| *More services coming soon* | | More service functions are in development and will be added to AgentScope to further enhance its capabilities. |

About each service function, you can find detailed information in the
About each service function, you can find detailed information in the
[API document](https://modelscope.github.io/agentscope/).

## How to use Service Functions

AgentScope provides two service classes for Service functions,
AgentScope provides two service classes for Service functions,
`ServiceFactory` and `ServiceResponse`.
- `ServiceFactory` is mainly used to convert general Python functions into
a form that can be directly used by large-scale models, and automatically
- `ServiceFactory` is mainly used to convert general Python functions into
a form that can be directly used by large-scale models, and automatically
generate function descriptions in JSON schema format.
- `ServiceResponse` is a subclass of a dictionary, providing a unified call
- `ServiceResponse` is a subclass of a dictionary, providing a unified call
result interface for all Service functions.

### About Service Factory

The tools used by agents are generally of the function type. Developers
need to prepare functions that can be called directly by large models, and
provide descriptions of the functions. However, general functions often
require developers to provide some parameters (such as keys, usernames,
specific URLs, etc.), and then the large model can use them. At the same
time, it is also a tedious task to generate specific format descriptions
The tools used by agents are generally of the function type. Developers
need to prepare functions that can be called directly by large models, and
provide descriptions of the functions. However, general functions often
require developers to provide some parameters (such as keys, usernames,
specific URLs, etc.), and then the large model can use them. At the same
time, it is also a tedious task to generate specific format descriptions
for multiple functions.

To tackle the above problems, AgentScope introduces `ServiceFactory`. For a
given Service function, it allows developers to specify some parameters,
generate a function that can be called directly by large models, and
automatically generate function descriptions based on the Docstring. Take
To tackle the above problems, AgentScope introduces `ServiceFactory`. For a
given Service function, it allows developers to specify some parameters,
generate a function that can be called directly by large models, and
automatically generate function descriptions based on the Docstring. Take
the Bing web search function as an example.

```python
Expand Down Expand Up @@ -96,8 +96,8 @@ We use the `get` function of `ServiceFactory` to process it:
from agentscope.service import ServiceFactory

func, func_intro = ServiceFactory.get(
bing_search,
api_key="xxx",
bing_search,
api_key="xxx",
num_results=3)
```

Expand All @@ -115,7 +115,7 @@ def bing_search(question: str) -> ServiceResponse:
return bing_search(question, api_key="xxx", num_results=3)
```

The generated JSON schema format is as follows, which can be directly used
The generated JSON schema format is as follows, which can be directly used
in the `tools` field of the OpenAI API.

```python
Expand Down Expand Up @@ -156,11 +156,11 @@ the agent can specify the arguments properly.

### About ServiceResponse

`ServiceResponse` is a wrapper for the execution results of the services,
containing two fields, `status` and `content`. When the Service function
runs to completion normally, `status` is `ServiceExecStatus.SUCCESS`, and
`content` is the return value of the function. When an error occurs during
execution, `status` is `ServiceExecStatus.Error`, and `content` contains
`ServiceResponse` is a wrapper for the execution results of the services,
containing two fields, `status` and `content`. When the Service function
runs to completion normally, `status` is `ServiceExecStatus.SUCCESS`, and
`content` is the return value of the function. When an error occurs during
execution, `status` is `ServiceExecStatus.Error`, and `content` contains
the error message.

```python
Expand Down Expand Up @@ -188,7 +188,7 @@ class ServiceResponse(dict):
"""
self.status = status
self.content = content

# [omitted for brevity]
```

Expand All @@ -201,16 +201,16 @@ from agentscope.service import ServiceResponse
from agentscope.agents import AgentBase


def create_file(file_path: str, content: str = "") -> ServiceResponse:
def create_file(file_path: str, content: str = "") -> ServiceResponse:
"""
Create a file and write content to it.
Args:
file_path (str): The path to the file to be created.
content (str): The content to be written to the file.
Returns:
ServiceResponse: A boolean indicating success or failure, and a
ServiceResponse: A boolean indicating success or failure, and a
string containing any error message (if any), including the error type.
"""
# ... [omitted for brevity]
Expand Down
Loading

0 comments on commit baf9cea

Please sign in to comment.