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

fix: Add property for maximum token limit in OpenAICompatibilityModel (#832)

Lei Zhang85e63a9f0655
diff --git a/camel/models/openai_compatibility_model.py b/camel/models/openai_compatibility_model.py
index adadd24c1..d7ca16fe7 100644
--- a/camel/models/openai_compatibility_model.py
+++ b/camel/models/openai_compatibility_model.py
@@ -103,3 +103,19 @@ class OpenAICompatibilityModel:
bool: Whether the model is in stream mode.
"""
return self.model_config_dict.get('stream', False)
+
+ @property
+ def token_limit(self) -> int:
+ r"""Returns the maximum token limit for the given model.
+
+ Returns:
+ int: The maximum token limit for the given model.
+ """
+ max_tokens = self.model_config_dict.get("max_tokens")
+ if isinstance(max_tokens, int):
+ return max_tokens
+ print(
+ "Must set `max_tokens` as an integer in `model_config_dict` when"
+ " setting up the model. Using 4096 as default value."
+ )
+ return 4096