🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: model token_limit and gemini dependency (#719)
Wendong-Fane38125d6c742
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.ymlindex f270778e7..946cc4ab7 100644--- a/.github/ISSUE_TEMPLATE/bug_report.yml+++ b/.github/ISSUE_TEMPLATE/bug_report.yml@@ -27,7 +27,7 @@ body:attributes:label: What version of camel are you using?description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.- placeholder: E.g., 0.1.5.6+ placeholder: E.g., 0.1.5.7validations:required: truediff --git a/README.md b/README.mdindex 4a36e3766..e5eda0a71 100644--- a/README.md+++ b/README.md@@ -110,7 +110,7 @@ conda create --name camel python=3.9conda activate camel# Clone github repo-git clone -b v0.1.5.6 https://github.com/camel-ai/camel.git+git clone -b v0.1.5.7 https://github.com/camel-ai/camel.git# Change directory into project directorycd cameldiff --git a/camel/__init__.py b/camel/__init__.pyindex ea2b8ceea..9b54c10e6 100644--- a/camel/__init__.py+++ b/camel/__init__.py@@ -12,7 +12,7 @@# limitations under the License.# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========-__version__ = '0.1.5.6'+__version__ = '0.1.5.7'__all__ = ['__version__',diff --git a/camel/configs/gemini_config.py b/camel/configs/gemini_config.pyindex 8e5c39939..757905a6f 100644--- a/camel/configs/gemini_config.py+++ b/camel/configs/gemini_config.py@@ -15,10 +15,19 @@from collections.abc import Iterablefrom dataclasses import asdict, dataclass-from typing import Optional+from typing import TYPE_CHECKING, Optionalfrom camel.configs.base_config import BaseConfig+if TYPE_CHECKING:+ from google.generativeai.protos import Schema+ from google.generativeai.types.content_types import (+ FunctionLibraryType,+ ToolConfigType,+ )+ from google.generativeai.types.helper_types import RequestOptionsType+ from google.generativeai.types.safety_types import SafetySettingOptions+@dataclass(frozen=True)class GeminiConfig(BaseConfig):@@ -72,14 +81,6 @@ class GeminiConfig(BaseConfig):Options for the request."""- from google.generativeai.protos import Schema- from google.generativeai.types.content_types import (- FunctionLibraryType,- ToolConfigType,- )- from google.generativeai.types.helper_types import RequestOptionsType- from google.generativeai.types.safety_types import SafetySettingOptions-candidate_count: Optional[int] = Nonestop_sequences: Optional[Iterable[str]] = Nonemax_output_tokens: Optional[int] = None@@ -87,11 +88,11 @@ class GeminiConfig(BaseConfig):top_p: Optional[float] = Nonetop_k: Optional[int] = Noneresponse_mime_type: Optional[str] = None- response_schema: Optional[Schema] = None- safety_settings: Optional[SafetySettingOptions] = None- tools: Optional[FunctionLibraryType] = None- tool_config: Optional[ToolConfigType] = None- request_options: Optional[RequestOptionsType] = None+ response_schema: Optional['Schema'] = None+ safety_settings: Optional['SafetySettingOptions'] = None+ tools: Optional['FunctionLibraryType'] = None+ tool_config: Optional['ToolConfigType'] = None+ request_options: Optional['RequestOptionsType'] = NoneGemini_API_PARAMS = {param for param in asdict(GeminiConfig()).keys()}diff --git a/camel/models/base_model.py b/camel/models/base_model.pyindex 9937f07ba..7df7c0ce3 100644--- a/camel/models/base_model.py+++ b/camel/models/base_model.py@@ -109,7 +109,10 @@ class BaseModelBackend(ABC):Returns:int: The maximum token limit for the given model."""- return self.model_type.token_limit+ return (+ self.model_config_dict.get("max_tokens")+ or self.model_type.token_limit+ )@propertydef stream(self) -> bool:diff --git a/camel/models/litellm_model.py b/camel/models/litellm_model.pyindex 83b0b77a4..a8e7e0d3e 100644--- a/camel/models/litellm_model.py+++ b/camel/models/litellm_model.py@@ -138,3 +138,19 @@ class LiteLLMModel:f"Unexpected argument `{param}` is ""input into LiteLLM model backend.")++ @property+ def token_limit(self) -> int:+ """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 4096diff --git a/camel/models/ollama_model.py b/camel/models/ollama_model.pyindex a7de1fd0d..4afe6c0d3 100644--- a/camel/models/ollama_model.py+++ b/camel/models/ollama_model.py@@ -104,6 +104,22 @@ class OllamaModel:)return response+ @property+ def token_limit(self) -> int:+ """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+@propertydef stream(self) -> bool:r"""Returns whether the model is in stream mode, which sends partialdiff --git a/camel/models/zhipuai_model.py b/camel/models/zhipuai_model.pyindex 32d402d5a..62025ea92 100644--- a/camel/models/zhipuai_model.py+++ b/camel/models/zhipuai_model.py@@ -118,7 +118,6 @@ class ZhipuAIModel(BaseModelBackend):f"Unexpected argument `{param}` is ""input into ZhipuAI model backend.")- pass@propertydef stream(self) -> bool:diff --git a/docs/conf.py b/docs/conf.pyindex 3e186e48c..ae648c3dc 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))project = 'CAMEL'copyright = '2023, CAMEL-AI.org'author = 'CAMEL-AI.org'-release = '0.1.5.6'+release = '0.1.5.7'html_favicon = ('https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'diff --git a/docs/get_started/setup.md b/docs/get_started/setup.mdindex 5aeea5598..7256c50fe 100644--- a/docs/get_started/setup.md+++ b/docs/get_started/setup.md@@ -61,7 +61,7 @@ conda create --name camel python=3.10conda activate camel# Clone github repo-git clone -b v0.1.5.6 https://github.com/camel-ai/camel.git+git clone -b v0.1.5.7 https://github.com/camel-ai/camel.git# Change directory into project directorycd cameldiff --git a/pyproject.toml b/pyproject.tomlindex c198e8cb1..8b3ce8855 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"[tool.poetry]name = "camel-ai"-version = "0.1.5.6"+version = "0.1.5.7"authors = ["CAMEL-AI.org"]description = "Communicative Agents for AI Society Study"readme = "README.md"