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

chore: Update ModelManager error message for one model (#1719)

Wendong-Fanb643501b0166
diff --git a/camel/agents/chat_agent.py b/camel/agents/chat_agent.py
index 6946ec0f4..3734dfe84 100644
--- a/camel/agents/chat_agent.py
+++ b/camel/agents/chat_agent.py
@@ -694,11 +694,18 @@ class ChatAgent(BaseAgent):
f"index: {self.model_backend.current_model_index}",
exc_info=exc,
)
- if not response:
+ error_info = str(exc)
+
+ if not response and self.model_backend.num_models > 1:
raise ModelProcessingError(
"Unable to process messages: none of the provided models "
"run succesfully."
)
+ elif not response:
+ raise ModelProcessingError(
+ f"Unable to process messages: the only provided model "
+ f"did not run succesfully. Error: {error_info}"
+ )
logger.info(
f"Model {self.model_backend.model_type}, "
@@ -732,11 +739,18 @@ class ChatAgent(BaseAgent):
f"index: {self.model_backend.current_model_index}",
exc_info=exc,
)
- if not response:
+ error_info = str(exc)
+
+ if not response and self.model_backend.num_models > 1:
raise ModelProcessingError(
"Unable to process messages: none of the provided models "
"run succesfully."
)
+ elif not response:
+ raise ModelProcessingError(
+ f"Unable to process messages: the only provided model "
+ f"did not run succesfully. Error: {error_info}"
+ )
logger.info(
f"Model {self.model_backend.model_type}, "
diff --git a/camel/models/model_manager.py b/camel/models/model_manager.py
index f072af250..04a7656b7 100644
--- a/camel/models/model_manager.py
+++ b/camel/models/model_manager.py
@@ -117,6 +117,15 @@ class ModelManager:
"""
return self.models.index(self.current_model)
+ @property
+ def num_models(self) -> int:
+ r"""Return the number of models in the manager.
+
+ Returns:
+ int: The number of models available in the model manager.
+ """
+ return len(self.models)
+
@property
def token_limit(self):
r"""Returns the maximum token limit for current model.