Skip to content

Commit

Permalink
Merge branch 'master' into issue-1717
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendong-Fan authored Mar 5, 2025
2 parents f5b3632 + b643501 commit 5cd53ac
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions camel/agents/chat_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,18 @@ def _get_model_response(
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}, "
Expand Down Expand Up @@ -732,11 +739,18 @@ async def _aget_model_response(
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}, "
Expand Down
9 changes: 9 additions & 0 deletions camel/models/model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ def current_model_index(self) -> int:
"""
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.
Expand Down

0 comments on commit 5cd53ac

Please sign in to comment.