🐫 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
feat: Add a new llm provider - novita (#2284)
Neal Davis103a34cf7089
diff --git a/.github/workflows/build_package.yml b/.github/workflows/build_package.ymlindex 5e0c57a1b..fc084a1f5 100644--- a/.github/workflows/build_package.yml+++ b/.github/workflows/build_package.yml@@ -107,6 +107,7 @@ jobs:BEDROCK_API_KEY: "${{ secrets.BEDROCK_API_KEY }}"BEDROCK_API_BASE_URL: "${{ secrets.BEDROCK_API_BASE_URL }}"NETMIND_API_KEY: "${{ secrets.NETMIND_API_KEY }}"+ NOVITA_API_KEY: "${{ secrets.NOVITA_API_KEY }}"run: |source test_venv/bin/activatepytest --fast-test-mode ./testdiff --git a/.github/workflows/pytest_package.yml b/.github/workflows/pytest_package.ymlindex f872c4d0d..bd64419c7 100644--- a/.github/workflows/pytest_package.yml+++ b/.github/workflows/pytest_package.yml@@ -72,6 +72,7 @@ jobs:BEDROCK_API_KEY: "${{ secrets.BEDROCK_API_KEY }}"BEDROCK_API_BASE_URL: "${{ secrets.BEDROCK_API_BASE_URL }}"NETMIND_API_KEY: "${{ secrets.NETMIND_API_KEY }}"+ NOVITA_API_KEY: "${{ secrets.NOVITA_API_KEY }}"run: |source .venv/bin/activateuv pip install -e ".[all, dev, docs]"@@ -136,6 +137,7 @@ jobs:BEDROCK_API_KEY: "${{ secrets.BEDROCK_API_KEY }}"BEDROCK_API_BASE_URL: "${{ secrets.BEDROCK_API_BASE_URL }}"NETMIND_API_KEY: "${{ secrets.NETMIND_API_KEY }}"+ NOVITA_API_KEY: "${{ secrets.NOVITA_API_KEY }}"run: |source .venv/bin/activateuv pip install -e ".[all, dev, docs]"@@ -198,6 +200,7 @@ jobs:BEDROCK_API_KEY: "${{ secrets.BEDROCK_API_KEY }}"BEDROCK_API_BASE_URL: "${{ secrets.BEDROCK_API_BASE_URL }}"NETMIND_API_KEY: "${{ secrets.NETMIND_API_KEY }}"+ NOVITA_API_KEY: "${{ secrets.NOVITA_API_KEY }}"run: |source .venv/bin/activateuv pip install -e ".[all, dev, docs]"diff --git a/camel/configs/__init__.py b/camel/configs/__init__.pyindex 45fd107a2..55225172b 100644--- a/camel/configs/__init__.py+++ b/camel/configs/__init__.py@@ -26,6 +26,7 @@ from .mistral_config import MISTRAL_API_PARAMS, MistralConfigfrom .modelscope_config import MODELSCOPE_API_PARAMS, ModelScopeConfigfrom .moonshot_config import MOONSHOT_API_PARAMS, MoonshotConfigfrom .netmind_config import NETMIND_API_PARAMS, NetmindConfig+from .novita_config import NOVITA_API_PARAMS, NovitaConfigfrom .nvidia_config import NVIDIA_API_PARAMS, NvidiaConfigfrom .ollama_config import OLLAMA_API_PARAMS, OllamaConfigfrom .openai_config import OPENAI_API_PARAMS, ChatGPTConfig@@ -98,6 +99,8 @@ __all__ = ["MOONSHOT_API_PARAMS",'ModelScopeConfig','MODELSCOPE_API_PARAMS',+ 'NovitaConfig',+ 'NOVITA_API_PARAMS','SiliconFlowConfig','SILICONFLOW_API_PARAMS','AIMLConfig',diff --git a/camel/configs/novita_config.py b/camel/configs/novita_config.pynew file mode 100644index 000000000..a55d8e2f9--- /dev/null+++ b/camel/configs/novita_config.py@@ -0,0 +1,102 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+from __future__ import annotations++from typing import Dict, Optional, Sequence, Type, Union++from pydantic import BaseModel++from camel.configs.base_config import BaseConfig+++class NovitaConfig(BaseConfig):+ r"""Defines the parameters for generating chat completions using the+ OpenAI API.++ Args:+ temperature (float, optional): Sampling temperature to use, between+ :obj:`0` and :obj:`2`. Higher values make the output more random,+ while lower values make it more focused and deterministic.+ (default: :obj:`None`)+ top_p (float, optional): An alternative to sampling with temperature,+ called nucleus sampling, where the model considers the results of+ the tokens with top_p probability mass. So :obj:`0.1` means only+ the tokens comprising the top 10% probability mass are considered.+ (default: :obj:`None`)+ n (int, optional): How many chat completion choices to generate for+ each input message. (default: :obj:`None`)+ response_format (object, optional): An object specifying the format+ that the model must output. Compatible with GPT-4 Turbo and all+ GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. Setting to+ {"type": "json_object"} enables JSON mode, which guarantees the+ message the model generates is valid JSON. Important: when using+ JSON mode, you must also instruct the model to produce JSON+ yourself via a system or user message. Without this, the model+ may generate an unending stream of whitespace until the generation+ reaches the token limit, resulting in a long-running and seemingly+ "stuck" request. Also note that the message content may be+ partially cut off if finish_reason="length", which indicates the+ generation exceeded max_tokens or the conversation exceeded the+ max context length.+ stream (bool, optional): If True, partial message deltas will be sent+ as data-only server-sent events as they become available.+ (default: :obj:`None`)+ stop (str or list, optional): Up to :obj:`4` sequences where the API+ will stop generating further tokens. (default: :obj:`None`)+ max_tokens (int, optional): The maximum number of tokens to generate+ in the chat completion. The total length of input tokens and+ generated tokens is limited by the model's context length.+ (default: :obj:`None`)+ presence_penalty (float, optional): Number between :obj:`-2.0` and+ :obj:`2.0`. Positive values penalize new tokens based on whether+ they appear in the text so far, increasing the model's likelihood+ to talk about new topics. See more information about frequency and+ presence penalties. (default: :obj:`None`)+ frequency_penalty (float, optional): Number between :obj:`-2.0` and+ :obj:`2.0`. Positive values penalize new tokens based on their+ existing frequency in the text so far, decreasing the model's+ likelihood to repeat the same line verbatim. See more information+ about frequency and presence penalties. (default: :obj:`None`)+ logit_bias (dict, optional): Modify the likelihood of specified tokens+ appearing in the completion. Accepts a json object that maps tokens+ (specified by their token ID in the tokenizer) to an associated+ bias value from :obj:`-100` to :obj:`100`. Mathematically, the bias+ is added to the logits generated by the model prior to sampling.+ The exact effect will vary per model, but values between:obj:` -1`+ and :obj:`1` should decrease or increase likelihood of selection;+ values like :obj:`-100` or :obj:`100` should result in a ban or+ exclusive selection of the relevant token. (default: :obj:`None`)+ user (str, optional): A unique identifier representing your end-user,+ which can help OpenAI to monitor and detect abuse.+ (default: :obj:`None`)+ tools (list[FunctionTool], optional): A list of tools the model may+ call. Currently, only functions are supported as a tool. Use this+ to provide a list of functions the model may generate JSON inputs+ for. A max of 128 functions are supported.+ """++ temperature: Optional[float] = None+ top_p: Optional[float] = None+ n: Optional[int] = None+ stream: Optional[bool] = None+ stop: Optional[Union[str, Sequence[str]]] = None+ max_tokens: Optional[int] = None+ presence_penalty: Optional[float] = None+ response_format: Optional[Union[Type[BaseModel], Dict]] = None+ frequency_penalty: Optional[float] = None+ logit_bias: Optional[Dict] = None+ user: Optional[str] = None+++NOVITA_API_PARAMS = {param for param in NovitaConfig.model_fields.keys()}diff --git a/camel/models/__init__.py b/camel/models/__init__.pyindex 6e3a2b1bb..443ee3e52 100644--- a/camel/models/__init__.py+++ b/camel/models/__init__.py@@ -32,6 +32,7 @@ from .modelscope_model import ModelScopeModelfrom .moonshot_model import MoonshotModelfrom .nemotron_model import NemotronModelfrom .netmind_model import NetmindModel+from .novita_model import NovitaModelfrom .nvidia_model import NvidiaModelfrom .ollama_model import OllamaModelfrom .openai_audio_models import OpenAIAudioModels@@ -68,6 +69,7 @@ __all__ = ['OpenAIAudioModels','NetmindModel','NemotronModel',+ 'NovitaModel','NvidiaModel','OllamaModel','VLLMModel',diff --git a/camel/models/model_factory.py b/camel/models/model_factory.pyindex fac2836d3..342e9a9ec 100644--- a/camel/models/model_factory.py+++ b/camel/models/model_factory.py@@ -32,6 +32,7 @@ from camel.models.mistral_model import MistralModelfrom camel.models.modelscope_model import ModelScopeModelfrom camel.models.moonshot_model import MoonshotModelfrom camel.models.netmind_model import NetmindModel+from camel.models.novita_model import NovitaModelfrom camel.models.nvidia_model import NvidiaModelfrom camel.models.ollama_model import OllamaModelfrom camel.models.openai_compatible_model import OpenAICompatibleModel@@ -163,6 +164,8 @@ class ModelFactory:model_class = MoonshotModelelif model_platform.is_modelscope:model_class = ModelScopeModel+ elif model_platform.is_novita:+ model_class = NovitaModelelif model_type == ModelType.STUB:model_class = StubModeldiff --git a/camel/models/novita_model.py b/camel/models/novita_model.pynew file mode 100644index 000000000..17099373b--- /dev/null+++ b/camel/models/novita_model.py@@ -0,0 +1,95 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++import os+from typing import Any, Dict, Optional, Union++from camel.configs import NOVITA_API_PARAMS, NovitaConfig+from camel.models.openai_compatible_model import OpenAICompatibleModel+from camel.types import ModelType+from camel.utils import (+ BaseTokenCounter,+ api_keys_required,+)+++class NovitaModel(OpenAICompatibleModel):+ r"""Constructor for Novita backend with OpenAI compatibility.++ Args:+ model_type (Union[ModelType, str]): Model for which a backend is+ created, supported model can be found here:+ https://novita.ai/models?utm_source=github_owl&utm_campaign=github_link+ model_config_dict (Optional[Dict[str, Any]], optional): A dictionary+ that will be fed into:obj:`openai.ChatCompletion.create()`. If+ :obj:`None`, :obj:`NovitaConfig().as_dict()` will be used.+ (default: :obj:`None`)+ api_key (Optional[str], optional): The API key for authenticating with+ the Novita service. (default: :obj:`None`)+ url (Optional[str], optional): The url to the Novita service.+ If not provided, "https://api.novita.ai/v3/openai" will be used.+ (default: :obj:`None`)+ token_counter (Optional[BaseTokenCounter], optional): Token counter to+ use for the model. If not provided, :obj:`OpenAITokenCounter(+ ModelType.GPT_4O_MINI)` will be used.+ timeout (Optional[float], optional): The timeout value in seconds for+ API calls. If not provided, will fall back to the MODEL_TIMEOUT+ environment variable or default to 180 seconds.+ (default: :obj:`None`)+ """++ @api_keys_required(+ [+ ("api_key", 'NOVITA_API_KEY'),+ ]+ )+ def __init__(+ self,+ model_type: Union[ModelType, str],+ model_config_dict: Optional[Dict[str, Any]] = None,+ api_key: Optional[str] = None,+ url: Optional[str] = None,+ token_counter: Optional[BaseTokenCounter] = None,+ timeout: Optional[float] = None,+ ) -> None:+ if model_config_dict is None:+ model_config_dict = NovitaConfig().as_dict()+ api_key = api_key or os.environ.get("NOVITA_API_KEY")+ url = url or os.environ.get(+ "NOVITA_API_BASE_URL", "https://api.novita.ai/v3/openai"+ )+ timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))+ super().__init__(+ model_type=model_type,+ model_config_dict=model_config_dict,+ api_key=api_key,+ url=url,+ token_counter=token_counter,+ timeout=timeout,+ )++ def check_model_config(self):+ r"""Check whether the model configuration contains any+ unexpected arguments to Novita API.++ Raises:+ ValueError: If the model configuration dictionary contains any+ unexpected arguments to Novita API.+ """+ for param in self.model_config_dict:+ if param not in NOVITA_API_PARAMS:+ raise ValueError(+ f"Unexpected argument `{param}` is "+ "input into Novita model backend."+ )diff --git a/camel/types/enums.py b/camel/types/enums.pyindex f36754d5b..0389db1e3 100644--- a/camel/types/enums.py+++ b/camel/types/enums.py@@ -270,6 +270,63 @@ class ModelType(UnifiedModelType, Enum):AIML_MIXTRAL_8X7B = "mistralai/Mixtral-8x7B-Instruct-v0.1"AIML_MISTRAL_7B_INSTRUCT = "mistralai/Mistral-7B-Instruct-v0.1"+ # Novita platform models support tool calling+ NOVITA_LLAMA_4_MAVERICK_17B = (+ "meta-llama/llama-4-maverick-17b-128e-instruct-fp8"+ )+ NOVITA_LLAMA_4_SCOUT_17B = "meta-llama/llama-4-scout-17b-16e-instruct"+ NOVITA_DEEPSEEK_V3_0324 = ("deepseek/deepseek-v3-0324",)+ NOVITA_QWEN_2_5_V1_72B = ("qwen/qwen2.5-vl-72b-instruct",)+ NOVITA_DEEPSEEK_V3_TURBO = ("deepseek/deepseek-v3-turbo",)+ NOVITA_DEEPSEEK_R1_TURBO = ("deepseek/deepseek-r1-turbo",)+ NOVITA_GEMMA_3_27B_IT = ("google/gemma-3-27b-it",)+ NOVITA_QWEN_32B = ("qwen/qwq-32b",)+ NOVITA_L3_8B_STHENO_V3_2 = ("Sao10K/L3-8B-Stheno-v3.2",)+ NOVITA_MYTHOMAX_L2_13B = ("gryphe/mythomax-l2-13b",)+ NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_8B = (+ "deepseek/deepseek-r1-distill-llama-8b",+ )+ NOVITA_DEEPSEEK_V3 = ("deepseek/deepseek_v3",)+ NOVITA_LLAMA_3_1_8B = ("meta-llama/llama-3.1-8b-instruct",)+ NOVITA_DEEPSEEK_R1_DISTILL_QWEN_14B = (+ "deepseek/deepseek-r1-distill-qwen-14b",+ )+ NOVITA_LLAMA_3_3_70B = ("meta-llama/llama-3.3-70b-instruct",)+ NOVITA_QWEN_2_5_72B = ("qwen/qwen-2.5-72b-instruct",)+ NOVITA_MISTRAL_NEMO = ("mistralai/mistral-nemo",)+ NOVITA_DEEPSEEK_R1_DISTILL_QWEN_32B = (+ "deepseek/deepseek-r1-distill-qwen-32b",+ )+ NOVITA_LLAMA_3_8B = ("meta-llama/llama-3-8b-instruct",)+ NOVITA_WIZARDLM_2_8X22B = ("microsoft/wizardlm-2-8x22b",)+ NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_70B = (+ "deepseek/deepseek-r1-distill-llama-70b",+ )+ NOVITA_LLAMA_3_1_70B = ("meta-llama/llama-3.1-70b-instruct",)+ NOVITA_GEMMA_2_9B_IT = ("google/gemma-2-9b-it",)+ NOVITA_MISTRAL_7B = ("mistralai/mistral-7b-instruct",)+ NOVITA_LLAMA_3_70B = ("meta-llama/llama-3-70b-instruct",)+ NOVITA_DEEPSEEK_R1 = ("deepseek/deepseek-r1",)+ NOVITA_HERMES_2_PRO_LLAMA_3_8B = ("nousresearch/hermes-2-pro-llama-3-8b",)+ NOVITA_L3_70B_EURYALE_V2_1 = ("sao10k/l3-70b-euryale-v2.1",)+ NOVITA_DOLPHIN_MIXTRAL_8X22B = (+ "cognitivecomputations/dolphin-mixtral-8x22b",+ )+ NOVITA_AIROBOROS_L2_70B = ("jondurbin/airoboros-l2-70b",)+ NOVITA_MIDNIGHT_ROSE_70B = ("sophosympatheia/midnight-rose-70b",)+ NOVITA_L3_8B_LUNARIS = ("sao10k/l3-8b-lunaris",)+ NOVITA_GLM_4_9B_0414 = ("thudm/glm-4-9b-0414",)+ NOVITA_GLM_Z1_9B_0414 = ("thudm/glm-z1-9b-0414",)+ NOVITA_GLM_Z1_32B_0414 = ("thudm/glm-z1-32b-0414",)+ NOVITA_GLM_4_32B_0414 = ("thudm/glm-4-32b-0414",)+ NOVITA_GLM_Z1_RUMINATION_32B_0414 = ("thudm/glm-z1-rumination-32b-0414",)+ NOVITA_QWEN_2_5_7B = ("qwen/qwen2.5-7b-instruct",)+ NOVITA_LLAMA_3_2_1B = ("meta-llama/llama-3.2-1b-instruct",)+ NOVITA_LLAMA_3_2_11B_VISION = ("meta-llama/llama-3.2-11b-vision-instruct",)+ NOVITA_LLAMA_3_2_3B = ("meta-llama/llama-3.2-3b-instruct",)+ NOVITA_LLAMA_3_1_8B_BF16 = ("meta-llama/llama-3.1-8b-instruct-bf16",)+ NOVITA_L31_70B_EURYALE_V2_2 = ("sao10k/l31-70b-euryale-v2.2",)+# ModelScope models support tool callingMODELSCOPE_QWEN_2_5_7B_INSTRUCT = "Qwen/Qwen2.5-7B-Instruct"MODELSCOPE_QWEN_2_5_14B_INSTRUCT = "Qwen/Qwen2.5-14B-Instruct"@@ -345,6 +402,7 @@ class ModelType(UnifiedModelType, Enum):self.is_zhipuai,self.is_aiml,self.is_azure_openai,+ self.is_novita,])@@ -713,6 +771,54 @@ class ModelType(UnifiedModelType, Enum):ModelType.SILICONFLOW_PRO_THUDM_GLM_4_9B_CHAT,}+ @property+ def is_novita(self) -> bool:+ return self in {+ ModelType.NOVITA_LLAMA_4_MAVERICK_17B,+ ModelType.NOVITA_LLAMA_4_SCOUT_17B,+ ModelType.NOVITA_DEEPSEEK_V3_0324,+ ModelType.NOVITA_QWEN_2_5_V1_72B,+ ModelType.NOVITA_DEEPSEEK_V3_TURBO,+ ModelType.NOVITA_DEEPSEEK_R1_TURBO,+ ModelType.NOVITA_GEMMA_3_27B_IT,+ ModelType.NOVITA_QWEN_32B,+ ModelType.NOVITA_L3_8B_STHENO_V3_2,+ ModelType.NOVITA_MYTHOMAX_L2_13B,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_8B,+ ModelType.NOVITA_DEEPSEEK_V3,+ ModelType.NOVITA_LLAMA_3_1_8B,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_QWEN_14B,+ ModelType.NOVITA_LLAMA_3_3_70B,+ ModelType.NOVITA_QWEN_2_5_72B,+ ModelType.NOVITA_MISTRAL_NEMO,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_QWEN_32B,+ ModelType.NOVITA_LLAMA_3_8B,+ ModelType.NOVITA_WIZARDLM_2_8X22B,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_70B,+ ModelType.NOVITA_LLAMA_3_1_70B,+ ModelType.NOVITA_GEMMA_2_9B_IT,+ ModelType.NOVITA_MISTRAL_7B,+ ModelType.NOVITA_LLAMA_3_70B,+ ModelType.NOVITA_DEEPSEEK_R1,+ ModelType.NOVITA_HERMES_2_PRO_LLAMA_3_8B,+ ModelType.NOVITA_L3_70B_EURYALE_V2_1,+ ModelType.NOVITA_DOLPHIN_MIXTRAL_8X22B,+ ModelType.NOVITA_AIROBOROS_L2_70B,+ ModelType.NOVITA_MIDNIGHT_ROSE_70B,+ ModelType.NOVITA_L3_8B_LUNARIS,+ ModelType.NOVITA_GLM_4_9B_0414,+ ModelType.NOVITA_GLM_Z1_9B_0414,+ ModelType.NOVITA_GLM_Z1_32B_0414,+ ModelType.NOVITA_GLM_4_32B_0414,+ ModelType.NOVITA_GLM_Z1_RUMINATION_32B_0414,+ ModelType.NOVITA_QWEN_2_5_7B,+ ModelType.NOVITA_LLAMA_3_2_1B,+ ModelType.NOVITA_LLAMA_3_2_11B_VISION,+ ModelType.NOVITA_LLAMA_3_2_3B,+ ModelType.NOVITA_LLAMA_3_1_8B_BF16,+ ModelType.NOVITA_L31_70B_EURYALE_V2_2,+ }+@propertydef is_aiml(self) -> bool:return self in {@@ -740,6 +846,9 @@ class ModelType(UnifiedModelType, Enum):ModelType.COHERE_COMMAND_LIGHT,ModelType.NVIDIA_NEMOTRON_340B_INSTRUCT,ModelType.NVIDIA_NEMOTRON_340B_REWARD,+ ModelType.NOVITA_MYTHOMAX_L2_13B,+ ModelType.NOVITA_AIROBOROS_L2_70B,+ ModelType.NOVITA_MIDNIGHT_ROSE_70B,}:return 4_096elif self in {@@ -761,12 +870,25 @@ class ModelType(UnifiedModelType, Enum):ModelType.LMSTUDIO_GEMMA_3_4B,ModelType.LMSTUDIO_GEMMA_3_12B,ModelType.LMSTUDIO_GEMMA_3_27B,+ ModelType.NOVITA_L3_8B_STHENO_V3_2,+ ModelType.NOVITA_LLAMA_3_8B,+ ModelType.NOVITA_GEMMA_2_9B_IT,+ ModelType.NOVITA_LLAMA_3_70B,+ ModelType.NOVITA_HERMES_2_PRO_LLAMA_3_8B,+ ModelType.NOVITA_L3_70B_EURYALE_V2_1,+ ModelType.NOVITA_L3_8B_LUNARIS,+ ModelType.NOVITA_LLAMA_3_1_8B_BF16,+ ModelType.NOVITA_L31_70B_EURYALE_V2_2,}:return 8_192elif self in {ModelType.PPIO_BAICHUAN_2_13B_CHAT,}:return 14_336+ elif self in {+ ModelType.NOVITA_DOLPHIN_MIXTRAL_8X22B,+ }:+ return 16_000elif self in {ModelType.GPT_3_5_TURBO,ModelType.YI_LIGHTNING,@@ -780,11 +902,21 @@ class ModelType(UnifiedModelType, Enum):ModelType.GLM_4V_PLUS_0111,ModelType.GLM_ZERO_PREVIEW,ModelType.PPIO_YI_1_5_34B_CHAT,+ ModelType.NOVITA_LLAMA_3_1_8B,}:return 16_384-elif self in {ModelType.NETMIND_DOUBAO_1_5_PRO,+ ModelType.NOVITA_GEMMA_3_27B_IT,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_8B,+ ModelType.NOVITA_QWEN_2_5_72B,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_LLAMA_70B,+ ModelType.NOVITA_GLM_4_9B_0414,+ ModelType.NOVITA_GLM_Z1_9B_0414,+ ModelType.NOVITA_GLM_Z1_32B_0414,+ ModelType.NOVITA_GLM_4_32B_0414,+ ModelType.NOVITA_GLM_Z1_RUMINATION_32B_0414,+ ModelType.NOVITA_QWEN_2_5_7B,}:return 32_000elif self in {@@ -829,6 +961,11 @@ class ModelType(UnifiedModelType, Enum):ModelType.MODELSCOPE_MINISTRAL_8B_INSTRUCT,ModelType.MODELSCOPE_DEEPSEEK_V3_0324,ModelType.OPENROUTER_LLAMA_3_1_405B,+ ModelType.NOVITA_QWEN_32B,+ ModelType.NOVITA_LLAMA_3_1_70B,+ ModelType.NOVITA_MISTRAL_7B,+ ModelType.NOVITA_LLAMA_3_2_11B_VISION,+ ModelType.NOVITA_LLAMA_3_2_3B,}:return 32_768elif self in {@@ -843,8 +980,22 @@ class ModelType(UnifiedModelType, Enum):ModelType.PPIO_DEEPSEEK_V3,ModelType.AWS_DEEPSEEK_R1,ModelType.NETMIND_QWQ_32B,+ ModelType.NOVITA_DEEPSEEK_V3_TURBO,+ ModelType.NOVITA_DEEPSEEK_R1_TURBO,+ ModelType.NOVITA_DEEPSEEK_V3,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_QWEN_14B,+ ModelType.NOVITA_DEEPSEEK_R1_DISTILL_QWEN_32B,+ ModelType.NOVITA_DEEPSEEK_R1,}:return 64_000+ elif self in {+ ModelType.NOVITA_WIZARDLM_2_8X22B,+ }:+ return 65_535+ elif self in {+ ModelType.NOVITA_QWEN_2_5_V1_72B,+ }:+ return 96_000elif self in {ModelType.CLAUDE_2_0,ModelType.CLAUDE_INSTANT_1_2,@@ -894,8 +1045,13 @@ class ModelType(UnifiedModelType, Enum):ModelType.AWS_LLAMA_3_2_11B_INSTRUCT,ModelType.NETMIND_DEEPSEEK_R1,ModelType.NETMIND_DEEPSEEK_V3,+ ModelType.NOVITA_DEEPSEEK_V3_0324,}:return 128_000+ elif self in {+ ModelType.NOVITA_LLAMA_3_2_1B,+ }:+ return 131_000elif self in {ModelType.GROQ_LLAMA_3_1_8B,ModelType.QWEN_PLUS,@@ -911,6 +1067,9 @@ class ModelType(UnifiedModelType, Enum):ModelType.OPENROUTER_LLAMA_3_1_70B,ModelType.PPIO_LLAMA_3_3_70B,ModelType.OPENROUTER_LLAMA_4_SCOUT,+ ModelType.NOVITA_LLAMA_4_SCOUT_17B,+ ModelType.NOVITA_LLAMA_3_3_70B,+ ModelType.NOVITA_MISTRAL_NEMO,}:return 131_072elif self in {@@ -961,6 +1120,7 @@ class ModelType(UnifiedModelType, Enum):ModelType.GPT_4_1,ModelType.GPT_4_1_MINI,ModelType.GPT_4_1_NANO,+ ModelType.NOVITA_LLAMA_4_MAVERICK_17B,}:return 1_048_576elif self in {@@ -1159,6 +1319,7 @@ class ModelPlatformType(Enum):AIML = "aiml"VOLCANO = "volcano"NETMIND = "netmind"+ NOVITA = "novita"@classmethoddef from_name(cls, name):@@ -1324,6 +1485,11 @@ class ModelPlatformType(Enum):r"""Returns whether this platform is volcano."""return self is ModelPlatformType.VOLCANO+ @property+ def is_novita(self) -> bool:+ r"""Returns whether this platform is Novita."""+ return self is ModelPlatformType.NOVITA+class AudioModelType(Enum):TTS_1 = "tts-1"diff --git a/camel/types/unified_model_type.py b/camel/types/unified_model_type.pyindex 180ad534d..ba50595d2 100644--- a/camel/types/unified_model_type.py+++ b/camel/types/unified_model_type.py@@ -153,6 +153,11 @@ class UnifiedModelType(str):r"""Returns whether this platform is Moonshot model."""return True+ @property+ def is_novita(self) -> bool:+ r"""Returns whether the model is a Novita served model."""+ return True+@propertydef support_native_structured_output(self) -> bool:r"""Returns whether the model supports native structured output."""diff --git a/docs/key_modules/models.md b/docs/key_modules/models.mdindex bd32c2aac..78b78d2a3 100644--- a/docs/key_modules/models.md+++ b/docs/key_modules/models.md@@ -36,6 +36,7 @@ CAMEL supports a wide range of models, including [OpenAI’s GPT series](https:/| **vLLM** | [supported models](https://docs.vllm.ai/en/latest/models/supported_models.html) || **SGLANG** | [supported models](https://sgl-project.github.io/references/supported_models.html) || **NetMind** | [supported models](https://www.netmind.ai/modelsLibrary) |+| **NOVITA** | [supported models](https://novita.ai/models?utm_source=github_owl&utm_medium=github_readme&utm_campaign=github_link) || **NVIDIA** | [supported models](https://docs.api.nvidia.com/nim/reference/llm-apis) || **AIML** | [supported models](https://docs.aimlapi.com/api-overview/model-database/text-models) || **ModelScope** | [supported models](https://www.modelscope.cn/docs/model-service/API-Inference/intro) |diff --git a/examples/models/novita_model_example.py b/examples/models/novita_model_example.pynew file mode 100644index 000000000..56eebe530--- /dev/null+++ b/examples/models/novita_model_example.py@@ -0,0 +1,52 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========++from camel.agents import ChatAgent+from camel.configs import NovitaConfig+from camel.models import ModelFactory+from camel.types import ModelPlatformType, ModelType++model = ModelFactory.create(+ model_platform=ModelPlatformType.NOVITA,+ model_type=ModelType.NOVITA_DEEPSEEK_R1_TURBO,+ model_config_dict=NovitaConfig(temperature=0.2).as_dict(),+)++# Define system message+sys_msg = "You are a helpful assistant."++# Set agent+camel_agent = ChatAgent(system_message=sys_msg, model=model)++user_msg = """Say hi to CAMEL AI, one open-source community+ dedicated to the study of autonomous and communicative agents."""++# Get response information+response = camel_agent.step(user_msg)+print(response.msgs[0].content)++'''+===============================================================================+Hi CAMEL AI! 👋 It's fantastic to see an open-source community dedicated to+advancing autonomous and communicative agents.++Your work in fostering collaboration and innovation is pivotal for the future+of AI, whether in robotics, NLP, or multi-agent systems. By making this+research accessible, you're empowering developers and researchers worldwide.+Keep pushing boundaries—your contributions are shaping a smarter, more+connected AI landscape!++Wishing you continued growth and breakthroughs! 🚀+===============================================================================+'''diff --git a/test/models/test_novita_model.py b/test/models/test_novita_model.pynew file mode 100644index 000000000..30adbc140--- /dev/null+++ b/test/models/test_novita_model.py@@ -0,0 +1,62 @@+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+# Licensed under the Apache License, Version 2.0 (the "License");+# you may not use this file except in compliance with the License.+# You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.+# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import re++import pytest++from camel.configs import NovitaConfig+from camel.models import NovitaModel+from camel.types import ModelType+from camel.utils import OpenAITokenCounter++[email protected]_backend+ "model_type",+ [+ ModelType.NOVITA_DEEPSEEK_R1,+ ModelType.NOVITA_LLAMA_3_1_70B,+ ModelType.NOVITA_QWEN_2_5_72B,+ ],+)+def test_novita_model(model_type: ModelType):+ model = NovitaModel(model_type)+ assert model.model_type == model_type+ assert model.model_config_dict == NovitaConfig().as_dict()+ assert isinstance(model.token_counter, OpenAITokenCounter)+ assert isinstance(model.model_type.value_for_tiktoken, str)+ assert isinstance(model.model_type.token_limit, int)++[email protected]_backend+def test_novita_model_unexpected_argument():+ model_type = ModelType.NOVITA_LLAMA_3_1_70B+ model_config_dict = {"model_path": "novita_llama_3_1_70B"}++ with pytest.raises(+ ValueError,+ match=re.escape(+ (+ "Unexpected argument `model_path` is "+ "input into Novita model backend."+ )+ ),+ ):+ _ = NovitaModel(model_type, model_config_dict)++[email protected]_backend+def test_novita_model_stream_property():+ model = NovitaModel(ModelType.NOVITA_LLAMA_3_1_70B)+ assert model.stream is False