camel-ai 0.2.15a0__py3-none-any.whl → 0.2.17__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 (95) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +18 -4
  3. camel/agents/multi_hop_generator_agent.py +85 -0
  4. camel/agents/programmed_agent_instruction.py +148 -0
  5. camel/benchmarks/__init__.py +13 -1
  6. camel/benchmarks/apibank.py +565 -0
  7. camel/benchmarks/apibench.py +500 -0
  8. camel/benchmarks/gaia.py +4 -4
  9. camel/benchmarks/nexus.py +518 -0
  10. camel/benchmarks/ragbench.py +333 -0
  11. camel/bots/__init__.py +1 -1
  12. camel/bots/discord/__init__.py +26 -0
  13. camel/bots/discord/discord_app.py +384 -0
  14. camel/bots/discord/discord_installation.py +64 -0
  15. camel/bots/discord/discord_store.py +160 -0
  16. camel/configs/__init__.py +3 -0
  17. camel/configs/anthropic_config.py +17 -15
  18. camel/configs/internlm_config.py +60 -0
  19. camel/data_collector/base.py +5 -5
  20. camel/data_collector/sharegpt_collector.py +2 -2
  21. camel/datagen/__init__.py +6 -2
  22. camel/datagen/{o1datagen.py → cotdatagen.py} +19 -6
  23. camel/datagen/self_instruct/__init__.py +36 -0
  24. camel/datagen/self_instruct/filter/__init__.py +34 -0
  25. camel/datagen/self_instruct/filter/filter_function.py +216 -0
  26. camel/datagen/self_instruct/filter/filter_registry.py +56 -0
  27. camel/datagen/self_instruct/filter/instruction_filter.py +81 -0
  28. camel/datagen/self_instruct/self_instruct.py +393 -0
  29. camel/datagen/self_instruct/templates.py +382 -0
  30. camel/datahubs/huggingface.py +12 -2
  31. camel/datahubs/models.py +2 -3
  32. camel/embeddings/mistral_embedding.py +5 -1
  33. camel/embeddings/openai_compatible_embedding.py +6 -1
  34. camel/embeddings/openai_embedding.py +5 -1
  35. camel/interpreters/e2b_interpreter.py +5 -1
  36. camel/loaders/__init__.py +2 -0
  37. camel/loaders/apify_reader.py +5 -1
  38. camel/loaders/chunkr_reader.py +5 -1
  39. camel/loaders/firecrawl_reader.py +0 -30
  40. camel/loaders/panda_reader.py +337 -0
  41. camel/logger.py +11 -5
  42. camel/messages/__init__.py +10 -4
  43. camel/messages/conversion/conversation_models.py +5 -0
  44. camel/messages/func_message.py +30 -22
  45. camel/models/__init__.py +2 -0
  46. camel/models/anthropic_model.py +6 -23
  47. camel/models/azure_openai_model.py +1 -2
  48. camel/models/cohere_model.py +13 -1
  49. camel/models/deepseek_model.py +5 -1
  50. camel/models/gemini_model.py +15 -2
  51. camel/models/groq_model.py +5 -1
  52. camel/models/internlm_model.py +143 -0
  53. camel/models/mistral_model.py +19 -8
  54. camel/models/model_factory.py +3 -0
  55. camel/models/nemotron_model.py +5 -1
  56. camel/models/nvidia_model.py +5 -1
  57. camel/models/openai_model.py +5 -1
  58. camel/models/qwen_model.py +5 -1
  59. camel/models/reka_model.py +5 -1
  60. camel/models/reward/__init__.py +2 -0
  61. camel/models/reward/nemotron_model.py +5 -1
  62. camel/models/reward/skywork_model.py +88 -0
  63. camel/models/samba_model.py +5 -1
  64. camel/models/togetherai_model.py +5 -1
  65. camel/models/yi_model.py +5 -1
  66. camel/models/zhipuai_model.py +5 -1
  67. camel/schemas/openai_converter.py +5 -1
  68. camel/storages/graph_storages/nebula_graph.py +89 -20
  69. camel/storages/graph_storages/neo4j_graph.py +138 -0
  70. camel/synthetic_datagen/source2synth/data_processor.py +373 -0
  71. camel/synthetic_datagen/source2synth/models.py +68 -0
  72. camel/synthetic_datagen/source2synth/user_data_processor_config.py +73 -0
  73. camel/toolkits/__init__.py +4 -0
  74. camel/toolkits/arxiv_toolkit.py +20 -3
  75. camel/toolkits/dappier_toolkit.py +196 -0
  76. camel/toolkits/function_tool.py +61 -61
  77. camel/toolkits/google_scholar_toolkit.py +9 -0
  78. camel/toolkits/meshy_toolkit.py +5 -1
  79. camel/toolkits/notion_toolkit.py +1 -1
  80. camel/toolkits/openbb_toolkit.py +869 -0
  81. camel/toolkits/search_toolkit.py +91 -5
  82. camel/toolkits/stripe_toolkit.py +5 -1
  83. camel/toolkits/twitter_toolkit.py +24 -16
  84. camel/types/__init__.py +4 -2
  85. camel/types/enums.py +34 -1
  86. camel/types/openai_types.py +6 -4
  87. camel/types/unified_model_type.py +5 -0
  88. camel/utils/__init__.py +2 -0
  89. camel/utils/commons.py +104 -19
  90. camel/utils/token_counting.py +3 -3
  91. {camel_ai-0.2.15a0.dist-info → camel_ai-0.2.17.dist-info}/METADATA +160 -177
  92. {camel_ai-0.2.15a0.dist-info → camel_ai-0.2.17.dist-info}/RECORD +94 -69
  93. {camel_ai-0.2.15a0.dist-info → camel_ai-0.2.17.dist-info}/WHEEL +1 -1
  94. camel/bots/discord_app.py +0 -138
  95. {camel_ai-0.2.15a0.dist-info → camel_ai-0.2.17.dist-info}/LICENSE +0 -0
@@ -52,6 +52,11 @@ class GeminiModel(BaseModelBackend):
52
52
  (default: :obj:`None`)
53
53
  """
54
54
 
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", 'GEMINI_API_KEY'),
58
+ ]
59
+ )
55
60
  def __init__(
56
61
  self,
57
62
  model_type: Union[ModelType, str],
@@ -77,7 +82,6 @@ class GeminiModel(BaseModelBackend):
77
82
  base_url=self._url,
78
83
  )
79
84
 
80
- @api_keys_required("GEMINI_API_KEY")
81
85
  def run(
82
86
  self,
83
87
  messages: List[OpenAIMessage],
@@ -93,8 +97,17 @@ class GeminiModel(BaseModelBackend):
93
97
  `ChatCompletion` in the non-stream mode, or
94
98
  `Stream[ChatCompletionChunk]` in the stream mode.
95
99
  """
100
+ # Process messages to ensure no empty content, it's not accepeted by
101
+ # Gemini
102
+ processed_messages = []
103
+ for msg in messages:
104
+ msg_copy = msg.copy()
105
+ if 'content' in msg_copy and msg_copy['content'] == '':
106
+ msg_copy['content'] = 'null'
107
+ processed_messages.append(msg_copy)
108
+
96
109
  response = self._client.chat.completions.create(
97
- messages=messages,
110
+ messages=processed_messages,
98
111
  model=self.model_type,
99
112
  **self.model_config_dict,
100
113
  )
@@ -51,6 +51,11 @@ class GroqModel(BaseModelBackend):
51
51
  (default: :obj:`None`)
52
52
  """
53
53
 
54
+ @api_keys_required(
55
+ [
56
+ ("api_key", "GROQ_API_KEY"),
57
+ ]
58
+ )
54
59
  def __init__(
55
60
  self,
56
61
  model_type: Union[ModelType, str],
@@ -89,7 +94,6 @@ class GroqModel(BaseModelBackend):
89
94
  self._token_counter = OpenAITokenCounter(ModelType.GPT_4O_MINI)
90
95
  return self._token_counter
91
96
 
92
- @api_keys_required("GROQ_API_KEY")
93
97
  def run(
94
98
  self,
95
99
  messages: List[OpenAIMessage],
@@ -0,0 +1,143 @@
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
+
15
+ import os
16
+ from typing import Any, Dict, List, Optional, Union
17
+
18
+ from openai import OpenAI, Stream
19
+
20
+ from camel.configs import INTERNLM_API_PARAMS, InternLMConfig
21
+ from camel.messages import OpenAIMessage
22
+ from camel.models import BaseModelBackend
23
+ from camel.types import (
24
+ ChatCompletion,
25
+ ChatCompletionChunk,
26
+ ModelType,
27
+ )
28
+ from camel.utils import (
29
+ BaseTokenCounter,
30
+ OpenAITokenCounter,
31
+ api_keys_required,
32
+ )
33
+
34
+
35
+ class InternLMModel(BaseModelBackend):
36
+ r"""InternLM API in a unified BaseModelBackend interface.
37
+
38
+ Args:
39
+ model_type (Union[ModelType, str]): Model for which a backend is
40
+ created, one of InternLM series.
41
+ model_config_dict (Optional[Dict[str, Any]], optional): A dictionary
42
+ that will be fed into:obj:`openai.ChatCompletion.create()`. If
43
+ :obj:`None`, :obj:`InternLMConfig().as_dict()` will be used.
44
+ (default: :obj:`None`)
45
+ api_key (Optional[str], optional): The API key for authenticating with
46
+ the InternLM service. (default: :obj:`None`)
47
+ url (Optional[str], optional): The url to the InternLM service.
48
+ (default: :obj:`https://internlm-chat.intern-ai.org.cn/puyu/api/v1`)
49
+ token_counter (Optional[BaseTokenCounter], optional): Token counter to
50
+ use for the model. If not provided, :obj:`OpenAITokenCounter(
51
+ ModelType.GPT_4O_MINI)` will be used.
52
+ (default: :obj:`None`)
53
+ """
54
+
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", "INTERNLM_API_KEY"),
58
+ ]
59
+ )
60
+ def __init__(
61
+ self,
62
+ model_type: Union[ModelType, str],
63
+ model_config_dict: Optional[Dict[str, Any]] = None,
64
+ api_key: Optional[str] = None,
65
+ url: Optional[str] = None,
66
+ token_counter: Optional[BaseTokenCounter] = None,
67
+ ) -> None:
68
+ if model_config_dict is None:
69
+ model_config_dict = InternLMConfig().as_dict()
70
+ api_key = api_key or os.environ.get("INTERNLM_API_KEY")
71
+ url = url or os.environ.get(
72
+ "INTERNLM_API_BASE_URL",
73
+ "https://internlm-chat.intern-ai.org.cn/puyu/api/v1",
74
+ )
75
+ super().__init__(
76
+ model_type, model_config_dict, api_key, url, token_counter
77
+ )
78
+ self._client = OpenAI(
79
+ timeout=180,
80
+ max_retries=3,
81
+ api_key=self._api_key,
82
+ base_url=self._url,
83
+ )
84
+
85
+ def run(
86
+ self,
87
+ messages: List[OpenAIMessage],
88
+ ) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
89
+ r"""Runs inference of InternLM chat completion.
90
+
91
+ Args:
92
+ messages (List[OpenAIMessage]): Message list with the chat history
93
+ in OpenAI API format.
94
+
95
+ Returns:
96
+ Union[ChatCompletion, Stream[ChatCompletionChunk]]:
97
+ `ChatCompletion` in the non-stream mode, or
98
+ `Stream[ChatCompletionChunk]` in the stream mode.
99
+ """
100
+ response = self._client.chat.completions.create(
101
+ messages=messages,
102
+ model=self.model_type,
103
+ **self.model_config_dict,
104
+ )
105
+ return response
106
+
107
+ @property
108
+ def token_counter(self) -> BaseTokenCounter:
109
+ r"""Initialize the token counter for the model backend.
110
+
111
+ Returns:
112
+ OpenAITokenCounter: The token counter following the model's
113
+ tokenization style.
114
+ """
115
+
116
+ if not self._token_counter:
117
+ self._token_counter = OpenAITokenCounter(ModelType.GPT_4O_MINI)
118
+ return self._token_counter
119
+
120
+ def check_model_config(self):
121
+ r"""Check whether the model configuration contains any
122
+ unexpected arguments to InternLM API.
123
+
124
+ Raises:
125
+ ValueError: If the model configuration dictionary contains any
126
+ unexpected arguments to InternLM API.
127
+ """
128
+ for param in self.model_config_dict:
129
+ if param not in INTERNLM_API_PARAMS:
130
+ raise ValueError(
131
+ f"Unexpected argument `{param}` is "
132
+ "input into InternLM model backend."
133
+ )
134
+
135
+ @property
136
+ def stream(self) -> bool:
137
+ r"""Returns whether the model is in stream mode, which sends partial
138
+ results each time.
139
+
140
+ Returns:
141
+ bool: Whether the model is in stream mode.
142
+ """
143
+ return self.model_config_dict.get('stream', False)
@@ -59,6 +59,11 @@ class MistralModel(BaseModelBackend):
59
59
  be used. (default: :obj:`None`)
60
60
  """
61
61
 
62
+ @api_keys_required(
63
+ [
64
+ ("api_key", "MISTRAL_API_KEY"),
65
+ ]
66
+ )
62
67
  @dependencies_required('mistralai')
63
68
  def __init__(
64
69
  self,
@@ -142,18 +147,25 @@ class MistralModel(BaseModelBackend):
142
147
  new_messages = []
143
148
  for msg in messages:
144
149
  tool_id = uuid.uuid4().hex[:9]
145
- tool_call_id = uuid.uuid4().hex[:9]
150
+ tool_call_id = msg.get("tool_call_id") or uuid.uuid4().hex[:9]
146
151
 
147
152
  role = msg.get("role")
148
- function_call = msg.get("function_call")
153
+ tool_calls = msg.get("tool_calls")
149
154
  content = msg.get("content")
150
155
 
151
156
  mistral_function_call = None
152
- if function_call:
153
- mistral_function_call = FunctionCall(
154
- name=function_call.get("name"), # type: ignore[attr-defined]
155
- arguments=function_call.get("arguments"), # type: ignore[attr-defined]
157
+ if tool_calls:
158
+ # Ensure tool_calls is treated as a list
159
+ tool_calls_list = (
160
+ tool_calls
161
+ if isinstance(tool_calls, list)
162
+ else [tool_calls]
156
163
  )
164
+ for tool_call in tool_calls_list:
165
+ mistral_function_call = FunctionCall(
166
+ name=tool_call["function"].get("name"), # type: ignore[attr-defined]
167
+ arguments=tool_call["function"].get("arguments"), # type: ignore[attr-defined]
168
+ )
157
169
 
158
170
  tool_calls = None
159
171
  if mistral_function_call:
@@ -173,7 +185,7 @@ class MistralModel(BaseModelBackend):
173
185
  new_messages.append(
174
186
  ToolMessage(
175
187
  content=content, # type: ignore[arg-type]
176
- tool_call_id=tool_call_id,
188
+ tool_call_id=tool_call_id, # type: ignore[arg-type]
177
189
  name=msg.get("name"), # type: ignore[arg-type]
178
190
  )
179
191
  )
@@ -200,7 +212,6 @@ class MistralModel(BaseModelBackend):
200
212
  )
201
213
  return self._token_counter
202
214
 
203
- @api_keys_required("MISTRAL_API_KEY")
204
215
  def run(
205
216
  self,
206
217
  messages: List[OpenAIMessage],
@@ -20,6 +20,7 @@ from camel.models.cohere_model import CohereModel
20
20
  from camel.models.deepseek_model import DeepSeekModel
21
21
  from camel.models.gemini_model import GeminiModel
22
22
  from camel.models.groq_model import GroqModel
23
+ from camel.models.internlm_model import InternLMModel
23
24
  from camel.models.litellm_model import LiteLLMModel
24
25
  from camel.models.mistral_model import MistralModel
25
26
  from camel.models.nvidia_model import NvidiaModel
@@ -124,6 +125,8 @@ class ModelFactory:
124
125
  model_class = QwenModel
125
126
  elif model_platform.is_deepseek:
126
127
  model_class = DeepSeekModel
128
+ elif model_platform.is_internlm and model_type.is_internlm:
129
+ model_class = InternLMModel
127
130
  elif model_type == ModelType.STUB:
128
131
  model_class = StubModel
129
132
 
@@ -40,6 +40,11 @@ class NemotronModel(BaseModelBackend):
40
40
  Nemotron model doesn't support additional model config like OpenAI.
41
41
  """
42
42
 
43
+ @api_keys_required(
44
+ [
45
+ ("api_key", "NVIDIA_API_KEY"),
46
+ ]
47
+ )
43
48
  def __init__(
44
49
  self,
45
50
  model_type: Union[ModelType, str],
@@ -58,7 +63,6 @@ class NemotronModel(BaseModelBackend):
58
63
  api_key=self._api_key,
59
64
  )
60
65
 
61
- @api_keys_required("NVIDIA_API_KEY")
62
66
  def run(
63
67
  self,
64
68
  messages: List[OpenAIMessage],
@@ -48,6 +48,11 @@ class NvidiaModel(BaseModelBackend):
48
48
  (default: :obj:`None`)
49
49
  """
50
50
 
51
+ @api_keys_required(
52
+ [
53
+ ("api_key", "NVIDIA_API_KEY"),
54
+ ]
55
+ )
51
56
  def __init__(
52
57
  self,
53
58
  model_type: Union[ModelType, str],
@@ -72,7 +77,6 @@ class NvidiaModel(BaseModelBackend):
72
77
  base_url=self._url,
73
78
  )
74
79
 
75
- @api_keys_required("NVIDIA_API_KEY")
76
80
  def run(
77
81
  self,
78
82
  messages: List[OpenAIMessage],
@@ -52,6 +52,11 @@ class OpenAIModel(BaseModelBackend):
52
52
  be used. (default: :obj:`None`)
53
53
  """
54
54
 
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", "OPENAI_API_KEY"),
58
+ ]
59
+ )
55
60
  def __init__(
56
61
  self,
57
62
  model_type: Union[ModelType, str],
@@ -86,7 +91,6 @@ class OpenAIModel(BaseModelBackend):
86
91
  self._token_counter = OpenAITokenCounter(self.model_type)
87
92
  return self._token_counter
88
93
 
89
- @api_keys_required("OPENAI_API_KEY")
90
94
  def run(
91
95
  self,
92
96
  messages: List[OpenAIMessage],
@@ -52,6 +52,11 @@ class QwenModel(BaseModelBackend):
52
52
  (default: :obj:`None`)
53
53
  """
54
54
 
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", "QWEN_API_KEY"),
58
+ ]
59
+ )
55
60
  def __init__(
56
61
  self,
57
62
  model_type: Union[ModelType, str],
@@ -77,7 +82,6 @@ class QwenModel(BaseModelBackend):
77
82
  base_url=self._url,
78
83
  )
79
84
 
80
- @api_keys_required("QWEN_API_KEY")
81
85
  def run(
82
86
  self,
83
87
  messages: List[OpenAIMessage],
@@ -56,6 +56,11 @@ class RekaModel(BaseModelBackend):
56
56
  be used. (default: :obj:`None`)
57
57
  """
58
58
 
59
+ @api_keys_required(
60
+ [
61
+ ("api_key", "REKA_API_KEY"),
62
+ ]
63
+ )
59
64
  @dependencies_required('reka')
60
65
  def __init__(
61
66
  self,
@@ -168,7 +173,6 @@ class RekaModel(BaseModelBackend):
168
173
  )
169
174
  return self._token_counter
170
175
 
171
- @api_keys_required("REKA_API_KEY")
172
176
  def run(
173
177
  self,
174
178
  messages: List[OpenAIMessage],
@@ -14,9 +14,11 @@
14
14
  from .base_reward_model import BaseRewardModel
15
15
  from .evaluator import Evaluator
16
16
  from .nemotron_model import NemotronRewardModel
17
+ from .skywork_model import SkyworkRewardModel
17
18
 
18
19
  __all__ = [
19
20
  'BaseRewardModel',
20
21
  'NemotronRewardModel',
21
22
  'Evaluator',
23
+ 'SkyworkRewardModel',
22
24
  ]
@@ -53,7 +53,11 @@ class NemotronRewardModel(BaseRewardModel):
53
53
  api_key=self.api_key,
54
54
  )
55
55
 
56
- @api_keys_required("NVIDIA_API_KEY")
56
+ @api_keys_required(
57
+ [
58
+ (None, "NVIDIA_API_KEY"),
59
+ ]
60
+ )
57
61
  def evaluate(self, messages: List[Dict[str, str]]) -> Dict[str, float]:
58
62
  r"""Evaluate the messages using the Nemotron model.
59
63
 
@@ -0,0 +1,88 @@
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
+ from typing import Dict, List, Optional, Union
15
+
16
+ import torch
17
+
18
+ from camel.models.reward import BaseRewardModel
19
+ from camel.types import ModelType
20
+
21
+
22
+ class SkyworkRewardModel(BaseRewardModel):
23
+ r"""Reward model based on the transformers, it will download the model
24
+ from huggingface.
25
+
26
+ Args:
27
+ model_type (Union[ModelType, str]): Model for which a backend is
28
+ created.
29
+ api_key (Optional[str], optional): Not used. (default: :obj:`None`)
30
+ url (Optional[str], optional): Not used. (default: :obj:`None`)
31
+ device_map (Optional[str], optional): choose the device map.
32
+ (default: :obj:`auto`)
33
+ attn_implementation (Optional[str], optional): choose the attention
34
+ implementation. (default: :obj:`flash_attention_2`)
35
+ offload_folder (Optional[str], optional): choose the offload folder.
36
+ (default: :obj:`offload`)
37
+ """
38
+
39
+ def __init__(
40
+ self,
41
+ model_type: Union[ModelType, str],
42
+ api_key: Optional[str] = None,
43
+ url: Optional[str] = None,
44
+ device_map: Optional[str] = "auto",
45
+ attn_implementation: Optional[str] = "flash_attention_2",
46
+ offload_folder: Optional[str] = "offload",
47
+ ) -> None:
48
+ from transformers import (
49
+ AutoModelForSequenceClassification,
50
+ AutoTokenizer,
51
+ )
52
+
53
+ super().__init__(model_type, api_key, url)
54
+ self._client = AutoModelForSequenceClassification.from_pretrained(
55
+ model_type,
56
+ torch_dtype=torch.bfloat16,
57
+ device_map=device_map,
58
+ attn_implementation=attn_implementation,
59
+ offload_folder=offload_folder,
60
+ num_labels=1,
61
+ )
62
+ self._tokenizer = AutoTokenizer.from_pretrained(model_type)
63
+
64
+ def evaluate(self, messages: List[Dict[str, str]]) -> Dict[str, float]:
65
+ r"""Evaluate the messages using the Skywork model.
66
+
67
+ Args:
68
+ messages (List[Dict[str, str]]): A list of messages.
69
+
70
+ Returns:
71
+ ChatCompletion: A ChatCompletion object with the scores.
72
+ """
73
+ inputs = self._tokenizer.apply_chat_template(
74
+ messages,
75
+ tokenize=True,
76
+ return_tensors="pt",
77
+ )
78
+ with torch.no_grad():
79
+ score = self._client(inputs).logits[0][0].item()
80
+ return {"Score": score}
81
+
82
+ def get_scores_types(self) -> List[str]:
83
+ r"""get the scores types
84
+
85
+ Returns:
86
+ List[str]: list of scores types
87
+ """
88
+ return ["Score"]
@@ -74,6 +74,11 @@ class SambaModel(BaseModelBackend):
74
74
  ModelType.GPT_4O_MINI)` will be used.
75
75
  """
76
76
 
77
+ @api_keys_required(
78
+ [
79
+ ("api_key", 'SAMBA_API_KEY'),
80
+ ]
81
+ )
77
82
  def __init__(
78
83
  self,
79
84
  model_type: Union[ModelType, str],
@@ -143,7 +148,6 @@ class SambaModel(BaseModelBackend):
143
148
  " SambaNova service"
144
149
  )
145
150
 
146
- @api_keys_required("SAMBA_API_KEY")
147
151
  def run( # type: ignore[misc]
148
152
  self, messages: List[OpenAIMessage]
149
153
  ) -> Union[ChatCompletion, Stream[ChatCompletionChunk]]:
@@ -53,6 +53,11 @@ class TogetherAIModel(BaseModelBackend):
53
53
  ModelType.GPT_4O_MINI)` will be used.
54
54
  """
55
55
 
56
+ @api_keys_required(
57
+ [
58
+ ("api_key", 'TOGETHER_API_KEY'),
59
+ ]
60
+ )
56
61
  def __init__(
57
62
  self,
58
63
  model_type: Union[ModelType, str],
@@ -78,7 +83,6 @@ class TogetherAIModel(BaseModelBackend):
78
83
  base_url=self._url,
79
84
  )
80
85
 
81
- @api_keys_required("TOGETHER_API_KEY")
82
86
  def run(
83
87
  self,
84
88
  messages: List[OpenAIMessage],
camel/models/yi_model.py CHANGED
@@ -52,6 +52,11 @@ class YiModel(BaseModelBackend):
52
52
  (default: :obj:`None`)
53
53
  """
54
54
 
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", 'YI_API_KEY'),
58
+ ]
59
+ )
55
60
  def __init__(
56
61
  self,
57
62
  model_type: Union[ModelType, str],
@@ -76,7 +81,6 @@ class YiModel(BaseModelBackend):
76
81
  base_url=self._url,
77
82
  )
78
83
 
79
- @api_keys_required("YI_API_KEY")
80
84
  def run(
81
85
  self,
82
86
  messages: List[OpenAIMessage],
@@ -52,6 +52,11 @@ class ZhipuAIModel(BaseModelBackend):
52
52
  (default: :obj:`None`)
53
53
  """
54
54
 
55
+ @api_keys_required(
56
+ [
57
+ ("api_key", 'ZHIPUAI_API_KEY'),
58
+ ]
59
+ )
55
60
  def __init__(
56
61
  self,
57
62
  model_type: Union[ModelType, str],
@@ -76,7 +81,6 @@ class ZhipuAIModel(BaseModelBackend):
76
81
  base_url=self._url,
77
82
  )
78
83
 
79
- @api_keys_required("ZHIPUAI_API_KEY")
80
84
  def run(
81
85
  self,
82
86
  messages: List[OpenAIMessage],
@@ -53,6 +53,11 @@ class OpenAISchemaConverter(BaseConverter):
53
53
 
54
54
  """
55
55
 
56
+ @api_keys_required(
57
+ [
58
+ ("api_key", "OPENAI_API_KEY"),
59
+ ]
60
+ )
56
61
  def __init__(
57
62
  self,
58
63
  model_type: ModelType = ModelType.GPT_4O_MINI,
@@ -69,7 +74,6 @@ class OpenAISchemaConverter(BaseConverter):
69
74
  )._client
70
75
  super().__init__()
71
76
 
72
- @api_keys_required("OPENAI_API_KEY")
73
77
  def convert( # type: ignore[override]
74
78
  self,
75
79
  content: str,