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 [skip ci]

camel-docs-bote601f4364c73
diff --git a/docs/mintlify/reference/camel.agents.chat_agent.mdx b/docs/mintlify/reference/camel.agents.chat_agent.mdx
index 0a03eedd0..fc3e8a660 100644
--- a/docs/mintlify/reference/camel.agents.chat_agent.mdx
+++ b/docs/mintlify/reference/camel.agents.chat_agent.mdx
@@ -273,7 +273,7 @@ Class for managing conversations of CAMEL Chat Agents.
- **enable_snapshot_clean** (bool, optional): Whether to clean snapshot markers and references from historical tool outputs in memory. This removes verbose DOM markers (like [ref=...]) from older tool results while keeping the latest output intact for immediate use. (default: :obj:`False`)
- **retry_attempts** (int, optional): Maximum number of retry attempts for rate limit errors. (default: :obj:`3`)
- **retry_delay** (float, optional): Initial delay in seconds between retries. Uses exponential backoff. (default: :obj:`1.0`)
-- **step_timeout** (Optional[float], optional): Timeout in seconds for the entire step operation. If None, no timeout is applied. (default: :obj:`None`)
+- **step_timeout** (Optional[float], optional): Timeout in seconds for the entire step operation. If None, no timeout is applied. (default: :obj:`None`) on_request_usage (Optional[Callable[[Dict[str, Any]], Any]], optional): Callback triggered after each LLM request completes. Useful for real-time token metering within a single step loop. The callback receives a payload with per-request usage and cumulative step usage. (default: :obj:`None`)
- **stream_accumulate** (Optional[bool], optional): When True, partial streaming updates return accumulated content. When False, partial updates return only the incremental delta (recommended). If None, defaults to False with a deprecation warning for users who previously relied on the old default (True). (default: :obj:`None`, which behaves as :obj:`False`)
- **summary_window_ratio** (float, optional): Maximum fraction of the total context window that can be occupied by summary information. Used to limit how much of the model's context is reserved for summarization results. (default: :obj:`0.6`)
@@ -307,6 +307,7 @@ def __init__(
retry_attempts: int = 3,
retry_delay: float = 1.0,
step_timeout: Optional[float] = Constants.TIMEOUT_THRESHOLD,
+ on_request_usage: Optional[Callable[[Dict[str, Any]], Any]] = None,
stream_accumulate: Optional[bool] = None,
summary_window_ratio: float = 0.6
):
@@ -1236,6 +1237,34 @@ Updates a token usage tracker with values from a usage dictionary.
- **tracker** (Dict[str, int]): The token usage tracker to update.
- **usage_dict** (Dict[str, int]): The usage dictionary with new values.
+<a id="camel.agents.chat_agent.ChatAgent._emit_request_usage"></a>
+
+### _emit_request_usage
+
+```python
+def _emit_request_usage(
+ self,
+ usage_dict: Dict[str, Any],
+ step_usage: Dict[str, int],
+ request_index: int,
+ response_id: str
+):
+```
+
+<a id="camel.agents.chat_agent.ChatAgent._build_request_usage_payload"></a>
+
+### _build_request_usage_payload
+
+```python
+def _build_request_usage_payload(
+ self,
+ usage_dict: Dict[str, Any],
+ step_usage: Dict[str, int],
+ request_index: int,
+ response_id: str
+):
+```
+
<a id="camel.agents.chat_agent.ChatAgent._convert_to_chatagent_response"></a>
### _convert_to_chatagent_response
@@ -1522,6 +1551,7 @@ def _process_stream_chunks_with_accumulator(
content_accumulator: StreamContentAccumulator,
accumulated_tool_calls: Dict[str, Any],
tool_call_records: List[ToolCallingRecord],
+ request_token_usage: Dict[str, int],
step_token_usage: Dict[str, int],
response_format: Optional[Type[BaseModel]] = None
):