camel-ai 0.2.74a5__py3-none-any.whl → 0.2.75__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of camel-ai might be problematic. Click here for more details.

Files changed (80) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +149 -95
  3. camel/configs/__init__.py +3 -0
  4. camel/configs/nebius_config.py +103 -0
  5. camel/interpreters/e2b_interpreter.py +34 -1
  6. camel/models/__init__.py +2 -0
  7. camel/models/aiml_model.py +1 -16
  8. camel/models/anthropic_model.py +6 -22
  9. camel/models/aws_bedrock_model.py +1 -16
  10. camel/models/azure_openai_model.py +1 -16
  11. camel/models/base_model.py +0 -12
  12. camel/models/cohere_model.py +1 -16
  13. camel/models/crynux_model.py +1 -16
  14. camel/models/deepseek_model.py +1 -16
  15. camel/models/gemini_model.py +1 -16
  16. camel/models/groq_model.py +1 -17
  17. camel/models/internlm_model.py +1 -16
  18. camel/models/litellm_model.py +1 -16
  19. camel/models/lmstudio_model.py +1 -17
  20. camel/models/mistral_model.py +1 -16
  21. camel/models/model_factory.py +2 -0
  22. camel/models/modelscope_model.py +1 -16
  23. camel/models/moonshot_model.py +6 -22
  24. camel/models/nebius_model.py +83 -0
  25. camel/models/nemotron_model.py +0 -5
  26. camel/models/netmind_model.py +1 -16
  27. camel/models/novita_model.py +1 -16
  28. camel/models/nvidia_model.py +1 -16
  29. camel/models/ollama_model.py +4 -19
  30. camel/models/openai_compatible_model.py +0 -3
  31. camel/models/openai_model.py +1 -22
  32. camel/models/openrouter_model.py +1 -17
  33. camel/models/ppio_model.py +1 -16
  34. camel/models/qianfan_model.py +1 -16
  35. camel/models/qwen_model.py +1 -16
  36. camel/models/reka_model.py +1 -16
  37. camel/models/samba_model.py +0 -32
  38. camel/models/sglang_model.py +1 -16
  39. camel/models/siliconflow_model.py +1 -16
  40. camel/models/stub_model.py +0 -4
  41. camel/models/togetherai_model.py +1 -16
  42. camel/models/vllm_model.py +1 -16
  43. camel/models/volcano_model.py +0 -17
  44. camel/models/watsonx_model.py +1 -16
  45. camel/models/yi_model.py +1 -16
  46. camel/models/zhipuai_model.py +1 -16
  47. camel/societies/workforce/prompts.py +1 -8
  48. camel/societies/workforce/task_channel.py +120 -27
  49. camel/societies/workforce/workforce.py +35 -3
  50. camel/toolkits/__init__.py +0 -2
  51. camel/toolkits/github_toolkit.py +104 -17
  52. camel/toolkits/hybrid_browser_toolkit/config_loader.py +3 -0
  53. camel/toolkits/hybrid_browser_toolkit/hybrid_browser_toolkit_ts.py +260 -5
  54. camel/toolkits/hybrid_browser_toolkit/ts/src/browser-session.ts +288 -37
  55. camel/toolkits/hybrid_browser_toolkit/ts/src/config-loader.ts +3 -1
  56. camel/toolkits/hybrid_browser_toolkit/ts/src/hybrid-browser-toolkit.ts +209 -41
  57. camel/toolkits/hybrid_browser_toolkit/ts/src/types.ts +22 -3
  58. camel/toolkits/hybrid_browser_toolkit/ts/websocket-server.js +28 -1
  59. camel/toolkits/hybrid_browser_toolkit/ws_wrapper.py +101 -0
  60. camel/toolkits/hybrid_browser_toolkit_py/actions.py +158 -0
  61. camel/toolkits/hybrid_browser_toolkit_py/browser_session.py +55 -8
  62. camel/toolkits/hybrid_browser_toolkit_py/config_loader.py +43 -0
  63. camel/toolkits/hybrid_browser_toolkit_py/hybrid_browser_toolkit.py +312 -3
  64. camel/toolkits/hybrid_browser_toolkit_py/snapshot.py +10 -4
  65. camel/toolkits/hybrid_browser_toolkit_py/unified_analyzer.js +45 -4
  66. camel/toolkits/math_toolkit.py +64 -10
  67. camel/toolkits/mcp_toolkit.py +39 -14
  68. camel/toolkits/openai_image_toolkit.py +55 -24
  69. camel/toolkits/search_toolkit.py +153 -29
  70. camel/types/__init__.py +2 -2
  71. camel/types/enums.py +54 -10
  72. camel/types/openai_types.py +2 -2
  73. camel/types/unified_model_type.py +5 -0
  74. camel/utils/mcp.py +2 -2
  75. camel/utils/token_counting.py +18 -3
  76. {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75.dist-info}/METADATA +9 -15
  77. {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75.dist-info}/RECORD +79 -78
  78. camel/toolkits/openai_agent_toolkit.py +0 -135
  79. {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75.dist-info}/WHEEL +0 -0
  80. {camel_ai-0.2.74a5.dist-info → camel_ai-0.2.75.dist-info}/licenses/LICENSE +0 -0
@@ -22,7 +22,7 @@ from openai.lib.streaming.chat import (
22
22
  )
23
23
  from pydantic import BaseModel
24
24
 
25
- from camel.configs import OPENAI_API_PARAMS, ChatGPTConfig
25
+ from camel.configs import ChatGPTConfig
26
26
  from camel.messages import OpenAIMessage
27
27
  from camel.models.base_model import BaseModelBackend
28
28
  from camel.types import (
@@ -452,21 +452,6 @@ class AzureOpenAIModel(BaseModelBackend):
452
452
  **request_config,
453
453
  )
454
454
 
455
- def check_model_config(self):
456
- r"""Check whether the model configuration contains any
457
- unexpected arguments to Azure OpenAI API.
458
-
459
- Raises:
460
- ValueError: If the model configuration dictionary contains any
461
- unexpected arguments to Azure OpenAI API.
462
- """
463
- for param in self.model_config_dict:
464
- if param not in OPENAI_API_PARAMS:
465
- raise ValueError(
466
- f"Unexpected argument `{param}` is "
467
- "input into Azure OpenAI model backend."
468
- )
469
-
470
455
  @property
471
456
  def stream(self) -> bool:
472
457
  r"""Returns whether the model is in stream mode,
@@ -105,7 +105,6 @@ class BaseModelBackend(ABC, metaclass=ModelBackendMeta):
105
105
  == "true"
106
106
  )
107
107
  self._log_dir = os.environ.get("CAMEL_LOG_DIR", "camel_logs")
108
- self.check_model_config()
109
108
 
110
109
  @property
111
110
  @abstractmethod
@@ -457,17 +456,6 @@ class BaseModelBackend(ABC, metaclass=ModelBackendMeta):
457
456
 
458
457
  return result
459
458
 
460
- @abstractmethod
461
- def check_model_config(self):
462
- r"""Check whether the input model configuration contains unexpected
463
- arguments
464
-
465
- Raises:
466
- ValueError: If the model configuration dictionary contains any
467
- unexpected argument for this model class.
468
- """
469
- pass
470
-
471
459
  def count_tokens_from_messages(self, messages: List[OpenAIMessage]) -> int:
472
460
  r"""Count the number of tokens in the messages using the specific
473
461
  tokenizer.
@@ -26,7 +26,7 @@ if TYPE_CHECKING:
26
26
  ChatResponse,
27
27
  )
28
28
 
29
- from camel.configs import COHERE_API_PARAMS, CohereConfig
29
+ from camel.configs import CohereConfig
30
30
  from camel.messages import OpenAIMessage
31
31
  from camel.models import BaseModelBackend
32
32
  from camel.models._utils import try_modify_message_with_format
@@ -454,21 +454,6 @@ class CohereModel(BaseModelBackend):
454
454
 
455
455
  return openai_response
456
456
 
457
- def check_model_config(self):
458
- r"""Check whether the model configuration contains any unexpected
459
- arguments to Cohere API.
460
-
461
- Raises:
462
- ValueError: If the model configuration dictionary contains any
463
- unexpected arguments to Cohere API.
464
- """
465
- for param in self.model_config_dict:
466
- if param not in COHERE_API_PARAMS:
467
- raise ValueError(
468
- f"Unexpected argument `{param}` is "
469
- "input into Cohere model backend."
470
- )
471
-
472
457
  @property
473
458
  def stream(self) -> bool:
474
459
  r"""Returns whether the model is in stream mode, which sends partial
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  from typing import Any, Dict, Optional, Union
17
17
 
18
- from camel.configs import CRYNUX_API_PARAMS, CrynuxConfig
18
+ from camel.configs import CrynuxConfig
19
19
  from camel.models.openai_compatible_model import OpenAICompatibleModel
20
20
  from camel.types import ModelType
21
21
  from camel.utils import (
@@ -85,18 +85,3 @@ class CrynuxModel(OpenAICompatibleModel):
85
85
  max_retries=max_retries,
86
86
  **kwargs,
87
87
  )
88
-
89
- def check_model_config(self):
90
- r"""Check whether the model configuration contains any
91
- unexpected arguments to Crynux API.
92
-
93
- Raises:
94
- ValueError: If the model configuration dictionary contains any
95
- unexpected arguments to Crynux API.
96
- """
97
- for param in self.model_config_dict:
98
- if param not in CRYNUX_API_PARAMS:
99
- raise ValueError(
100
- f"Unexpected argument `{param}` is "
101
- "input into Crynux model backend."
102
- )
@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Optional, Type, Union
18
18
  from openai import AsyncStream, Stream
19
19
  from pydantic import BaseModel
20
20
 
21
- from camel.configs import DEEPSEEK_API_PARAMS, DeepSeekConfig
21
+ from camel.configs import DeepSeekConfig
22
22
  from camel.logger import get_logger
23
23
  from camel.messages import OpenAIMessage
24
24
  from camel.models._utils import try_modify_message_with_format
@@ -287,18 +287,3 @@ class DeepSeekModel(OpenAICompatibleModel):
287
287
  )
288
288
 
289
289
  return self._post_handle_response(response)
290
-
291
- def check_model_config(self):
292
- r"""Check whether the model configuration contains any
293
- unexpected arguments to DeepSeek API.
294
-
295
- Raises:
296
- ValueError: If the model configuration dictionary contains any
297
- unexpected arguments to DeepSeek API.
298
- """
299
- for param in self.model_config_dict:
300
- if param not in DEEPSEEK_API_PARAMS:
301
- raise ValueError(
302
- f"Unexpected argument `{param}` is "
303
- "input into DeepSeek model backend."
304
- )
@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Type, Union
17
17
  from openai import AsyncStream, Stream
18
18
  from pydantic import BaseModel
19
19
 
20
- from camel.configs import Gemini_API_PARAMS, GeminiConfig
20
+ from camel.configs import GeminiConfig
21
21
  from camel.messages import OpenAIMessage
22
22
  from camel.models.openai_compatible_model import OpenAICompatibleModel
23
23
  from camel.types import (
@@ -335,18 +335,3 @@ class GeminiModel(OpenAICompatibleModel):
335
335
  model=self.model_type,
336
336
  **request_config,
337
337
  )
338
-
339
- def check_model_config(self):
340
- r"""Check whether the model configuration contains any
341
- unexpected arguments to Gemini API.
342
-
343
- Raises:
344
- ValueError: If the model configuration dictionary contains any
345
- unexpected arguments to Gemini API.
346
- """
347
- for param in self.model_config_dict:
348
- if param not in Gemini_API_PARAMS:
349
- raise ValueError(
350
- f"Unexpected argument `{param}` is "
351
- "input into Gemini model backend."
352
- )
@@ -14,7 +14,7 @@
14
14
  import os
15
15
  from typing import Any, Dict, Optional, Union
16
16
 
17
- from camel.configs import GROQ_API_PARAMS, GroqConfig
17
+ from camel.configs import GroqConfig
18
18
  from camel.models.openai_compatible_model import OpenAICompatibleModel
19
19
  from camel.types import ModelType
20
20
  from camel.utils import (
@@ -80,19 +80,3 @@ class GroqModel(OpenAICompatibleModel):
80
80
  max_retries=max_retries,
81
81
  **kwargs,
82
82
  )
83
-
84
- def check_model_config(self):
85
- r"""Check whether the model configuration contains any unexpected
86
- arguments to Groq API. But Groq API does not have any additional
87
- arguments to check.
88
-
89
- Raises:
90
- ValueError: If the model configuration dictionary contains any
91
- unexpected arguments to Groq API.
92
- """
93
- for param in self.model_config_dict:
94
- if param not in GROQ_API_PARAMS:
95
- raise ValueError(
96
- f"Unexpected argument `{param}` is "
97
- "input into Groq model backend."
98
- )
@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Optional, Type, Union
18
18
  from openai import AsyncStream
19
19
  from pydantic import BaseModel
20
20
 
21
- from camel.configs import INTERNLM_API_PARAMS, InternLMConfig
21
+ from camel.configs import InternLMConfig
22
22
  from camel.messages import OpenAIMessage
23
23
  from camel.models.openai_compatible_model import OpenAICompatibleModel
24
24
  from camel.types import (
@@ -101,18 +101,3 @@ class InternLMModel(OpenAICompatibleModel):
101
101
  tools: Optional[List[Dict[str, Any]]] = None,
102
102
  ) -> Union[ChatCompletion, AsyncStream[ChatCompletionChunk]]:
103
103
  raise NotImplementedError("InternLM does not support async inference.")
104
-
105
- def check_model_config(self):
106
- r"""Check whether the model configuration contains any
107
- unexpected arguments to InternLM API.
108
-
109
- Raises:
110
- ValueError: If the model configuration dictionary contains any
111
- unexpected arguments to InternLM API.
112
- """
113
- for param in self.model_config_dict:
114
- if param not in INTERNLM_API_PARAMS:
115
- raise ValueError(
116
- f"Unexpected argument `{param}` is "
117
- "input into InternLM model backend."
118
- )
@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Type, Union
17
17
 
18
18
  from pydantic import BaseModel
19
19
 
20
- from camel.configs import LITELLM_API_PARAMS, LiteLLMConfig
20
+ from camel.configs import LiteLLMConfig
21
21
  from camel.messages import OpenAIMessage
22
22
  from camel.models import BaseModelBackend
23
23
  from camel.types import ChatCompletion, ModelType
@@ -217,18 +217,3 @@ class LiteLLMModel(BaseModelBackend):
217
217
  usage=response.usage,
218
218
  )
219
219
  return response
220
-
221
- def check_model_config(self):
222
- r"""Check whether the model configuration contains any unexpected
223
- arguments to LiteLLM API.
224
-
225
- Raises:
226
- ValueError: If the model configuration dictionary contains any
227
- unexpected arguments.
228
- """
229
- for param in self.model_config_dict:
230
- if param not in LITELLM_API_PARAMS:
231
- raise ValueError(
232
- f"Unexpected argument `{param}` is "
233
- "input into LiteLLM model backend."
234
- )
@@ -14,7 +14,7 @@
14
14
  import os
15
15
  from typing import Any, Dict, Optional, Union
16
16
 
17
- from camel.configs import LMSTUDIO_API_PARAMS, LMStudioConfig
17
+ from camel.configs import LMStudioConfig
18
18
  from camel.models.openai_compatible_model import OpenAICompatibleModel
19
19
  from camel.types import ModelType
20
20
  from camel.utils import BaseTokenCounter
@@ -77,19 +77,3 @@ class LMStudioModel(OpenAICompatibleModel):
77
77
  max_retries=max_retries,
78
78
  **kwargs,
79
79
  )
80
-
81
- def check_model_config(self):
82
- r"""Check whether the model configuration contains any unexpected
83
- arguments to LMStudio API. But LMStudio API does not have any
84
- additional arguments to check.
85
-
86
- Raises:
87
- ValueError: If the model configuration dictionary contains any
88
- unexpected arguments to LMStudio API.
89
- """
90
- for param in self.model_config_dict:
91
- if param not in LMSTUDIO_API_PARAMS:
92
- raise ValueError(
93
- f"Unexpected argument `{param}` is "
94
- "input into LMStudio model backend."
95
- )
@@ -24,7 +24,7 @@ if TYPE_CHECKING:
24
24
 
25
25
  from openai import AsyncStream
26
26
 
27
- from camel.configs import MISTRAL_API_PARAMS, MistralConfig
27
+ from camel.configs import MistralConfig
28
28
  from camel.logger import get_logger
29
29
  from camel.messages import OpenAIMessage
30
30
  from camel.models import BaseModelBackend
@@ -414,21 +414,6 @@ class MistralModel(BaseModelBackend):
414
414
 
415
415
  return request_config
416
416
 
417
- def check_model_config(self):
418
- r"""Check whether the model configuration contains any
419
- unexpected arguments to Mistral API.
420
-
421
- Raises:
422
- ValueError: If the model configuration dictionary contains any
423
- unexpected arguments to Mistral API.
424
- """
425
- for param in self.model_config_dict:
426
- if param not in MISTRAL_API_PARAMS:
427
- raise ValueError(
428
- f"Unexpected argument `{param}` is "
429
- "input into Mistral model backend."
430
- )
431
-
432
417
  @property
433
418
  def stream(self) -> bool:
434
419
  r"""Returns whether the model is in stream mode, which sends partial
@@ -31,6 +31,7 @@ from camel.models.lmstudio_model import LMStudioModel
31
31
  from camel.models.mistral_model import MistralModel
32
32
  from camel.models.modelscope_model import ModelScopeModel
33
33
  from camel.models.moonshot_model import MoonshotModel
34
+ from camel.models.nebius_model import NebiusModel
34
35
  from camel.models.netmind_model import NetmindModel
35
36
  from camel.models.novita_model import NovitaModel
36
37
  from camel.models.nvidia_model import NvidiaModel
@@ -83,6 +84,7 @@ class ModelFactory:
83
84
  ModelPlatformType.AZURE: AzureOpenAIModel,
84
85
  ModelPlatformType.ANTHROPIC: AnthropicModel,
85
86
  ModelPlatformType.GROQ: GroqModel,
87
+ ModelPlatformType.NEBIUS: NebiusModel,
86
88
  ModelPlatformType.LMSTUDIO: LMStudioModel,
87
89
  ModelPlatformType.OPENROUTER: OpenRouterModel,
88
90
  ModelPlatformType.ZHIPU: ZhipuAIModel,
@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Optional, Union
18
18
 
19
19
  from openai import AsyncStream, Stream
20
20
 
21
- from camel.configs import MODELSCOPE_API_PARAMS, ModelScopeConfig
21
+ from camel.configs import ModelScopeConfig
22
22
  from camel.messages import OpenAIMessage
23
23
  from camel.models.openai_compatible_model import OpenAICompatibleModel
24
24
  from camel.types import (
@@ -261,18 +261,3 @@ class ModelScopeModel(OpenAICompatibleModel):
261
261
  **request_config,
262
262
  )
263
263
  return self._post_handle_response(response)
264
-
265
- def check_model_config(self):
266
- r"""Check whether the model configuration contains any
267
- unexpected arguments to ModelScope API.
268
-
269
- Raises:
270
- ValueError: If the model configuration dictionary contains any
271
- unexpected arguments to ModelScope API.
272
- """
273
- for param in self.model_config_dict:
274
- if param not in MODELSCOPE_API_PARAMS:
275
- raise ValueError(
276
- f"Unexpected argument `{param}` is "
277
- "input into ModelScope model backend."
278
- )
@@ -18,7 +18,7 @@ from typing import Any, Dict, List, Optional, Type, Union
18
18
  from openai import AsyncStream
19
19
  from pydantic import BaseModel
20
20
 
21
- from camel.configs import MOONSHOT_API_PARAMS, MoonshotConfig
21
+ from camel.configs import MoonshotConfig
22
22
  from camel.messages import OpenAIMessage
23
23
  from camel.models._utils import try_modify_message_with_format
24
24
  from camel.models.openai_compatible_model import OpenAICompatibleModel
@@ -61,7 +61,9 @@ class MoonshotModel(OpenAICompatibleModel):
61
61
  api_key (Optional[str], optional): The API key for authenticating with
62
62
  the Moonshot service. (default: :obj:`None`)
63
63
  url (Optional[str], optional): The url to the Moonshot service.
64
- (default: :obj:`https://api.moonshot.cn/v1`)
64
+ For Chinese users, use :obj:`https://api.moonshot.cn/v1`.
65
+ For overseas users, the default endpoint will be used.
66
+ (default: :obj:`https://api.moonshot.ai/v1`)
65
67
  token_counter (Optional[BaseTokenCounter], optional): Token counter to
66
68
  use for the model. If not provided, :obj:`OpenAITokenCounter(
67
69
  ModelType.GPT_4)` will be used.
@@ -82,7 +84,7 @@ class MoonshotModel(OpenAICompatibleModel):
82
84
  model_type: Union[ModelType, str],
83
85
  model_config_dict: Optional[Dict[str, Any]] = None,
84
86
  api_key: Optional[str] = None,
85
- url: Optional[str] = None,
87
+ url: Optional[str] = "https://api.moonshot.ai/v1",
86
88
  token_counter: Optional[BaseTokenCounter] = None,
87
89
  timeout: Optional[float] = None,
88
90
  max_retries: int = 3,
@@ -91,10 +93,7 @@ class MoonshotModel(OpenAICompatibleModel):
91
93
  if model_config_dict is None:
92
94
  model_config_dict = MoonshotConfig().as_dict()
93
95
  api_key = api_key or os.environ.get("MOONSHOT_API_KEY")
94
- url = url or os.environ.get(
95
- "MOONSHOT_API_BASE_URL",
96
- "https://api.moonshot.cn/v1",
97
- )
96
+ url = url or os.environ.get("MOONSHOT_API_BASE_URL")
98
97
  timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))
99
98
  super().__init__(
100
99
  model_type=model_type,
@@ -183,18 +182,3 @@ class MoonshotModel(OpenAICompatibleModel):
183
182
  model=self.model_type,
184
183
  **request_config,
185
184
  )
186
-
187
- def check_model_config(self):
188
- r"""Check whether the model configuration contains any
189
- unexpected arguments to Moonshot API.
190
-
191
- Raises:
192
- ValueError: If the model configuration dictionary contains any
193
- unexpected arguments to Moonshot API.
194
- """
195
- for param in self.model_config_dict:
196
- if param not in MOONSHOT_API_PARAMS:
197
- raise ValueError(
198
- f"Unexpected argument `{param}` is "
199
- "input into Moonshot model backend."
200
- )
@@ -0,0 +1,83 @@
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # http://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License.
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
+ import os
15
+ from typing import Any, Dict, Optional, Union
16
+
17
+ from camel.configs import NebiusConfig
18
+ from camel.models.openai_compatible_model import OpenAICompatibleModel
19
+ from camel.types import ModelType
20
+ from camel.utils import (
21
+ BaseTokenCounter,
22
+ api_keys_required,
23
+ )
24
+
25
+
26
+ class NebiusModel(OpenAICompatibleModel):
27
+ r"""LLM API served by Nebius AI Studio in a unified OpenAICompatibleModel
28
+ interface.
29
+
30
+ Args:
31
+ model_type (Union[ModelType, str]): Model for which a backend is
32
+ created.
33
+ model_config_dict (Optional[Dict[str, Any]], optional): A dictionary
34
+ that will be fed into:obj:`openai.ChatCompletion.create()`.
35
+ If:obj:`None`, :obj:`NebiusConfig().as_dict()` will be used.
36
+ (default: :obj:`None`)
37
+ api_key (Optional[str], optional): The API key for authenticating
38
+ with the Nebius AI Studio service. (default: :obj:`None`).
39
+ url (Optional[str], optional): The url to the Nebius AI Studio service.
40
+ (default: :obj:`None`)
41
+ token_counter (Optional[BaseTokenCounter], optional): Token counter to
42
+ use for the model. If not provided, :obj:`OpenAITokenCounter(
43
+ ModelType.GPT_4O_MINI)` will be used.
44
+ (default: :obj:`None`)
45
+ timeout (Optional[float], optional): The timeout value in seconds for
46
+ API calls. If not provided, will fall back to the MODEL_TIMEOUT
47
+ environment variable or default to 180 seconds.
48
+ (default: :obj:`None`)
49
+ max_retries (int, optional): Maximum number of retries for API calls.
50
+ (default: :obj:`3`)
51
+ **kwargs (Any): Additional arguments to pass to the client
52
+ initialization.
53
+ """
54
+
55
+ @api_keys_required([("api_key", "NEBIUS_API_KEY")])
56
+ def __init__(
57
+ self,
58
+ model_type: Union[ModelType, str],
59
+ model_config_dict: Optional[Dict[str, Any]] = None,
60
+ api_key: Optional[str] = None,
61
+ url: Optional[str] = None,
62
+ token_counter: Optional[BaseTokenCounter] = None,
63
+ timeout: Optional[float] = None,
64
+ max_retries: int = 3,
65
+ **kwargs: Any,
66
+ ) -> None:
67
+ if model_config_dict is None:
68
+ model_config_dict = NebiusConfig().as_dict()
69
+ api_key = api_key or os.environ.get("NEBIUS_API_KEY")
70
+ url = url or os.environ.get(
71
+ "NEBIUS_API_BASE_URL", "https://api.studio.nebius.com/v1"
72
+ )
73
+ timeout = timeout or float(os.environ.get("MODEL_TIMEOUT", 180))
74
+ super().__init__(
75
+ model_type=model_type,
76
+ model_config_dict=model_config_dict,
77
+ api_key=api_key,
78
+ url=url,
79
+ token_counter=token_counter,
80
+ timeout=timeout,
81
+ max_retries=max_retries,
82
+ **kwargs,
83
+ )
@@ -80,8 +80,3 @@ class NemotronModel(OpenAICompatibleModel):
80
80
  raise NotImplementedError(
81
81
  "Nemotron model doesn't support token counter."
82
82
  )
83
-
84
- def check_model_config(self):
85
- raise NotImplementedError(
86
- "Nemotron model doesn't support model config."
87
- )
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  from typing import Any, Dict, Optional, Union
17
17
 
18
- from camel.configs import NETMIND_API_PARAMS, NetmindConfig
18
+ from camel.configs import NetmindConfig
19
19
  from camel.models.openai_compatible_model import OpenAICompatibleModel
20
20
  from camel.types import ModelType
21
21
  from camel.utils import (
@@ -87,18 +87,3 @@ class NetmindModel(OpenAICompatibleModel):
87
87
  max_retries=max_retries,
88
88
  **kwargs,
89
89
  )
90
-
91
- def check_model_config(self):
92
- r"""Check whether the model configuration contains any
93
- unexpected arguments to NETMIND API.
94
-
95
- Raises:
96
- ValueError: If the model configuration dictionary contains any
97
- unexpected arguments to NETMIND API.
98
- """
99
- for param in self.model_config_dict:
100
- if param not in NETMIND_API_PARAMS:
101
- raise ValueError(
102
- f"Unexpected argument `{param}` is "
103
- "input into NETMIND model backend."
104
- )
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  from typing import Any, Dict, Optional, Union
17
17
 
18
- from camel.configs import NOVITA_API_PARAMS, NovitaConfig
18
+ from camel.configs import NovitaConfig
19
19
  from camel.models.openai_compatible_model import OpenAICompatibleModel
20
20
  from camel.types import ModelType
21
21
  from camel.utils import (
@@ -86,18 +86,3 @@ class NovitaModel(OpenAICompatibleModel):
86
86
  max_retries=max_retries,
87
87
  **kwargs,
88
88
  )
89
-
90
- def check_model_config(self):
91
- r"""Check whether the model configuration contains any
92
- unexpected arguments to Novita API.
93
-
94
- Raises:
95
- ValueError: If the model configuration dictionary contains any
96
- unexpected arguments to Novita API.
97
- """
98
- for param in self.model_config_dict:
99
- if param not in NOVITA_API_PARAMS:
100
- raise ValueError(
101
- f"Unexpected argument `{param}` is "
102
- "input into Novita model backend."
103
- )
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  from typing import Any, Dict, Optional, Union
17
17
 
18
- from camel.configs import NVIDIA_API_PARAMS, NvidiaConfig
18
+ from camel.configs import NvidiaConfig
19
19
  from camel.models.openai_compatible_model import OpenAICompatibleModel
20
20
  from camel.types import ModelType
21
21
  from camel.utils import BaseTokenCounter, api_keys_required
@@ -82,18 +82,3 @@ class NvidiaModel(OpenAICompatibleModel):
82
82
  max_retries=max_retries,
83
83
  **kwargs,
84
84
  )
85
-
86
- def check_model_config(self):
87
- r"""Check whether the model configuration contains any
88
- unexpected arguments to NVIDIA API.
89
-
90
- Raises:
91
- ValueError: If the model configuration dictionary contains any
92
- unexpected arguments to NVIDIA API.
93
- """
94
- for param in self.model_config_dict:
95
- if param not in NVIDIA_API_PARAMS:
96
- raise ValueError(
97
- f"Unexpected argument `{param}` is "
98
- "input into NVIDIA model backend."
99
- )
@@ -15,7 +15,7 @@ import os
15
15
  import subprocess
16
16
  from typing import Any, Dict, Optional, Union
17
17
 
18
- from camel.configs import OLLAMA_API_PARAMS, OllamaConfig
18
+ from camel.configs import OllamaConfig
19
19
  from camel.logger import get_logger
20
20
  from camel.models.openai_compatible_model import OpenAICompatibleModel
21
21
  from camel.types import ModelType
@@ -35,8 +35,8 @@ class OllamaModel(OpenAICompatibleModel):
35
35
  If:obj:`None`, :obj:`OllamaConfig().as_dict()` will be used.
36
36
  (default: :obj:`None`)
37
37
  api_key (Optional[str], optional): The API key for authenticating with
38
- the model service. Ollama doesn't need API key, it would be
39
- ignored if set. (default: :obj:`None`)
38
+ the model service. Required for Ollama cloud services. If not
39
+ provided, defaults to "Not_Provided". (default: :obj:`None`)
40
40
  url (Optional[str], optional): The url to the model service.
41
41
  (default: :obj:`None`)
42
42
  token_counter (Optional[BaseTokenCounter], optional): Token counter to
@@ -79,7 +79,7 @@ class OllamaModel(OpenAICompatibleModel):
79
79
  super().__init__(
80
80
  model_type=self._model_type,
81
81
  model_config_dict=model_config_dict,
82
- api_key="Not_Used",
82
+ api_key=api_key or "Not_Provided",
83
83
  url=self._url,
84
84
  token_counter=token_counter,
85
85
  timeout=timeout,
@@ -102,18 +102,3 @@ class OllamaModel(OpenAICompatibleModel):
102
102
  )
103
103
  except Exception as e:
104
104
  logger.error(f"Failed to start Ollama server: {e}.")
105
-
106
- def check_model_config(self):
107
- r"""Check whether the model configuration contains any
108
- unexpected arguments to Ollama API.
109
-
110
- Raises:
111
- ValueError: If the model configuration dictionary contains any
112
- unexpected arguments to OpenAI API.
113
- """
114
- for param in self.model_config_dict:
115
- if param not in OLLAMA_API_PARAMS:
116
- raise ValueError(
117
- f"Unexpected argument `{param}` is "
118
- "input into Ollama model backend."
119
- )
@@ -462,6 +462,3 @@ class OpenAICompatibleModel(BaseModelBackend):
462
462
  bool: Whether the model is in stream mode.
463
463
  """
464
464
  return self.model_config_dict.get('stream', False)
465
-
466
- def check_model_config(self):
467
- pass