Skip to content

Commit

Permalink
fix sphinx link
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Jan 19, 2024
1 parent c41496a commit 2854d9a
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 106 deletions.
8 changes: 3 additions & 5 deletions docs/sphinx_doc/source/tutorial/101-installation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(101-installation)=

# Installation

To install AgentScope, you need to have Python 3.9 or higher installed. We recommend setting up a new virtual environment specifically for AgentScope:
Expand Down Expand Up @@ -44,7 +46,6 @@ pip install agentscope
pip install agentscope[distribute] # On Mac use `pip install agentscope\[distribute\]`
```


#### Install from Source

For users who prefer to install AgentScope directly from the source code, follow these steps to clone the repository and install the platform in editable mode:
Expand All @@ -62,9 +63,6 @@ pip install -e .
pip install -e .[distribute] # On Mac use `pip install -e .\[distribute\]`
```


**Note**: The `[distribute]` option installs additional dependencies required for distributed applications. Remember to activate your virtual environment before running these commands.



[[Return to the top]](#installation)
[[Return to the top]](#installation)
7 changes: 3 additions & 4 deletions docs/sphinx_doc/source/tutorial/102-concepts.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(102-concepts)=

# Fundamental Concepts

In this tutorial, you'll have an initial understanding of the **fundamental concepts** of AgentScope. We will focus on how a multi-agent application runs based on our platform and familiarize you with the essential terms. Let's get started!
Expand All @@ -12,7 +14,6 @@ In this tutorial, you'll have an initial understanding of the **fundamental conc
* **Service** is a collection of functionality tools (e.g., web search, code interpreter, file processing) that provide specific capabilities or processes that are independent of an agent's memory state. Services can be invoked by agents or other components and designed to be reusable across different scenarios.
* **Pipeline** refers to the interaction order or pattern of agents in a task. AgentScope provides built-in `pipelines` to streamline the process of collaboration across multiple agents, such as `SequentialPipeline` and `ForLoopPipeline`. When a `Pipeline` is executed, the *message* passes from predecessors to successors with intermediate results for the task.


## Code Structure

```bash
Expand Down Expand Up @@ -42,6 +43,4 @@ AgentScope
└── ... ..
```



[[Return to the top]](#fundamental-concepts)
[[Return to the top]](#fundamental-concepts)
19 changes: 9 additions & 10 deletions docs/sphinx_doc/source/tutorial/103-example.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(103-example)=

# Getting Started with a Simple Example

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**.
Expand All @@ -13,10 +15,9 @@ Agent is the basic composition and communication unit in AgentScope. To initiali
| Embedding | `openai_embedding` | API for text embeddings |
| General usages in POST | `post_api` | *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:

```
```python
model_config = {
"type": "openai", # Choose from "openai", "openai_dall_e", or "openai_embedding"
"name": "{your_config_name}", # A unique identifier for your config
Expand All @@ -26,9 +27,10 @@ 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]](https://alibaba.github.io/AgentScope/tutorial/203-model.html).
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.

```python
import agentscope

Expand All @@ -38,7 +40,6 @@ modelscope_cfg_dict = {...dict_filling...}
agentscope.init(model_configs=[openai_cfg_dict, modelscope_cfg_dict])
```


## Step2: Create Agents

Creating agents is straightforward in AgentScope. After initializing AgentScope with your model configurations (Step 1 above), you can then define each agent with its corresponding role and specific model.
Expand All @@ -55,7 +56,7 @@ dialogAgent = DialogAgent(name="assistant", model="gpt-4")
userAgent = UserAgent()
```

**NOTE**: Please refer to [[Customizing Your Custom Agent with Agent Pool]](https://alibaba.github.io/AgentScope/tutorial/201-agent.html) for all available agents.
**NOTE**: Please refer to [[Customizing Your Custom Agent with Agent Pool]](201-agent) for all available agents.

## Step3: Agent Conversation

Expand All @@ -81,7 +82,7 @@ while True:

# Terminate the conversation if the user types "exit"
if x.content == "exit":
print("Exiting the conversation.")
print("Exiting the conversation.")
break
```

Expand All @@ -93,11 +94,9 @@ from agentscope.pipelines.functional import sequentialpipeline
# Execute the conversation loop within a pipeline structure
x = None
while x is None or x.content != "exit":
x = sequentialpipeline([dialog_agent, user_agent])
x = sequentialpipeline([dialog_agent, user_agent])
```

For more details about how to utilize pipelines for complex agent interactions, please refer to [[Agent Interactions: Dive deeper into Pipelines and Message Hub]](https://alibaba.github.io/AgentScope/tutorial/202-pipeline.html).


For more details about how to utilize pipelines for complex agent interactions, please refer to [[Agent Interactions: Dive deeper into Pipelines and Message Hub]](202-pipeline).

[[Return to the top]](#getting-started-with-a-simple-example)
43 changes: 24 additions & 19 deletions docs/sphinx_doc/source/tutorial/104-usecase.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(104-usecase)=

# Crafting Your First Application

<img src="https://img.alicdn.com/imgextra/i3/O1CN01dFpOh82643mygUh2Z_!!6000000007607-2-tps-1024-1024.png" alt="img" style="zoom:25%;" />
Expand All @@ -10,19 +12,25 @@ 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](https://alibaba.github.io/AgentScope/tutorial/102-concepts.html). 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](102-concepts). The overview of this tutorial is shown below:

* [Step 1: Prepare **Model API** and Set Model Configs](#step-1-prepare-model-api-and-set-model-configs)
* [Step 2: Define the Roles of Each **Agent**](#step-2-define-the-roles-of-each-agent)
* [Step 3: **Initialize** AgentScope and the Agents](#step-3-initialize-agentscope-and-the-agents)
* [Step 4: Set Up the Game Logic with **Pipelines**](#step-4-set-up-the-game-logic-with-pipelines)
* [Step 5: **Run** the Application](#step-5-run-the-application)
- [Crafting Your First Application](#crafting-your-first-application)
- [Getting Started](#getting-started)
- [Step 1: Prepare Model API and Set Model Configs](#step-1-prepare-model-api-and-set-model-configs)
- [Step 2: Define the Roles of Each Agent](#step-2-define-the-roles-of-each-agent)
- [Step 3: Initialize AgentScope and the Agents](#step-3-initialize-agentscope-and-the-agents)
- [Step 4: Set Up the Game Logic](#step-4-set-up-the-game-logic)
- [Leverage Pipeline and MsgHub](#leverage-pipeline-and-msghub)
- [Implement Werewolf Pipeline](#implement-werewolf-pipeline)
- [Step 5: Run the Application](#step-5-run-the-application)
- [Next step](#next-step)
- [Other Example Applications](#other-example-applications)

**Note**: all the configurations and code for this tutorial can be found in `examples/werewolf`.

### Step 1: Prepare Model API and Set Model Configs

As we discussed in the last tutorial, you need to prepare your model configurations into a JSON file for standard OpenAI chat API, FastChat, and vllm. More details and advanced usages such as configuring local models with POST API are presented in [Tutorial-Model-API](https://alibaba.github.io/AgentScope/tutorial/203-model.html).
As we discussed in the last tutorial, you need to prepare your model configurations into a JSON file for standard OpenAI chat API, FastChat, and vllm. More details and advanced usages such as configuring local models with POST API are presented in [Tutorial-Model-API](203-model).

```json
[
Expand Down Expand Up @@ -138,7 +146,7 @@ To simplify the construction of agent communication, AgentScope provides two hel

The game logic is divided into two major phases: (1) night when werewolves act, and (2) daytime when all players discuss and vote. Each phase will be handled by a section of code using pipelines to manage multi-agent communications.

* **1.1 Night Phase: Werewolves Discuss and Vote**
- **1.1 Night Phase: Werewolves Discuss and Vote**

During the night phase, werewolves must discuss among themselves to decide on a target. The `msghub` function creates a message hub for the werewolves to communicate in, where every message sent by an agent is observable by all other agents within the `msghub`.

Expand Down Expand Up @@ -169,7 +177,7 @@ After the discussion, werewolves proceed to vote for their target, and the major
)
```

* **1.2 Witch's Turn**
- **1.2 Witch's Turn**

If the witch is still alive, she gets the opportunity to use her powers to either save the player chosen by the werewolves or use her poison.

Expand All @@ -178,7 +186,7 @@ If the witch is still alive, she gets the opportunity to use her powers to eithe
healing_used_tonight = False
if witch in survivors:
if healing:
# Witch decides whether to use the healing potion
# Witch decides whether to use the healing potion
hint = HostMsg(
content=Prompts.to_witch_resurrect.format_map(
{"witch_name": witch.name, "dead_name": dead_player[0]},
Expand All @@ -191,7 +199,7 @@ If the witch is still alive, she gets the opportunity to use her powers to eithe
healing = False
```

* **1.3 Seer's Turn**
- **1.3 Seer's Turn**

The seer has a chance to reveal the true identity of a player. This information can be crucial for the villagers. The `observe()` function allows each agent to take note of a message without immediately replying to it.

Expand All @@ -210,7 +218,7 @@ The seer has a chance to reveal the true identity of a player. This information
seer.observe(hint)
```

* **1.4 Update Alive Players**
- **1.4 Update Alive Players**

Based on the actions taken during the night, the list of surviving players needs to be updated.

Expand All @@ -219,7 +227,7 @@ Based on the actions taken during the night, the list of surviving players needs
survivors, wolves = update_alive_players(survivors, wolves, dead_player)
```

* **2.1 Daytime Phase: Discussion and Voting**
- **2.1 Daytime Phase: Discussion and Voting**

During the day, all players will discuss and then vote to eliminate a suspected werewolf.

Expand All @@ -239,7 +247,7 @@ During the day, all players will discuss and then vote to eliminate a suspected
survivors, wolves = update_alive_players(survivors, wolves, vote_res)
```

* **2.2 Check for Winning Conditions**
- **2.2 Check for Winning Conditions**

After each phase, the game checks if the werewolves or villagers have won.

Expand All @@ -249,7 +257,7 @@ After each phase, the game checks if the werewolves or villagers have won.
break
```

* **2.3 Continue to the Next Round**
- **2.3 Continue to the Next Round**

If neither werewolves nor villagers win, the game continues to the next round.

Expand Down Expand Up @@ -311,14 +319,11 @@ Moderator: The day is coming, all the players open your eyes. Last night is peac

Now you've grasped how to conveniently set up a multi-agent application with AgentScope. Feel free to tailor the game to include additional roles and introduce more sophisticated strategies. For more advanced tutorials that delve deeper into more capabilities of AgentScope, such as *memory management* and *service functions* utilized by agents, please refer to the tutorials in the **Advanced Exploration** section and look up the API references.


## Other Example Applications

- Example of Simple Group Conversation: [examples/Simple Conversation](https://github.com/alibaba/AgentScope/tree/main/examples/simple_chat/README.md)
- Example of Werewolves: [examples/Werewolves](https://github.com/alibaba/AgentScope/tree/main/examples/werewolves/README.md)
- Example of Distributed Agents: [examples/Distributed Agents](https://github.com/alibaba/AgentScope/tree/main/examples/distributed_agents/README.md)
- ...



[[Return to the top]](#crafting-your-first-application)
[[Return to the top]](#crafting-your-first-application)
12 changes: 9 additions & 3 deletions docs/sphinx_doc/source/tutorial/105-logging.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
(105-logging)=

# Logging and WebUI

Welcome to the tutorial on logging in multi-agent applications with AgentScope. We'll also touch on how you can visualize these logs using a simple web interface. This guide will help you track the agent's interactions and system information in a clearer and more organized way.
Expand Down Expand Up @@ -65,17 +67,22 @@ logger.error("The agent encountered an unexpected error while processing a reque
To visualize these logs, we provide a customized gradio component in `src/agentscope/web_ui`.

### Quick Running

For convince, we provide the pre-built app in a wheel file, you can run the WebUI in the following command:

```shell
pip install gradio_groupchat-0.0.1-py3-none-any.whl
python app.py
```

After the init and entering the UI port printed by `app.py`, e.g., `http://127.0.0.1:7860/`, you can choose `run.log.demo` in the top-middle `FileSelector` window (it's a demo log file provided by us). Then, the dialog and system log should be shown correctly in the bottom windows.

![webui](https://img.alicdn.com/imgextra/i2/O1CN01hSaFue1EdL2yCEznc_!!6000000000374-2-tps-3066-1808.png)

### For Other Customization

To customize the backend, or the frontend of the provided WebUI, you can

```shell
# generate the template codes
# for network connectivity problem, try to run
Expand All @@ -91,12 +98,11 @@ gradio cc dev
```

If you want to release the modification, you can do

```shell
gradio cc build
pip install <path-to-whl>
python app.py
```



[[Return to the top]](#logging-and-webui)
[[Return to the top]](#logging-and-webui)
Loading

0 comments on commit 2854d9a

Please sign in to comment.