camel-ai 0.2.18__py3-none-any.whl → 0.2.20__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 (53) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +29 -30
  3. camel/agents/knowledge_graph_agent.py +1 -5
  4. camel/agents/multi_hop_generator_agent.py +35 -3
  5. camel/agents/programmed_agent_instruction.py +73 -18
  6. camel/benchmarks/apibench.py +1 -5
  7. camel/benchmarks/nexus.py +1 -5
  8. camel/benchmarks/ragbench.py +2 -2
  9. camel/bots/telegram_bot.py +1 -5
  10. camel/configs/__init__.py +9 -0
  11. camel/configs/aiml_config.py +80 -0
  12. camel/configs/gemini_config.py +1 -1
  13. camel/configs/moonshot_config.py +63 -0
  14. camel/configs/sglang_config.py +4 -0
  15. camel/configs/siliconflow_config.py +91 -0
  16. camel/datagen/__init__.py +3 -1
  17. camel/datagen/self_improving_cot.py +821 -0
  18. camel/datagen/source2synth/__init__.py +31 -0
  19. camel/{synthetic_datagen → datagen}/source2synth/data_processor.py +194 -29
  20. camel/{synthetic_datagen → datagen}/source2synth/models.py +25 -0
  21. camel/{synthetic_datagen → datagen}/source2synth/user_data_processor_config.py +9 -8
  22. camel/datahubs/huggingface.py +3 -3
  23. camel/embeddings/__init__.py +2 -0
  24. camel/embeddings/jina_embedding.py +161 -0
  25. camel/messages/func_message.py +1 -1
  26. camel/models/__init__.py +4 -0
  27. camel/models/aiml_model.py +147 -0
  28. camel/models/deepseek_model.py +29 -11
  29. camel/models/groq_model.py +0 -2
  30. camel/models/model_factory.py +9 -0
  31. camel/models/moonshot_model.py +138 -0
  32. camel/models/openai_model.py +1 -9
  33. camel/models/siliconflow_model.py +142 -0
  34. camel/societies/workforce/role_playing_worker.py +2 -4
  35. camel/societies/workforce/single_agent_worker.py +1 -6
  36. camel/societies/workforce/workforce.py +3 -9
  37. camel/toolkits/__init__.py +4 -0
  38. camel/toolkits/reddit_toolkit.py +8 -38
  39. camel/toolkits/search_toolkit.py +17 -6
  40. camel/toolkits/semantic_scholar_toolkit.py +308 -0
  41. camel/toolkits/sympy_toolkit.py +778 -0
  42. camel/toolkits/whatsapp_toolkit.py +11 -32
  43. camel/types/enums.py +205 -16
  44. camel/types/unified_model_type.py +5 -0
  45. camel/utils/__init__.py +7 -2
  46. camel/utils/commons.py +198 -21
  47. camel/utils/deduplication.py +199 -0
  48. camel/utils/token_counting.py +1 -39
  49. {camel_ai-0.2.18.dist-info → camel_ai-0.2.20.dist-info}/METADATA +17 -12
  50. {camel_ai-0.2.18.dist-info → camel_ai-0.2.20.dist-info}/RECORD +53 -41
  51. /camel/datagen/{cotdatagen.py → cot_datagen.py} +0 -0
  52. {camel_ai-0.2.18.dist-info → camel_ai-0.2.20.dist-info}/LICENSE +0 -0
  53. {camel_ai-0.2.18.dist-info → camel_ai-0.2.20.dist-info}/WHEEL +0 -0
@@ -0,0 +1,63 @@
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
+ from typing import List, Optional, Union
16
+
17
+ from camel.configs.base_config import BaseConfig
18
+
19
+
20
+ class MoonshotConfig(BaseConfig):
21
+ r"""Defines the parameters for generating chat completions using the
22
+ Moonshot API. You can refer to the following link for more details:
23
+ https://platform.moonshot.cn/docs/api-reference
24
+
25
+ Args:
26
+ temperature (float, optional): Controls randomness in the response.
27
+ Lower values make the output more focused and deterministic.
28
+ (default: :obj:`0.3`)
29
+ max_tokens (int, optional): The maximum number of tokens to generate.
30
+ (default: :obj:`None`)
31
+ stream (bool, optional): Whether to stream the response.
32
+ (default: :obj:`False`)
33
+ tools (list, optional): List of tools that the model can use for
34
+ function calling. Each tool should be a dictionary containing
35
+ type, function name, description, and parameters.
36
+ (default: :obj:`None`)
37
+ top_p (float, optional): Controls diversity via nucleus sampling.
38
+ (default: :obj:`1.0`)
39
+ n (int, optional): How many chat completion choices to generate for
40
+ each input message. (default: :obj:`1`)
41
+ presence_penalty (float, optional): Penalty for new tokens based on
42
+ whether they appear in the text so far.
43
+ (default: :obj:`0.0`)
44
+ frequency_penalty (float, optional): Penalty for new tokens based on
45
+ their frequency in the text so far.
46
+ (default: :obj:`0.0`)
47
+ stop (Optional[Union[str, List[str]]], optional): Up to 4 sequences
48
+ where the API will stop generating further tokens.
49
+ (default: :obj:`None`)
50
+ """
51
+
52
+ temperature: float = 0.3
53
+ max_tokens: Optional[int] = None
54
+ stream: bool = False
55
+ tools: Optional[list] = None
56
+ top_p: float = 1.0
57
+ n: int = 1
58
+ presence_penalty: float = 0.0
59
+ frequency_penalty: float = 0.0
60
+ stop: Optional[Union[str, List[str]]] = None
61
+
62
+
63
+ MOONSHOT_API_PARAMS = {param for param in MoonshotConfig.model_fields.keys()}
@@ -56,6 +56,10 @@ class SGLangConfig(BaseConfig):
56
56
  in the chat completion. The total length of input tokens and
57
57
  generated tokens is limited by the model's context length.
58
58
  (default: :obj:`None`)
59
+ tools (list[FunctionTool], optional): A list of tools the model may
60
+ call. Currently, only functions are supported as a tool. Use this
61
+ to provide a list of functions the model may generate JSON inputs
62
+ for. A max of 128 functions are supported.
59
63
  """
60
64
 
61
65
  stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
@@ -0,0 +1,91 @@
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 __future__ import annotations
15
+
16
+ from typing import Any, Sequence, Type, Union
17
+
18
+ from pydantic import BaseModel
19
+
20
+ from camel.configs.base_config import BaseConfig
21
+ from camel.types import NOT_GIVEN, NotGiven
22
+
23
+
24
+ class SiliconFlowConfig(BaseConfig):
25
+ r"""Defines the parameters for generating chat completions using the
26
+ SiliconFlow API.
27
+
28
+ Args:
29
+ temperature (float, optional): Determines the degree of randomness
30
+ in the response. (default: :obj:`0.7`)
31
+ top_p (float, optional): The top_p (nucleus) parameter is used to
32
+ dynamically adjust the number of choices for each predicted token
33
+ based on the cumulative probabilities. (default: :obj:`0.7`)
34
+ n (int, optional): Number of generations to return. (default::obj:`1`)
35
+ response_format (object, optional): An object specifying the format
36
+ that the model must output.
37
+ stream (bool, optional): If set, tokens are returned as Server-Sent
38
+ Events as they are made available. (default: :obj:`False`)
39
+ stop (str or list, optional): Up to :obj:`4` sequences where the API
40
+ will stop generating further tokens. (default: :obj:`None`)
41
+ max_tokens (int, optional): The maximum number of tokens to generate.
42
+ (default: :obj:`None`)
43
+ frequency_penalty (float, optional): Number between :obj:`-2.0` and
44
+ :obj:`2.0`. Positive values penalize new tokens based on their
45
+ existing frequency in the text so far, decreasing the model's
46
+ likelihood to repeat the same line verbatim. See more information
47
+ about frequency and presence penalties. (default: :obj:`0.0`)
48
+ tools (list[FunctionTool], optional): A list of tools the model may
49
+ call. Currently, only functions are supported as a tool. Use this
50
+ to provide a list of functions the model may generate JSON inputs
51
+ for. A max of 128 functions are supported.
52
+ """
53
+
54
+ temperature: float = 0.7
55
+ top_p: float = 0.7
56
+ n: int = 1
57
+ stream: bool = False
58
+ stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
59
+ max_tokens: Union[int, NotGiven] = NOT_GIVEN
60
+ response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
61
+ frequency_penalty: float = 0.0
62
+
63
+ def as_dict(self) -> dict[str, Any]:
64
+ r"""Convert the current configuration to a dictionary.
65
+
66
+ This method converts the current configuration object to a dictionary
67
+ representation, which can be used for serialization or other purposes.
68
+
69
+ Returns:
70
+ dict[str, Any]: A dictionary representation of the current
71
+ configuration.
72
+ """
73
+ config_dict = self.model_dump()
74
+ if self.tools:
75
+ from camel.toolkits import FunctionTool
76
+
77
+ tools_schema = []
78
+ for tool in self.tools:
79
+ if not isinstance(tool, FunctionTool):
80
+ raise ValueError(
81
+ f"The tool {tool} should "
82
+ "be an instance of `FunctionTool`."
83
+ )
84
+ tools_schema.append(tool.get_openai_tool_schema())
85
+ config_dict["tools"] = NOT_GIVEN
86
+ return config_dict
87
+
88
+
89
+ SILICONFLOW_API_PARAMS = {
90
+ param for param in SiliconFlowConfig.model_fields.keys()
91
+ }
camel/datagen/__init__.py CHANGED
@@ -12,10 +12,12 @@
12
12
  # limitations under the License.
13
13
  # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
 
15
- from .cotdatagen import CoTDataGenerator
15
+ from .cot_datagen import CoTDataGenerator
16
+ from .self_improving_cot import SelfImprovingCoTPipeline
16
17
  from .self_instruct import SelfInstructPipeline
17
18
 
18
19
  __all__ = [
19
20
  "CoTDataGenerator",
20
21
  "SelfInstructPipeline",
22
+ "SelfImprovingCoTPipeline",
21
23
  ]