Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge

camel-docs-botf944b9a54eac
diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.json
index 3b17d96b8..1f8c2a370 100644
--- a/docs/mintlify/docs.json
+++ b/docs/mintlify/docs.json
@@ -562,6 +562,7 @@
"pages": [
"reference/camel.environments.models",
"reference/camel.environments.multi_step",
+ "reference/camel.environments.rlcards_env",
"reference/camel.environments.single_step",
"reference/camel.environments.tic_tac_toe"
]
diff --git a/docs/mintlify/reference/camel.environments.rlcards_env.mdx b/docs/mintlify/reference/camel.environments.rlcards_env.mdx
new file mode 100644
index 000000000..103d76ac7
--- /dev/null
+++ b/docs/mintlify/reference/camel.environments.rlcards_env.mdx
@@ -0,0 +1,495 @@
+<a id="camel.environments.rlcards_env"></a>
+
+<a id="camel.environments.rlcards_env.ActionExtractor"></a>
+
+## ActionExtractor
+
+```python
+class ActionExtractor(BaseExtractorStrategy):
+```
+
+A strategy for extracting RLCard actions from text.
+
+<a id="camel.environments.rlcards_env.ActionExtractor.__init__"></a>
+
+### __init__
+
+```python
+def __init__(self, action_pattern: str = '<Action>\\s*(.+)'):
+```
+
+Initialize the action extractor with a regex pattern.
+
+**Parameters:**
+
+- **action_pattern** (str): The regex pattern to extract actions. (default: :obj:`"<Action>\\s*(.+)"`).
+
+<a id="camel.environments.rlcards_env.RLCardsEnv"></a>
+
+## RLCardsEnv
+
+```python
+class RLCardsEnv(MultiStepEnv):
+```
+
+A base environment for RLCard games.
+
+This environment implements a wrapper around RLCard environments for
+reinforcement learning with LLMs. It handles the conversion between
+RLCard states and actions and the CAMEL environment interface.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ game_name: str,
+ extractor: Optional[BaseExtractor] = None,
+ max_steps: Optional[int] = None,
+ num_players: int = 2,
+ **kwargs
+):
+```
+
+Initialize the RLCard environment.
+
+**Parameters:**
+
+- **game_name** (str): The name of the RLCard game to play.
+- **extractor** (Optional[BaseExtractor]): Extractor to process LLM responses. If None, a default extractor with ActionExtractor will be used. (default: :obj:`None`)
+- **max_steps** (Optional[int]): Maximum steps per episode. (default: :obj:`None`)
+- **num_players** (int): Number of players in the game. (default: :obj:`2`) **kwargs: Additional environment parameters.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._get_initial_state"></a>
+
+### _get_initial_state
+
+```python
+def _get_initial_state(self):
+```
+
+**Returns:**
+
+ Dict[str, Any]: A dictionary containing the initial state with
+game state, player info, and game status flags.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._get_next_observation"></a>
+
+### _get_next_observation
+
+```python
+def _get_next_observation(self):
+```
+
+**Returns:**
+
+ Observation: An Observation object containing the game state
+description.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._get_terminal_observation"></a>
+
+### _get_terminal_observation
+
+```python
+def _get_terminal_observation(self):
+```
+
+**Returns:**
+
+ Observation: An Observation object containing the final game state
+description.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._is_done"></a>
+
+### _is_done
+
+```python
+def _is_done(self):
+```
+
+**Returns:**
+
+ bool: True if the game is over, False otherwise.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._convert_to_rlcard_action"></a>
+
+### _convert_to_rlcard_action
+
+```python
+def _convert_to_rlcard_action(self, action_str: str):
+```
+
+Convert a string action to the format expected by RLCard.
+
+This method must be implemented by subclasses to handle the specific
+action format of each game.
+
+**Parameters:**
+
+- **action_str** (str): The string representation of the action.
+
+**Returns:**
+
+ Any: The action in the format expected by the RLCard environment.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._format_state_for_observation"></a>
+
+### _format_state_for_observation
+
+```python
+def _format_state_for_observation(self, state: Dict[str, Any]):
+```
+
+Format the RLCard state for human-readable observation.
+
+This method must be implemented by subclasses to create a
+human-readable representation of the game state.
+
+**Parameters:**
+
+- **state** (Dict[str, Any]): The RLCard state dictionary.
+
+**Returns:**
+
+ str: A human-readable representation of the state.
+
+<a id="camel.environments.rlcards_env.RLCardsEnv._format_legal_actions"></a>
+
+### _format_legal_actions
+
+```python
+def _format_legal_actions(self, legal_actions: List[Any]):
+```
+
+Format the legal actions for human-readable observation.
+
+This method must be implemented by subclasses to create a
+human-readable representation of the legal actions.
+
+**Parameters:**
+
+- **legal_actions** (List[Any]): The list of legal actions.
+
+**Returns:**
+
+ str: A human-readable representation of the legal actions.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv"></a>
+
+## BlackjackEnv
+
+```python
+class BlackjackEnv(RLCardsEnv):
+```
+
+A Blackjack environment for reinforcement learning with LLMs.
+
+This environment implements a standard Blackjack game where the LLM agent
+plays against a dealer.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ extractor: Optional[BaseExtractor] = None,
+ max_steps: Optional[int] = None,
+ **kwargs
+):
+```
+
+Initialize the Blackjack environment.
+
+**Parameters:**
+
+- **extractor** (Optional[BaseExtractor]): Extractor to process LLM responses. If None, a default extractor will be used. (default: :obj:`None`)
+- **max_steps** (Optional[int]): Maximum steps per episode. (default: :obj:`None`) **kwargs: Additional environment parameters.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv._convert_to_rlcard_action"></a>
+
+### _convert_to_rlcard_action
+
+```python
+def _convert_to_rlcard_action(self, action_str: str):
+```
+
+Convert a string action to the format expected by RLCard Blackjack.
+
+**Parameters:**
+
+- **action_str** (str): The string representation of the action. Expected to be 'hit' or 'stand'.
+
+**Returns:**
+
+ int: 0 for 'hit', 1 for 'stand'.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv._format_state_for_observation"></a>
+
+### _format_state_for_observation
+
+```python
+def _format_state_for_observation(self, state: Dict[str, Any]):
+```
+
+Format the Blackjack state for human-readable observation.
+
+**Parameters:**
+
+- **state** (Dict[str, Any]): The RLCard state dictionary.
+
+**Returns:**
+
+ str: A human-readable representation of the state.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv._format_legal_actions"></a>
+
+### _format_legal_actions
+
+```python
+def _format_legal_actions(self, legal_actions: List[int]):
+```
+
+Format the legal actions for Blackjack.
+
+**Parameters:**
+
+- **legal_actions** (List[int]): The list of legal actions.
+
+**Returns:**
+
+ str: A human-readable representation of the legal actions.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv._format_cards"></a>
+
+### _format_cards
+
+```python
+def _format_cards(self, cards: List[str]):
+```
+
+Format a list of cards for display.
+
+**Parameters:**
+
+- **cards** (List[str]): List of card strings.
+
+**Returns:**
+
+ str: Formatted card string.
+
+<a id="camel.environments.rlcards_env.BlackjackEnv._calculate_hand_value"></a>
+
+### _calculate_hand_value
+
+```python
+def _calculate_hand_value(self, cards: List[str]):
+```
+
+Calculate the value of a hand in Blackjack.
+
+**Parameters:**
+
+- **cards** (List[str]): List of card strings.
+
+**Returns:**
+
+ int: The value of the hand.
+
+<a id="camel.environments.rlcards_env.LeducHoldemEnv"></a>
+
+## LeducHoldemEnv
+
+```python
+class LeducHoldemEnv(RLCardsEnv):
+```
+
+A Leduc Hold'em environment for reinforcement learning with LLMs.
+
+This environment implements a Leduc Hold'em poker game where the LLM agent
+plays against one or more opponents.
+
+<a id="camel.environments.rlcards_env.LeducHoldemEnv.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ extractor: Optional[BaseExtractor] = None,
+ max_steps: Optional[int] = None,
+ num_players: int = 2,
+ **kwargs
+):
+```
+
+Initialize the Leduc Hold'em environment.
+
+**Parameters:**
+
+- **extractor** (Optional[BaseExtractor]): Extractor to process LLM responses. If None, a default extractor will be used. (default: :obj:`None`)
+- **max_steps** (Optional[int]): Maximum steps per episode. (default: :obj:`None`)
+- **num_players** (int): Number of players in the game. (default: :obj:`2`) **kwargs: Additional environment parameters.
+
+<a id="camel.environments.rlcards_env.LeducHoldemEnv._convert_to_rlcard_action"></a>
+
+### _convert_to_rlcard_action
+
+```python
+def _convert_to_rlcard_action(self, action_str: str):
+```
+
+Convert a string action to the format expected by RLCard
+Leduc Hold'em.
+
+**Parameters:**
+
+- **action_str** (str): The string representation of the action. Expected to be 'fold', 'check', 'call', or 'raise'.
+
+**Returns:**
+
+ int: 0 for 'fold', 1 for 'check/call', 2 for 'raise'.
+
+<a id="camel.environments.rlcards_env.LeducHoldemEnv._format_state_for_observation"></a>
+
+### _format_state_for_observation
+
+```python
+def _format_state_for_observation(self, state: Dict[str, Any]):
+```
+
+Format the Leduc Hold'em state for human-readable observation.
+
+**Parameters:**
+
+- **state** (Dict[str, Any]): The RLCard state dictionary.
+
+**Returns:**
+
+ str: A human-readable representation of the state.
+
+<a id="camel.environments.rlcards_env.LeducHoldemEnv._format_legal_actions"></a>
+
+### _format_legal_actions
+
+```python
+def _format_legal_actions(self, legal_actions: List[int]):
+```
+
+Format the legal actions for Leduc Hold'em.
+
+**Parameters:**
+
+- **legal_actions** (List[int]): The list of legal actions.
+
+**Returns:**
+
+ str: A human-readable representation of the legal actions.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv"></a>
+
+## DoudizhuEnv
+
+```python
+class DoudizhuEnv(RLCardsEnv):
+```
+
+A Doudizhu environment for reinforcement learning with LLMs.
+
+This environment implements a standard Doudizhu game where the LLM agent
+plays against two AI opponents.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ extractor: Optional[BaseExtractor] = None,
+ max_steps: Optional[int] = None,
+ **kwargs
+):
+```
+
+Initialize the Doudizhu environment.
+
+**Parameters:**
+
+- **extractor** (Optional[BaseExtractor]): Extractor to process LLM responses. If None, a default extractor will be used. (default: :obj:`None`)
+- **max_steps** (Optional[int]): Maximum steps per episode. (default: :obj:`None`) **kwargs: Additional environment parameters.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv._convert_to_rlcard_action"></a>
+
+### _convert_to_rlcard_action
+
+```python
+def _convert_to_rlcard_action(self, action_str: str):
+```
+
+Convert a string action to the format expected by RLCard Doudizhu.
+
+**Parameters:**
+
+- **action_str** (str): The string representation of the action. Expected to be a card combination or 'pass'.
+
+**Returns:**
+
+ str: The action string in the format expected by RLCard.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv._format_state_for_observation"></a>
+
+### _format_state_for_observation
+
+```python
+def _format_state_for_observation(self, state: Dict[str, Any]):
+```
+
+Format the Doudizhu state for human-readable observation.
+
+**Parameters:**
+
+- **state** (Dict[str, Any]): The RLCard state dictionary.
+
+**Returns:**
+
+ str: A human-readable representation of the state.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv._format_legal_actions"></a>
+
+### _format_legal_actions
+
+```python
+def _format_legal_actions(self, legal_actions: List[str]):
+```
+
+Format the legal actions for Doudizhu.
+
+**Parameters:**
+
+- **legal_actions** (List[str]): The list of legal actions.
+
+**Returns:**
+
+ str: A human-readable representation of the legal actions.
+
+<a id="camel.environments.rlcards_env.DoudizhuEnv._format_cards"></a>
+
+### _format_cards
+
+```python
+def _format_cards(self, cards: List[str]):
+```
+
+Format a list of cards for display.
+
+**Parameters:**
+
+- **cards** (List[str]): List of card strings.
+
+**Returns:**
+
+ str: Formatted card string.
diff --git a/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx b/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx
index 06235bca7..1dc83058b 100644
--- a/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx
+++ b/docs/mintlify/reference/camel.societies.workforce.single_agent_worker.mdx
@@ -14,13 +14,19 @@ A worker node that consists of a single agent.
- **description** (str): Description of the node.
- **worker** (ChatAgent): Worker of the node. A single agent.
+- **max_concurrent_tasks** (int): Maximum number of tasks this worker can process concurrently. (default: :obj:`10`)
<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.__init__"></a>
### __init__
```python
-def __init__(self, description: str, worker: ChatAgent):
+def __init__(
+ self,
+ description: str,
+ worker: ChatAgent,
+ max_concurrent_tasks: int = 10
+):
```
<a id="camel.societies.workforce.single_agent_worker.SingleAgentWorker.reset"></a>
diff --git a/docs/mintlify/reference/camel.societies.workforce.task_channel.mdx b/docs/mintlify/reference/camel.societies.workforce.task_channel.mdx
index e05999f77..9565e51e9 100644
--- a/docs/mintlify/reference/camel.societies.workforce.task_channel.mdx
+++ b/docs/mintlify/reference/camel.societies.workforce.task_channel.mdx
@@ -12,9 +12,11 @@ The status of a packet. The packet can be in one of the following
states:
- `__INLINE_CODE_0__`: The packet has been sent to a worker.
-- `__INLINE_CODE_1__`: The packet has been returned by the worker, meaning that
+- `__INLINE_CODE_1__`: The packet has been claimed by a worker and is being
+processed.
+- `__INLINE_CODE_2__`: The packet has been returned by the worker, meaning that
the status of the task inside has been updated.
-- `__INLINE_CODE_2__`: The packet has been archived, meaning that the content of
+- `__INLINE_CODE_3__`: The packet has been archived, meaning that the content of
the task inside will not be changed. The task is considered
as a dependency.
diff --git a/docs/mintlify/reference/camel.societies.workforce.worker.mdx b/docs/mintlify/reference/camel.societies.workforce.worker.mdx
index ce7498fdb..1db57550e 100644
--- a/docs/mintlify/reference/camel.societies.workforce.worker.mdx
+++ b/docs/mintlify/reference/camel.societies.workforce.worker.mdx
@@ -15,13 +15,19 @@ processing in the workforce system.
- **description** (str): Description of the node.
- **node_id** (Optional[str]): ID of the node. If not provided, it will be generated automatically. (default: :obj:`None`)
+- **max_concurrent_tasks** (int): Maximum number of tasks this worker can process concurrently. (default: :obj:`10`)
<a id="camel.societies.workforce.worker.Worker.__init__"></a>
### __init__
```python
-def __init__(self, description: str, node_id: Optional[str] = None):
+def __init__(
+ self,
+ description: str,
+ node_id: Optional[str] = None,
+ max_concurrent_tasks: int = 10
+):
```
<a id="camel.societies.workforce.worker.Worker.__repr__"></a>
diff --git a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx
index f88631b05..46c0f3a6c 100644
--- a/docs/mintlify/reference/camel.societies.workforce.workforce.mdx
+++ b/docs/mintlify/reference/camel.societies.workforce.workforce.mdx
@@ -354,7 +354,12 @@ still running/paused.
### add_single_agent_worker
```python
-def add_single_agent_worker(self, description: str, worker: ChatAgent):
+def add_single_agent_worker(
+ self,
+ description: str,
+ worker: ChatAgent,
+ max_concurrent_tasks: int = 10
+):
```
Add a worker node to the workforce that uses a single agent.
@@ -363,6 +368,7 @@ Add a worker node to the workforce that uses a single agent.
- **description** (str): Description of the worker node.
- **worker** (ChatAgent): The agent to be added.
+- **max_concurrent_tasks** (int): Maximum number of tasks this worker can process concurrently. (default: :obj:`10`)
**Returns:**