Skip to content

Commit

Permalink
fix model configs in examples and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Feb 4, 2024
1 parent 4ad546b commit a1d464b
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 55 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ AgentScope supports the following model API services:
- [HuggingFace](https://huggingface.co/docs/api-inference/index) and [ModelScope](https://www.modelscope.cn/docs/%E9%AD%94%E6%90%ADv1.5%E7%89%88%E6%9C%AC%20Release%20Note%20(20230428)) inference APIs
- Customized model APIs

| | Model Type Argument | Support APIs |
|----------------------|---------------------|---------------------------------------------------------------|
| OpenAI Chat API | `openai` | Standard OpenAI Chat API, FastChat and vllm |
| OpenAI DALL-E API | `openai_dall_e` | Standard DALL-E API |
| OpenAI Embedding API | `openai_embedding` | OpenAI embedding API |
| Post API | `post_api` | Huggingface/ModelScope inference API, and customized post API |
| | Model Type Argument | Support APIs |
|----------------------|---------------------|----------------------------------------------------------------|
| OpenAI Chat API | `openai` | Standard OpenAI Chat API, FastChat and vllm |
| OpenAI DALL-E API | `openai_dall_e` | Standard DALL-E API |
| OpenAI Embedding API | `openai_embedding` | OpenAI embedding API |
| Post API | `post_api` | Huggingface/ModelScope inference API, and customized post API |
| Post API Chat | `post_api_chat` | A customized POST API which is compatible with OpenAI Chat API |

##### OpenAI API Config

Expand Down
1 change: 1 addition & 0 deletions docs/sphinx_doc/source/tutorial/103-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Agent is the basic composition and communication unit in AgentScope. To initiali
| 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 |
| Chat usages in POST | `post_api_chat` | POST APIs which are compatible with OpenAI Chat 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 Down
2 changes: 1 addition & 1 deletion examples/conversation/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
},
{
"model_type": "post_api",
"model_type": "post_api_chat",
"model_id": "my_post_api",
"api_url": "https://xxx",
"headers": {},
Expand Down
12 changes: 6 additions & 6 deletions examples/werewolf/configs/agent_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"args": {
"name": "Player1",
"sys_prompt": "Act as a player in a werewolf game. You are Player1 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing werewolf in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4-turbo",
"use_memory": true
}
},
Expand All @@ -13,7 +13,7 @@
"args": {
"name": "Player2",
"sys_prompt": "Act as a player in a werewolf game. You are Player2 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing werewolf in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4",
"use_memory": true
}
},
Expand All @@ -22,7 +22,7 @@
"args": {
"name": "Player3",
"sys_prompt": "Act as a player in a werewolf game. You are Player3 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing villager in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4",
"use_memory": true
}
},
Expand All @@ -31,7 +31,7 @@
"args": {
"name": "Player4",
"sys_prompt": "Act as a player in a werewolf game. You are Player4 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing villager in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4",
"use_memory": true
}
},
Expand All @@ -40,7 +40,7 @@
"args": {
"name": "Player5",
"sys_prompt": "Act as a player in a werewolf game. You are Player5 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing seer in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4",
"use_memory": true
}
},
Expand All @@ -49,7 +49,7 @@
"args": {
"name": "Player6",
"sys_prompt": "Act as a player in a werewolf game. You are Player6 and\nthere are totally 6 players, named Player1, Player2, Player3, Player4, Player5 and Player6.\n\nPLAYER ROLES:\nIn werewolf game, players are divided into two werewolves, two villagers, one seer and one witch. Note only werewolves know who are their teammates.\nWerewolves: They know their teammates' identities and attempt to eliminate a villager each night while trying to remain undetected.\nVillagers: They do not know who the werewolves are and must work together during the day to deduce who the werewolves might be and vote to eliminate them.\nSeer: A villager with the ability to learn the true identity of one player each night. This role is crucial for the villagers to gain information.\nWitch: A character who has a one-time ability to save a player from being eliminated at night (sometimes this is a potion of life) and a one-time ability to eliminate a player at night (a potion of death).\n\nGAME RULE:\nThe game is consisted of two phases: night phase and day phase. The two phases are repeated until werewolf or villager win the game.\n1. Night Phase: During the night, the werewolves discuss and vote for a player to eliminate. Special roles also perform their actions at this time (e.g., the Seer chooses a player to learn their role, the witch chooses a decide if save the player).\n2. Day Phase: During the day, all surviving players discuss who they suspect might be a werewolf. No one reveals their role unless it serves a strategic purpose. After the discussion, a vote is taken, and the player with the most votes is \"lynched\" or eliminated from the game.\n\nVICTORY CONDITION:\nFor werewolves, they win the game if the number of werewolves is equal to or greater than the number of remaining villagers.\nFor villagers, they win if they identify and eliminate all of the werewolves in the group.\n\nCONSTRAINTS:\n1. Your response should be in the first person.\n2. This is a conversational game. You should response only based on the conversation history and your strategy.\n\nYou are playing witch in this game.\n",
"model_id": "gpt-3.5-turbo",
"model_id": "gpt-4",
"use_memory": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/werewolf/configs/model_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}
},
{
"model_type": "post_api",
"model_type": "post_api_chat",
"model_id": "my_post_api",
"api_url": "https://xxx",
"headers": {},
Expand Down
11 changes: 6 additions & 5 deletions notebook/conversation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,18 @@
"agentscope.init(\n",
" model_configs=[\n",
" {\n",
" \"type\": \"openai\",\n",
" \"name\": \"gpt-3.5-turbo\",\n",
" \"model_type\": \"openai\",\n",
" \"model_id\": \"gpt-3.5-turbo\",\n",
" \"model\": \"gpt-3.5-turbo\",\n",
" \"api_key\": \"xxx\", # Load from env if not provided\n",
" \"organization\": \"xxx\", # Load from env if not provided\n",
" \"generate_args\": {\n",
" \"temperature\": 0.5,\n",
" },\n",
" },\n",
" {\n",
" \"type\": \"post_api\",\n",
" \"name\": \"my_post_api\",\n",
" \"model_type\": \"post_api_chat\",\n",
" \"model_id\": \"my_post_api\",\n",
" \"api_url\": \"https://xxx\",\n",
" \"headers\": {},\n",
" },\n",
Expand All @@ -85,7 +86,7 @@
"dialog_agent = DialogAgent(\n",
" name=\"Assistant\",\n",
" sys_prompt=\"You're a helpful assistant.\",\n",
" model=\"gpt-3.5-turbo\", # replace by your model config name\n",
" model_id=\"gpt-3.5-turbo\", # replace by your model config name\n",
")\n",
"user_agent = UserAgent()"
]
Expand Down
Loading

0 comments on commit a1d464b

Please sign in to comment.