camel-ai 0.2.9__py3-none-any.whl → 0.2.11__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 (242) hide show
  1. camel/__init__.py +10 -5
  2. camel/agents/__init__.py +4 -4
  3. camel/agents/base.py +4 -4
  4. camel/agents/chat_agent.py +106 -42
  5. camel/agents/critic_agent.py +4 -4
  6. camel/agents/deductive_reasoner_agent.py +8 -5
  7. camel/agents/embodied_agent.py +4 -4
  8. camel/agents/knowledge_graph_agent.py +4 -4
  9. camel/agents/role_assignment_agent.py +4 -4
  10. camel/agents/search_agent.py +4 -4
  11. camel/agents/task_agent.py +4 -4
  12. camel/agents/tool_agents/__init__.py +4 -4
  13. camel/agents/tool_agents/base.py +4 -4
  14. camel/agents/tool_agents/hugging_face_tool_agent.py +4 -4
  15. camel/bots/__init__.py +4 -4
  16. camel/bots/discord_app.py +4 -4
  17. camel/bots/slack/__init__.py +4 -4
  18. camel/bots/slack/models.py +4 -4
  19. camel/bots/slack/slack_app.py +4 -4
  20. camel/bots/telegram_bot.py +4 -4
  21. camel/configs/__init__.py +13 -4
  22. camel/configs/anthropic_config.py +4 -4
  23. camel/configs/base_config.py +4 -4
  24. camel/configs/cohere_config.py +76 -0
  25. camel/configs/deepseek_config.py +134 -0
  26. camel/configs/gemini_config.py +85 -127
  27. camel/configs/groq_config.py +4 -4
  28. camel/configs/litellm_config.py +4 -4
  29. camel/configs/mistral_config.py +4 -7
  30. camel/configs/nvidia_config.py +70 -0
  31. camel/configs/ollama_config.py +4 -4
  32. camel/configs/openai_config.py +32 -7
  33. camel/configs/qwen_config.py +4 -4
  34. camel/configs/reka_config.py +4 -4
  35. camel/configs/samba_config.py +4 -4
  36. camel/configs/togetherai_config.py +4 -4
  37. camel/configs/vllm_config.py +14 -5
  38. camel/configs/yi_config.py +4 -4
  39. camel/configs/zhipuai_config.py +4 -4
  40. camel/embeddings/__init__.py +6 -4
  41. camel/embeddings/base.py +4 -4
  42. camel/embeddings/mistral_embedding.py +4 -4
  43. camel/embeddings/openai_compatible_embedding.py +91 -0
  44. camel/embeddings/openai_embedding.py +4 -4
  45. camel/embeddings/sentence_transformers_embeddings.py +4 -4
  46. camel/embeddings/vlm_embedding.py +8 -5
  47. camel/generators.py +4 -4
  48. camel/human.py +4 -4
  49. camel/interpreters/__init__.py +4 -4
  50. camel/interpreters/base.py +4 -4
  51. camel/interpreters/docker_interpreter.py +11 -6
  52. camel/interpreters/internal_python_interpreter.py +4 -4
  53. camel/interpreters/interpreter_error.py +4 -4
  54. camel/interpreters/ipython_interpreter.py +4 -4
  55. camel/interpreters/subprocess_interpreter.py +11 -6
  56. camel/loaders/__init__.py +4 -4
  57. camel/loaders/apify_reader.py +4 -4
  58. camel/loaders/base_io.py +4 -4
  59. camel/loaders/chunkr_reader.py +4 -4
  60. camel/loaders/firecrawl_reader.py +4 -7
  61. camel/loaders/jina_url_reader.py +4 -4
  62. camel/loaders/unstructured_io.py +4 -4
  63. camel/logger.py +112 -0
  64. camel/memories/__init__.py +4 -4
  65. camel/memories/agent_memories.py +4 -4
  66. camel/memories/base.py +4 -4
  67. camel/memories/blocks/__init__.py +4 -4
  68. camel/memories/blocks/chat_history_block.py +4 -4
  69. camel/memories/blocks/vectordb_block.py +4 -4
  70. camel/memories/context_creators/__init__.py +4 -4
  71. camel/memories/context_creators/score_based.py +4 -4
  72. camel/memories/records.py +4 -4
  73. camel/messages/__init__.py +20 -4
  74. camel/messages/base.py +118 -11
  75. camel/messages/conversion/__init__.py +31 -0
  76. camel/messages/conversion/alpaca.py +122 -0
  77. camel/messages/conversion/conversation_models.py +178 -0
  78. camel/messages/conversion/sharegpt/__init__.py +20 -0
  79. camel/messages/conversion/sharegpt/function_call_formatter.py +49 -0
  80. camel/messages/conversion/sharegpt/hermes/__init__.py +19 -0
  81. camel/messages/conversion/sharegpt/hermes/hermes_function_formatter.py +128 -0
  82. camel/messages/func_message.py +50 -4
  83. camel/models/__init__.py +13 -4
  84. camel/models/anthropic_model.py +4 -4
  85. camel/models/azure_openai_model.py +4 -4
  86. camel/models/base_model.py +4 -4
  87. camel/models/cohere_model.py +282 -0
  88. camel/models/deepseek_model.py +139 -0
  89. camel/models/gemini_model.py +61 -146
  90. camel/models/groq_model.py +4 -4
  91. camel/models/litellm_model.py +4 -4
  92. camel/models/mistral_model.py +4 -4
  93. camel/models/model_factory.py +13 -4
  94. camel/models/model_manager.py +212 -0
  95. camel/models/nemotron_model.py +4 -4
  96. camel/models/nvidia_model.py +141 -0
  97. camel/models/ollama_model.py +4 -4
  98. camel/models/openai_audio_models.py +4 -4
  99. camel/models/openai_compatible_model.py +4 -4
  100. camel/models/openai_model.py +43 -4
  101. camel/models/qwen_model.py +4 -4
  102. camel/models/reka_model.py +4 -4
  103. camel/models/samba_model.py +6 -5
  104. camel/models/stub_model.py +4 -4
  105. camel/models/togetherai_model.py +4 -4
  106. camel/models/vllm_model.py +4 -4
  107. camel/models/yi_model.py +4 -4
  108. camel/models/zhipuai_model.py +4 -4
  109. camel/personas/__init__.py +17 -0
  110. camel/personas/persona.py +103 -0
  111. camel/personas/persona_hub.py +293 -0
  112. camel/prompts/__init__.py +6 -4
  113. camel/prompts/ai_society.py +4 -4
  114. camel/prompts/base.py +4 -4
  115. camel/prompts/code.py +4 -4
  116. camel/prompts/evaluation.py +4 -4
  117. camel/prompts/generate_text_embedding_data.py +4 -4
  118. camel/prompts/image_craft.py +4 -4
  119. camel/prompts/misalignment.py +4 -4
  120. camel/prompts/multi_condition_image_craft.py +4 -4
  121. camel/prompts/object_recognition.py +4 -4
  122. camel/prompts/persona_hub.py +61 -0
  123. camel/prompts/prompt_templates.py +4 -4
  124. camel/prompts/role_description_prompt_template.py +4 -4
  125. camel/prompts/solution_extraction.py +4 -4
  126. camel/prompts/task_prompt_template.py +4 -4
  127. camel/prompts/translation.py +4 -4
  128. camel/prompts/video_description_prompt.py +4 -4
  129. camel/responses/__init__.py +4 -4
  130. camel/responses/agent_responses.py +4 -4
  131. camel/retrievers/__init__.py +4 -4
  132. camel/retrievers/auto_retriever.py +4 -4
  133. camel/retrievers/base.py +4 -4
  134. camel/retrievers/bm25_retriever.py +4 -4
  135. camel/retrievers/cohere_rerank_retriever.py +7 -9
  136. camel/retrievers/vector_retriever.py +26 -9
  137. camel/runtime/__init__.py +29 -0
  138. camel/runtime/api.py +93 -0
  139. camel/runtime/base.py +45 -0
  140. camel/runtime/configs.py +56 -0
  141. camel/runtime/docker_runtime.py +404 -0
  142. camel/runtime/llm_guard_runtime.py +199 -0
  143. camel/runtime/remote_http_runtime.py +204 -0
  144. camel/runtime/utils/__init__.py +20 -0
  145. camel/runtime/utils/function_risk_toolkit.py +58 -0
  146. camel/runtime/utils/ignore_risk_toolkit.py +72 -0
  147. camel/schemas/__init__.py +17 -0
  148. camel/schemas/base.py +45 -0
  149. camel/schemas/openai_converter.py +116 -0
  150. camel/societies/__init__.py +4 -4
  151. camel/societies/babyagi_playing.py +8 -5
  152. camel/societies/role_playing.py +4 -4
  153. camel/societies/workforce/__init__.py +4 -4
  154. camel/societies/workforce/base.py +4 -4
  155. camel/societies/workforce/prompts.py +4 -4
  156. camel/societies/workforce/role_playing_worker.py +4 -4
  157. camel/societies/workforce/single_agent_worker.py +4 -4
  158. camel/societies/workforce/task_channel.py +4 -4
  159. camel/societies/workforce/utils.py +4 -4
  160. camel/societies/workforce/worker.py +4 -4
  161. camel/societies/workforce/workforce.py +7 -7
  162. camel/storages/__init__.py +4 -4
  163. camel/storages/graph_storages/__init__.py +4 -4
  164. camel/storages/graph_storages/base.py +4 -4
  165. camel/storages/graph_storages/graph_element.py +4 -4
  166. camel/storages/graph_storages/nebula_graph.py +4 -4
  167. camel/storages/graph_storages/neo4j_graph.py +4 -4
  168. camel/storages/key_value_storages/__init__.py +4 -4
  169. camel/storages/key_value_storages/base.py +4 -4
  170. camel/storages/key_value_storages/in_memory.py +4 -4
  171. camel/storages/key_value_storages/json.py +4 -4
  172. camel/storages/key_value_storages/redis.py +4 -4
  173. camel/storages/object_storages/__init__.py +4 -4
  174. camel/storages/object_storages/amazon_s3.py +4 -4
  175. camel/storages/object_storages/azure_blob.py +4 -4
  176. camel/storages/object_storages/base.py +4 -4
  177. camel/storages/object_storages/google_cloud.py +4 -4
  178. camel/storages/vectordb_storages/__init__.py +4 -4
  179. camel/storages/vectordb_storages/base.py +4 -4
  180. camel/storages/vectordb_storages/milvus.py +4 -4
  181. camel/storages/vectordb_storages/qdrant.py +4 -4
  182. camel/tasks/__init__.py +4 -4
  183. camel/tasks/task.py +4 -4
  184. camel/tasks/task_prompt.py +4 -4
  185. camel/terminators/__init__.py +4 -4
  186. camel/terminators/base.py +4 -4
  187. camel/terminators/response_terminator.py +4 -4
  188. camel/terminators/token_limit_terminator.py +4 -4
  189. camel/toolkits/__init__.py +16 -17
  190. camel/toolkits/arxiv_toolkit.py +4 -4
  191. camel/toolkits/ask_news_toolkit.py +7 -18
  192. camel/toolkits/base.py +4 -4
  193. camel/toolkits/code_execution.py +57 -10
  194. camel/toolkits/dalle_toolkit.py +4 -7
  195. camel/toolkits/data_commons_toolkit.py +4 -4
  196. camel/toolkits/function_tool.py +220 -69
  197. camel/toolkits/github_toolkit.py +4 -4
  198. camel/toolkits/google_maps_toolkit.py +4 -4
  199. camel/toolkits/google_scholar_toolkit.py +4 -4
  200. camel/toolkits/human_toolkit.py +53 -0
  201. camel/toolkits/linkedin_toolkit.py +4 -4
  202. camel/toolkits/math_toolkit.py +4 -7
  203. camel/toolkits/meshy_toolkit.py +185 -0
  204. camel/toolkits/notion_toolkit.py +4 -4
  205. camel/toolkits/open_api_specs/biztoc/__init__.py +4 -4
  206. camel/toolkits/open_api_specs/coursera/__init__.py +4 -4
  207. camel/toolkits/open_api_specs/create_qr_code/__init__.py +4 -4
  208. camel/toolkits/open_api_specs/klarna/__init__.py +4 -4
  209. camel/toolkits/open_api_specs/nasa_apod/__init__.py +4 -4
  210. camel/toolkits/open_api_specs/outschool/__init__.py +4 -4
  211. camel/toolkits/open_api_specs/outschool/paths/__init__.py +4 -4
  212. camel/toolkits/open_api_specs/outschool/paths/get_classes.py +4 -4
  213. camel/toolkits/open_api_specs/outschool/paths/search_teachers.py +4 -4
  214. camel/toolkits/open_api_specs/security_config.py +4 -4
  215. camel/toolkits/open_api_specs/speak/__init__.py +4 -4
  216. camel/toolkits/open_api_specs/web_scraper/__init__.py +4 -4
  217. camel/toolkits/open_api_specs/web_scraper/paths/__init__.py +4 -4
  218. camel/toolkits/open_api_specs/web_scraper/paths/scraper.py +4 -4
  219. camel/toolkits/open_api_toolkit.py +4 -4
  220. camel/toolkits/reddit_toolkit.py +4 -4
  221. camel/toolkits/retrieval_toolkit.py +4 -4
  222. camel/toolkits/search_toolkit.py +49 -29
  223. camel/toolkits/slack_toolkit.py +4 -4
  224. camel/toolkits/twitter_toolkit.py +13 -13
  225. camel/toolkits/video_toolkit.py +211 -0
  226. camel/toolkits/weather_toolkit.py +4 -7
  227. camel/toolkits/whatsapp_toolkit.py +6 -6
  228. camel/types/__init__.py +6 -4
  229. camel/types/enums.py +118 -15
  230. camel/types/openai_types.py +6 -4
  231. camel/types/unified_model_type.py +9 -4
  232. camel/utils/__init__.py +35 -33
  233. camel/utils/async_func.py +4 -4
  234. camel/utils/commons.py +26 -9
  235. camel/utils/constants.py +4 -4
  236. camel/utils/response_format.py +63 -0
  237. camel/utils/token_counting.py +8 -5
  238. {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/METADATA +108 -56
  239. camel_ai-0.2.11.dist-info/RECORD +252 -0
  240. camel_ai-0.2.9.dist-info/RECORD +0 -215
  241. {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/LICENSE +0 -0
  242. {camel_ai-0.2.9.dist-info → camel_ai-0.2.11.dist-info}/WHEEL +0 -0
@@ -1,156 +1,114 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
 
15
+ from __future__ import annotations
15
16
 
16
- from collections.abc import Iterable
17
- from typing import Any, Optional
17
+ from typing import Any, Optional, Sequence, Type, Union
18
18
 
19
- from pydantic import model_validator
19
+ from pydantic import BaseModel
20
20
 
21
21
  from camel.configs.base_config import BaseConfig
22
+ from camel.types import NOT_GIVEN, NotGiven
22
23
 
23
24
 
24
25
  class GeminiConfig(BaseConfig):
25
- r"""A simple dataclass used to configure the generation parameters of
26
- `GenerativeModel.generate_content`.
26
+ r"""Defines the parameters for generating chat completions using the
27
+ Gemini API.
27
28
 
28
29
  Args:
29
- candidate_count (int, optional): Number of responses to return.
30
- stop_sequences (Iterable[str], optional): The set of character
31
- sequences (up to 5) that will stop output generation. If specified
32
- the API will stop at the first appearance of a stop sequence.
33
- The stop sequence will not be included as part of the response.
34
- max_output_tokens (int, optional): The maximum number of tokens to
35
- include in a candidate. If unset, this will default to
36
- output_token_limit specified in the model's specification.
37
- temperature (float, optional): Controls the randomness of the output.
38
- Note: The default value varies by model, see the
39
- `Model.temperature` attribute of the `Model` returned
40
- the `genai.get_model` function. Values can range from [0.0,1.0],
41
- inclusive. A value closer to 1.0 will produce responses that are
42
- more varied and creative, while a value closer to 0.0 will
43
- typically result in more straightforward responses from the model.
44
- top_p (int, optional): The maximum cumulative probability of tokens to
45
- consider when sampling. The model uses combined Top-k and nucleus
46
- sampling. Tokens are sorted based on their assigned probabilities
47
- so that only the most likely tokens are considered. Top-k sampling
48
- directly limits the maximum number of tokens to consider, while
49
- Nucleus sampling limits number of tokens
50
- based on the cumulative probability. Note: The default value varies
51
- by model, see the `Model.top_p` attribute of the `Model` returned
52
- the `genai.get_model` function.
53
- top_k (int, optional): The maximum number of tokens to consider when
54
- sampling. The model uses combined Top-k and nucleus sampling.Top-k
55
- sampling considers the set of `top_k` most probable tokens.
56
- Defaults to 40. Note: The default value varies by model, see the
57
- `Model.top_k` attribute of the `Model` returned the
58
- `genai.get_model` function.
59
- response_mime_type (str, optional): Output response mimetype of the
60
- generated candidate text. Supported mimetype:
61
- `text/plain`: (default) Text output.
62
- `application/json`: JSON response in the candidates.
63
- response_schema (Schema, optional): Specifies the format of the
64
- JSON requested if response_mime_type is `application/json`.
65
- safety_settings (SafetySettingOptions, optional):
66
- Overrides for the model's safety settings.
67
- tools (FunctionLibraryType, optional):
68
- `protos.Tools` more info coming soon.
69
- tool_config (ToolConfigType, optional):
70
- more info coming soon.
71
- request_options (RequestOptionsType, optional):
72
- Options for the request.
30
+ temperature (float, optional): Sampling temperature to use, between
31
+ :obj:`0` and :obj:`2`. Higher values make the output more random,
32
+ while lower values make it more focused and deterministic.
33
+ (default: :obj:`0.2`)
34
+ top_p (float, optional): An alternative to sampling with temperature,
35
+ called nucleus sampling, where the model considers the results of
36
+ the tokens with top_p probability mass. So :obj:`0.1` means only
37
+ the tokens comprising the top 10% probability mass are considered.
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
+ response_format (object, optional): An object specifying the format
42
+ that the model must output. Compatible with GPT-4 Turbo and all
43
+ GPT-3.5 Turbo models newer than gpt-3.5-turbo-1106. Setting to
44
+ {"type": "json_object"} enables JSON mode, which guarantees the
45
+ message the model generates is valid JSON. Important: when using
46
+ JSON mode, you must also instruct the model to produce JSON
47
+ yourself via a system or user message. Without this, the model
48
+ may generate an unending stream of whitespace until the generation
49
+ reaches the token limit, resulting in a long-running and seemingly
50
+ "stuck" request. Also note that the message content may be
51
+ partially cut off if finish_reason="length", which indicates the
52
+ generation exceeded max_tokens or the conversation exceeded the
53
+ max context length.
54
+ stream (bool, optional): If True, partial message deltas will be sent
55
+ as data-only server-sent events as they become available.
56
+ (default: :obj:`False`)
57
+ stop (str or list, optional): Up to :obj:`4` sequences where the API
58
+ will stop generating further tokens. (default: :obj:`None`)
59
+ max_tokens (int, optional): The maximum number of tokens to generate
60
+ in the chat completion. The total length of input tokens and
61
+ generated tokens is limited by the model's context length.
62
+ (default: :obj:`None`)
63
+ tools (list[FunctionTool], optional): A list of tools the model may
64
+ call. Currently, only functions are supported as a tool. Use this
65
+ to provide a list of functions the model may generate JSON inputs
66
+ for. A max of 128 functions are supported.
67
+ tool_choice (Union[dict[str, str], str], optional): Controls which (if
68
+ any) tool is called by the model. :obj:`"none"` means the model
69
+ will not call any tool and instead generates a message.
70
+ :obj:`"auto"` means the model can pick between generating a
71
+ message or calling one or more tools. :obj:`"required"` means the
72
+ model must call one or more tools. Specifying a particular tool
73
+ via {"type": "function", "function": {"name": "my_function"}}
74
+ forces the model to call that tool. :obj:`"none"` is the default
75
+ when no tools are present. :obj:`"auto"` is the default if tools
76
+ are present.
73
77
  """
74
78
 
75
- candidate_count: Optional[int] = None
76
- stop_sequences: Optional[Iterable[str]] = None
77
- max_output_tokens: Optional[int] = None
78
- temperature: Optional[float] = None
79
- top_p: Optional[float] = None
80
- top_k: Optional[int] = None
81
- response_mime_type: Optional[str] = None
82
- response_schema: Optional[Any] = None
83
- safety_settings: Optional[Any] = None
84
- tool_config: Optional[Any] = None
85
- request_options: Optional[Any] = None
79
+ temperature: float = 0.2 # openai default: 1.0
80
+ top_p: float = 1.0
81
+ n: int = 1
82
+ stream: bool = False
83
+ stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
84
+ max_tokens: Union[int, NotGiven] = NOT_GIVEN
85
+ response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
86
+ tool_choice: Optional[Union[dict[str, str], str]] = None
86
87
 
87
- @model_validator(mode="before")
88
- @classmethod
89
- def model_type_checking(cls, data: Any):
90
- r"""Validate the type of tools in the configuration.
88
+ def as_dict(self) -> dict[str, Any]:
89
+ r"""Convert the current configuration to a dictionary.
91
90
 
92
- This method ensures that the tools provided in the configuration are
93
- instances of `FunctionTool`. If any tool is not an instance of
94
- `FunctionTool`, it raises a ValueError.
95
- """
96
- if isinstance(data, dict):
97
- response_schema = data.get("response_schema")
98
- safety_settings = data.get("safety_settings")
99
- tools = data.get("tools")
100
- tool_config = data.get("tool_config")
101
- request_options = data.get("request_options")
102
-
103
- if response_schema:
104
- from google.generativeai.protos import Schema
105
- from google.generativeai.types.content_types import (
106
- FunctionLibraryType,
107
- ToolConfigType,
108
- )
109
- from google.generativeai.types.helper_types import (
110
- RequestOptionsType,
111
- )
112
- from google.generativeai.types.safety_types import (
113
- SafetySettingOptions,
114
- )
115
- else:
116
- return data
91
+ This method converts the current configuration object to a dictionary
92
+ representation, which can be used for serialization or other purposes.
117
93
 
118
- if response_schema and not isinstance(response_schema, Schema):
119
- raise ValueError(
120
- "The response_schema should be an instance of "
121
- "google.generativeai.protos.Schema."
122
- )
123
-
124
- if safety_settings and not isinstance(
125
- safety_settings, SafetySettingOptions
126
- ):
127
- raise ValueError(
128
- "The safety_settings should be an instance of "
129
- "google.generativeai.types.safety_types."
130
- "SafetySettingOptions."
131
- )
94
+ Returns:
95
+ dict[str, Any]: A dictionary representation of the current
96
+ configuration.
97
+ """
98
+ config_dict = self.model_dump()
99
+ if self.tools:
100
+ from camel.toolkits import FunctionTool
132
101
 
133
- if tools is not None:
134
- for tool in tools:
135
- if not isinstance(tool, FunctionLibraryType):
102
+ tools_schema = []
103
+ for tool in self.tools:
104
+ if not isinstance(tool, FunctionTool):
136
105
  raise ValueError(
137
- "The tool should be an instance of "
138
- "google.generativeai.types.content_types."
139
- "FunctionLibraryType."
106
+ f"The tool {tool} should "
107
+ "be an instance of `FunctionTool`."
140
108
  )
141
- if tool_config and not isinstance(tool_config, ToolConfigType):
142
- raise ValueError(
143
- "The tool_config should be an instance of "
144
- "google.generativeai.types.content_types.ToolConfigType."
145
- )
146
- if request_options and not isinstance(
147
- request_options, RequestOptionsType
148
- ):
149
- raise ValueError(
150
- "The request_options should be an instance of "
151
- "google.generativeai.types.helper_types.RequestOptionsType."
152
- )
153
- return data
109
+ tools_schema.append(tool.get_openai_tool_schema())
110
+ config_dict["tools"] = NOT_GIVEN
111
+ return config_dict
154
112
 
155
113
 
156
- Gemini_API_PARAMS = {param for param in GeminiConfig().model_fields.keys()}
114
+ Gemini_API_PARAMS = {param for param in GeminiConfig.model_fields.keys()}
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Optional, Sequence, Union
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import List, Optional, Union
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Any, Dict, Optional, Union
@@ -35,8 +35,6 @@ class MistralConfig(BaseConfig):
35
35
  tokens to generate, e.g. 0.9. Defaults to None.
36
36
  max_tokens (Optional[int], optional): the maximum number of tokens to
37
37
  generate, e.g. 100. Defaults to None.
38
- min_tokens (Optional[int], optional): the minimum number of tokens to
39
- generate, e.g. 100. Defaults to None.
40
38
  stop (Optional[Union[str,list[str]]]): Stop generation if this token
41
39
  is detected. Or if one of these tokens is detected when providing
42
40
  a string list.
@@ -58,7 +56,6 @@ class MistralConfig(BaseConfig):
58
56
  temperature: Optional[float] = None
59
57
  top_p: Optional[float] = None
60
58
  max_tokens: Optional[int] = None
61
- min_tokens: Optional[int] = None
62
59
  stop: Optional[Union[str, list[str]]] = None
63
60
  random_seed: Optional[int] = None
64
61
  safe_prompt: bool = False
@@ -0,0 +1,70 @@
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 List, Optional, Union
17
+
18
+ from pydantic import Field
19
+
20
+ from camel.configs.base_config import BaseConfig
21
+ from camel.types import NOT_GIVEN, NotGiven
22
+
23
+
24
+ class NvidiaConfig(BaseConfig):
25
+ r"""Configuration class for NVIDIA API models.
26
+
27
+ This class defines the configuration parameters for NVIDIA's language
28
+ models, including temperature, sampling parameters, and response format
29
+ settings.
30
+
31
+ Args:
32
+ stream (bool, optional): Whether to stream the response.
33
+ (default: :obj:`False`)
34
+ temperature (float, optional): Controls randomness in the response.
35
+ Higher values make output more random, lower values make it more
36
+ deterministic. Range: [0.0, 2.0]. (default: :obj:`0.7`)
37
+ top_p (float, optional): Controls diversity via nucleus sampling.
38
+ Range: [0.0, 1.0]. (default: :obj:`0.95`)
39
+ presence_penalty (float, optional): Penalizes new tokens based on
40
+ whether they appear in the text so far. Range: [-2.0, 2.0].
41
+ (default: :obj:`0.0`)
42
+ frequency_penalty (float, optional): Penalizes new tokens based on
43
+ their frequency in the text so far. Range: [-2.0, 2.0].
44
+ (default: :obj:`0.0`)
45
+ max_tokens (Union[int, NotGiven], optional): Maximum number of tokens
46
+ to generate. If not provided, model will use its default maximum.
47
+ (default: :obj:`NOT_GIVEN`)
48
+ seed (Optional[int], optional): Random seed for deterministic sampling.
49
+ (default: :obj:`None`)
50
+ tools (Optional[List[Dict]], optional): List of tools available to the
51
+ model. This includes tools such as a text editor, a calculator, or
52
+ a search engine. (default: :obj:`None`)
53
+ tool_choice (Optional[str], optional): Tool choice configuration.
54
+ (default: :obj:`None`)
55
+ stop (Optional[List[str]], optional): List of stop sequences.
56
+ (default: :obj:`None`)
57
+ """
58
+
59
+ stream: bool = Field(default=False)
60
+ temperature: float = Field(default=0.7)
61
+ top_p: float = Field(default=0.95)
62
+ presence_penalty: float = Field(default=0.0)
63
+ frequency_penalty: float = Field(default=0.0)
64
+ max_tokens: Union[int, NotGiven] = Field(default=NOT_GIVEN)
65
+ seed: Optional[int] = Field(default=None)
66
+ tool_choice: Optional[str] = Field(default=None)
67
+ stop: Optional[List[str]] = Field(default=None)
68
+
69
+
70
+ NVIDIA_API_PARAMS = {param for param in NvidiaConfig.model_fields.keys()}
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Sequence, Union
@@ -1,21 +1,21 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
- from typing import Optional, Sequence, Union
16
+ from typing import Any, Optional, Sequence, Type, Union
17
17
 
18
- from pydantic import Field
18
+ from pydantic import BaseModel, Field
19
19
 
20
20
  from camel.configs.base_config import BaseConfig
21
21
  from camel.types import NOT_GIVEN, NotGiven
@@ -104,11 +104,36 @@ class ChatGPTConfig(BaseConfig):
104
104
  stop: Union[str, Sequence[str], NotGiven] = NOT_GIVEN
105
105
  max_tokens: Union[int, NotGiven] = NOT_GIVEN
106
106
  presence_penalty: float = 0.0
107
- response_format: Union[dict, NotGiven] = NOT_GIVEN
107
+ response_format: Union[Type[BaseModel], dict, NotGiven] = NOT_GIVEN
108
108
  frequency_penalty: float = 0.0
109
109
  logit_bias: dict = Field(default_factory=dict)
110
110
  user: str = ""
111
111
  tool_choice: Optional[Union[dict[str, str], str]] = None
112
112
 
113
+ def as_dict(self) -> dict[str, Any]:
114
+ r"""Convert the current configuration to a dictionary.
115
+
116
+ This method converts the current configuration object to a dictionary
117
+ representation, which can be used for serialization or other purposes.
118
+
119
+ Returns:
120
+ dict[str, Any]: A dictionary representation of the current
121
+ configuration.
122
+ """
123
+ config_dict = self.model_dump()
124
+ if self.tools:
125
+ from camel.toolkits import FunctionTool
126
+
127
+ tools_schema = []
128
+ for tool in self.tools:
129
+ if not isinstance(tool, FunctionTool):
130
+ raise ValueError(
131
+ f"The tool {tool} should "
132
+ "be an instance of `FunctionTool`."
133
+ )
134
+ tools_schema.append(tool.get_openai_tool_schema())
135
+ config_dict["tools"] = NOT_GIVEN
136
+ return config_dict
137
+
113
138
 
114
139
  OPENAI_API_PARAMS = {param for param in ChatGPTConfig.model_fields.keys()}
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import ClassVar, Optional, Union
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Any, Optional, Union
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Any, Optional, Sequence, Union
@@ -1,16 +1,16 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
16
  from typing import Any, Sequence, Union
@@ -1,19 +1,19 @@
1
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
2
- # Licensed under the Apache License, Version 2.0 (the License);
1
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
3
  # you may not use this file except in compliance with the License.
4
4
  # You may obtain a copy of the License at
5
5
  #
6
6
  # http://www.apache.org/licenses/LICENSE-2.0
7
7
  #
8
8
  # Unless required by applicable law or agreed to in writing, software
9
- # distributed under the License is distributed on an AS IS BASIS,
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
10
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
- # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
13
+ # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
14
14
  from __future__ import annotations
15
15
 
16
- from typing import Sequence, Union
16
+ from typing import Optional, Sequence, Union
17
17
 
18
18
  from pydantic import Field
19
19
 
@@ -84,6 +84,13 @@ class VLLMConfig(BaseConfig):
84
84
  user (str, optional): A unique identifier representing your end-user,
85
85
  which can help OpenAI to monitor and detect abuse.
86
86
  (default: :obj:`""`)
87
+ logprobs: Whether to return log probabilities of the output tokens or
88
+ not. If true, returns the log probabilities of each output token
89
+ returned in the `logits` of `message`. (default: :obj:`None`)
90
+ top_logprobs: An integer between 0 and 20 specifying the number of
91
+ most likely tokens to return at each token position, each with an
92
+ associated log probability. `logprobs` must be set to `true` if
93
+ this parameter is used. (default: :obj:`None`)
87
94
  """
88
95
 
89
96
  temperature: float = 0.2 # openai default: 1.0
@@ -97,6 +104,8 @@ class VLLMConfig(BaseConfig):
97
104
  frequency_penalty: float = 0.0
98
105
  logit_bias: dict = Field(default_factory=dict)
99
106
  user: str = ""
107
+ logprobs: Optional[bool] = None
108
+ top_logprobs: Optional[int] = None
100
109
 
101
110
 
102
111
  VLLM_API_PARAMS = {param for param in VLLMConfig.model_fields.keys()}