Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added README file for conversation_self_organizing #210

Merged
merged 5 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions examples/conversation_basic/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Multi-Agent Conversation in AgentScope
This is a demo of how to program a multi-agent conversation in AgentScope.

This example will show how to program a multi-agent conversation in AgentScope.
Complete code is in `conversation.py`, which set up a user agent and an
assistant agent to have a conversation. When user input "exit", the
conversation ends.
Expand All @@ -8,5 +9,13 @@ You can modify the `sys_prompt` to change the role of assistant agent.
# Note: Set your api_key in conversation.py first
python conversation.py
```
## Tested Models

These models are tested in this example. For other models, some modifications may be needed.
- dashscope_chat (qwen-max)
- ollama_chat (ollama_llama3_8b)
- gemini_chat (models/gemini-pro)

## Prerequisites
To set up model serving with open-source LLMs, follow the guidance in
[scripts/REAMDE.md](../../scripts/README.md).
[scripts/REAMDE.md](../../scripts/README.md).
29 changes: 29 additions & 0 deletions examples/conversation_self_organizing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Self-Organizing Conversation Example

This example will show
- How to set up a self-organizing conversation using the `DialogAgent` and `agent_builder`
- How to extract the discussion scenario and participant agents from the `agent_builder`'s response
- How to conduct a multi-round discussion among the participant agents


## Background

In this example, we demonstrate how to create a self-organizing conversation where the `agent_builder` automatically sets up the agents participating in the discussion based on a given question. The `agent_builder` provides the discussion scenario and the characteristics of the participant agents. The participant agents then engage in a multi-round discussion to solve the given question.


## Tested Models

These models are tested in this example. For other models, some modifications may be needed.
- `dashscope_chat` with `qwen-turbo`
- `ollama_chat` with `llama3_8b`
- `gemini_chat` with `models/gemini-1.0-pro-latest`


## Prerequisites

Fill the next cell to meet the following requirements
- Set up the `model_configs` with the appropriate API keys and endpoints
- Provide the path to the `agent_builder_instruct.txt` file in the `load_txt` function
- Set the desired `max_round` for the discussion
- Provide the `query` or question for the discussion
- [Optional] Adjust the `generate_args` such as `temperature` for the `openai_chat` model
75 changes: 21 additions & 54 deletions examples/conversation_with_mentions/README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,40 @@
###
# Multi-Agent Group Conversation in AgentScope

This example demonstrates a multi-agent group conversation facilitated by AgentScope. The script `main.py` sets up a virtual chat room where a user agent interacts with several NPC (non-player character) agents. The chat utilizes a special **"@"** mention functionality, which allows participants to address specific agents and have a more directed conversation.
This example demonstrates a multi-agent group conversation facilitated by AgentScope. The script sets up a virtual chat room where a user agent interacts with several NPC (non-player character) agents. Participants can utilize a special "@" mention functionality to address specific agents directly.

## Key Features
## Background

- **Real-time Group Conversation**: Engage in a chat with multiple agents responding in real time.
- **@ Mention Functionality**: Use the "@" symbol followed by an agent's name to specifically address that agent within the conversation.
- **Dynamic Flow**: User-driven conversation with agents responding based on the context and mentions.
- **Configurable Agent Roles**: Easily modify agent roles and behaviors by editing the `sys_prompt` in the configuration files.
- **User Timeout**: If the user does not respond within a specified time, the conversation continues with the next agent.
The conversation takes place in a simulated chat room environment with predefined roles for each participant. Topics are open-ended and evolve based on the user's input and agents' responses.

## How to Use

To start the group conversation, follow these steps:

1. Make sure to set your `api_key` in the `configs/model_configs.json` file.
2. Run the script using the following command:
## Tested Models

```bash
python main.py
These models are tested in this example. For other models, some modifications may be needed.
- gemini_chat (models/gemini-pro, models/gemini-1.0-pro)
- dashscope_chat (qwen-max, qwen-turbo)
- ollama_chat (ollama_llama3_8b)

# or launch agentscope studio
as_studio main.py
```
## Prerequisites

1. To address a specific agent in the chat, type "@" followed by the agent's name in your message.
2. To exit the chat, simply type "exit" when it's your turn to speak.
Fill the next cell to meet the following requirements:
- Set your `api_key` in the `configs/model_configs.json` file
- Optional: Launch agentscope studio with `as_studio main.py`

## Background and Conversation Flow

The conversation takes place in a simulated chat room environment with roles defined for each participant. The user acts as a regular chat member with the ability to speak freely and address any agent. NPC agents are pre-configured with specific roles that determine their responses and behavior in the chat. The topic of the conversation is open-ended and can evolve organically based on the user's input and agents' programmed personas.

### Example Interaction
## How to Use

```
User input: Hi, everyone! I'm excited to join this chat.
AgentA: Welcome! We're glad to have you here.
User input: @AgentB, what do you think about the new technology trends?
AgentB: It's an exciting time for tech! There are so many innovations on the horizon.
...
```
1. Run the script using the command: `python main.py`
2. Address specific agents by typing "@" followed by the agent's name.
3. Type "exit" to leave the chat.

## Customization Options

The group conversation script provides several options for customization, allowing you to tailor the chat experience to your preferences.

You can customize the conversation by editing the agent configurations and model parameters. The `agent_configs.json` file allows you to set specific behaviors for each NPC agent, while `model_configs.json` contains the parameters for the conversation model.
You can adjust the behavior and parameters of the NPC agents and conversation model by editing the `agent_configs.json` and `model_configs.json` files, respectively.

### Changing User Input Time Limit

The `USER_TIME_TO_SPEAK` variable sets the time limit (in seconds) for the user to input their message during each round. By default, this is set to 10 seconds. You can adjust this time limit by modifying the value of `USER_TIME_TO_SPEAK` in the `main.py` script.

For example, to change the time limit to 20 seconds, update the line in `main.py` as follows:

```
USER_TIME_TO_SPEAK = 20 # User has 20 seconds to type their message
```
Adjust the `USER_TIME_TO_SPEAK` variable in the `main.py` script to change the time limit for user input.

### Setting a Default Topic for the Chat Room

The `DEFAULT_TOPIC` variable defines the initial message or topic of the chat room. It sets the stage for the conversation and is announced at the beginning of the chat session. You can change this message to prompt a specific discussion topic or to provide instructions to the agents.

To customize this message, modify the `DEFAULT_TOPIC` variable in the `main.py` script. For instance, if you want to set the default topic to discuss "The Future of Artificial Intelligence," you would change the code as follows:

```python
DEFAULT_TOPIC = """
This is a chat room about the Future of Artificial Intelligence and you can
speak freely and briefly.
"""
```

With these customizations, the chat room can be tailored to fit specific themes or time constraints, enhancing the user's control over the chat experience.
Modify the `DEFAULT_TOPIC` variable in the `main.py` script to set the initial topic of the chat room.
###
DavdGao marked this conversation as resolved.
Show resolved Hide resolved