camel-ai 0.1.5.6__py3-none-any.whl → 0.1.6.1__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 (133) hide show
  1. camel/__init__.py +1 -1
  2. camel/agents/chat_agent.py +249 -36
  3. camel/agents/critic_agent.py +18 -2
  4. camel/agents/deductive_reasoner_agent.py +16 -4
  5. camel/agents/embodied_agent.py +20 -6
  6. camel/agents/knowledge_graph_agent.py +24 -5
  7. camel/agents/role_assignment_agent.py +13 -1
  8. camel/agents/search_agent.py +16 -5
  9. camel/agents/task_agent.py +20 -5
  10. camel/configs/__init__.py +11 -9
  11. camel/configs/anthropic_config.py +5 -6
  12. camel/configs/base_config.py +50 -4
  13. camel/configs/gemini_config.py +69 -17
  14. camel/configs/groq_config.py +105 -0
  15. camel/configs/litellm_config.py +2 -8
  16. camel/configs/mistral_config.py +78 -0
  17. camel/configs/ollama_config.py +5 -7
  18. camel/configs/openai_config.py +12 -23
  19. camel/configs/vllm_config.py +102 -0
  20. camel/configs/zhipuai_config.py +5 -11
  21. camel/embeddings/__init__.py +2 -0
  22. camel/embeddings/mistral_embedding.py +89 -0
  23. camel/human.py +1 -1
  24. camel/interpreters/__init__.py +2 -0
  25. camel/interpreters/ipython_interpreter.py +167 -0
  26. camel/loaders/__init__.py +2 -0
  27. camel/loaders/firecrawl_reader.py +213 -0
  28. camel/memories/agent_memories.py +1 -4
  29. camel/memories/blocks/chat_history_block.py +6 -2
  30. camel/memories/blocks/vectordb_block.py +3 -1
  31. camel/memories/context_creators/score_based.py +6 -6
  32. camel/memories/records.py +9 -7
  33. camel/messages/base.py +1 -0
  34. camel/models/__init__.py +8 -0
  35. camel/models/anthropic_model.py +7 -2
  36. camel/models/azure_openai_model.py +152 -0
  37. camel/models/base_model.py +9 -2
  38. camel/models/gemini_model.py +14 -2
  39. camel/models/groq_model.py +131 -0
  40. camel/models/litellm_model.py +26 -4
  41. camel/models/mistral_model.py +169 -0
  42. camel/models/model_factory.py +30 -3
  43. camel/models/ollama_model.py +21 -2
  44. camel/models/open_source_model.py +13 -5
  45. camel/models/openai_model.py +7 -2
  46. camel/models/stub_model.py +4 -4
  47. camel/models/vllm_model.py +138 -0
  48. camel/models/zhipuai_model.py +7 -4
  49. camel/prompts/__init__.py +8 -1
  50. camel/prompts/image_craft.py +34 -0
  51. camel/prompts/multi_condition_image_craft.py +34 -0
  52. camel/prompts/task_prompt_template.py +10 -4
  53. camel/prompts/{descripte_video_prompt.py → video_description_prompt.py} +1 -1
  54. camel/responses/agent_responses.py +4 -3
  55. camel/retrievers/auto_retriever.py +2 -2
  56. camel/societies/babyagi_playing.py +6 -4
  57. camel/societies/role_playing.py +16 -8
  58. camel/storages/graph_storages/graph_element.py +10 -14
  59. camel/storages/graph_storages/neo4j_graph.py +5 -0
  60. camel/storages/vectordb_storages/base.py +24 -13
  61. camel/storages/vectordb_storages/milvus.py +1 -1
  62. camel/storages/vectordb_storages/qdrant.py +2 -3
  63. camel/tasks/__init__.py +22 -0
  64. camel/tasks/task.py +408 -0
  65. camel/tasks/task_prompt.py +65 -0
  66. camel/toolkits/__init__.py +39 -0
  67. camel/toolkits/base.py +4 -2
  68. camel/toolkits/code_execution.py +1 -1
  69. camel/toolkits/dalle_toolkit.py +146 -0
  70. camel/toolkits/github_toolkit.py +19 -34
  71. camel/toolkits/google_maps_toolkit.py +368 -0
  72. camel/toolkits/math_toolkit.py +79 -0
  73. camel/toolkits/open_api_toolkit.py +547 -0
  74. camel/{functions → toolkits}/openai_function.py +2 -7
  75. camel/toolkits/retrieval_toolkit.py +76 -0
  76. camel/toolkits/search_toolkit.py +326 -0
  77. camel/toolkits/slack_toolkit.py +308 -0
  78. camel/toolkits/twitter_toolkit.py +522 -0
  79. camel/toolkits/weather_toolkit.py +173 -0
  80. camel/types/enums.py +154 -35
  81. camel/utils/__init__.py +14 -2
  82. camel/utils/async_func.py +1 -1
  83. camel/utils/commons.py +152 -2
  84. camel/utils/constants.py +3 -0
  85. camel/utils/token_counting.py +148 -40
  86. camel/workforce/__init__.py +23 -0
  87. camel/workforce/base.py +50 -0
  88. camel/workforce/manager_node.py +299 -0
  89. camel/workforce/role_playing_node.py +168 -0
  90. camel/workforce/single_agent_node.py +77 -0
  91. camel/workforce/task_channel.py +173 -0
  92. camel/workforce/utils.py +97 -0
  93. camel/workforce/worker_node.py +115 -0
  94. camel/workforce/workforce.py +49 -0
  95. camel/workforce/workforce_prompt.py +125 -0
  96. {camel_ai-0.1.5.6.dist-info → camel_ai-0.1.6.1.dist-info}/METADATA +45 -3
  97. camel_ai-0.1.6.1.dist-info/RECORD +182 -0
  98. camel/functions/__init__.py +0 -51
  99. camel/functions/google_maps_function.py +0 -335
  100. camel/functions/math_functions.py +0 -61
  101. camel/functions/open_api_function.py +0 -508
  102. camel/functions/retrieval_functions.py +0 -61
  103. camel/functions/search_functions.py +0 -298
  104. camel/functions/slack_functions.py +0 -286
  105. camel/functions/twitter_function.py +0 -479
  106. camel/functions/weather_functions.py +0 -144
  107. camel_ai-0.1.5.6.dist-info/RECORD +0 -157
  108. /camel/{functions → toolkits}/open_api_specs/biztoc/__init__.py +0 -0
  109. /camel/{functions → toolkits}/open_api_specs/biztoc/ai-plugin.json +0 -0
  110. /camel/{functions → toolkits}/open_api_specs/biztoc/openapi.yaml +0 -0
  111. /camel/{functions → toolkits}/open_api_specs/coursera/__init__.py +0 -0
  112. /camel/{functions → toolkits}/open_api_specs/coursera/openapi.yaml +0 -0
  113. /camel/{functions → toolkits}/open_api_specs/create_qr_code/__init__.py +0 -0
  114. /camel/{functions → toolkits}/open_api_specs/create_qr_code/openapi.yaml +0 -0
  115. /camel/{functions → toolkits}/open_api_specs/klarna/__init__.py +0 -0
  116. /camel/{functions → toolkits}/open_api_specs/klarna/openapi.yaml +0 -0
  117. /camel/{functions → toolkits}/open_api_specs/nasa_apod/__init__.py +0 -0
  118. /camel/{functions → toolkits}/open_api_specs/nasa_apod/openapi.yaml +0 -0
  119. /camel/{functions → toolkits}/open_api_specs/outschool/__init__.py +0 -0
  120. /camel/{functions → toolkits}/open_api_specs/outschool/ai-plugin.json +0 -0
  121. /camel/{functions → toolkits}/open_api_specs/outschool/openapi.yaml +0 -0
  122. /camel/{functions → toolkits}/open_api_specs/outschool/paths/__init__.py +0 -0
  123. /camel/{functions → toolkits}/open_api_specs/outschool/paths/get_classes.py +0 -0
  124. /camel/{functions → toolkits}/open_api_specs/outschool/paths/search_teachers.py +0 -0
  125. /camel/{functions → toolkits}/open_api_specs/security_config.py +0 -0
  126. /camel/{functions → toolkits}/open_api_specs/speak/__init__.py +0 -0
  127. /camel/{functions → toolkits}/open_api_specs/speak/openapi.yaml +0 -0
  128. /camel/{functions → toolkits}/open_api_specs/web_scraper/__init__.py +0 -0
  129. /camel/{functions → toolkits}/open_api_specs/web_scraper/ai-plugin.json +0 -0
  130. /camel/{functions → toolkits}/open_api_specs/web_scraper/openapi.yaml +0 -0
  131. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/__init__.py +0 -0
  132. /camel/{functions → toolkits}/open_api_specs/web_scraper/paths/scraper.py +0 -0
  133. {camel_ai-0.1.5.6.dist-info → camel_ai-0.1.6.1.dist-info}/WHEEL +0 -0
@@ -1,335 +0,0 @@
1
- # =========== Copyright 2023 @ 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 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- import os
15
- from functools import wraps
16
- from typing import Any, Callable, List, Optional, Tuple, Union
17
-
18
- from camel.functions.openai_function import OpenAIFunction
19
-
20
-
21
- def import_googlemaps_or_raise() -> Any:
22
- r"""Attempts to import the `googlemaps` library and returns it.
23
-
24
- Returns:
25
- module: The `googlemaps` module if successfully imported.
26
-
27
- Raises:
28
- ImportError: If the `googlemaps` library is not installed, this error
29
- is raised with a message instructing how to install the
30
- library using pip.
31
- """
32
- try:
33
- import googlemaps
34
-
35
- return googlemaps
36
- except ImportError:
37
- raise ImportError(
38
- "Please install `googlemaps` first. You can install "
39
- "it by running `pip install googlemaps`."
40
- )
41
-
42
-
43
- def get_googlemap_api_key() -> str:
44
- r"""Retrieve the Google Maps API key from environment variables.
45
-
46
- Returns:
47
- str: The Google Maps API key.
48
-
49
- Raises:
50
- ValueError: If the API key is not found in the environment variables.
51
- """
52
- # Get `GOOGLEMAPS_API_KEY` here:
53
- # https://console.cloud.google.com/apis/credentials
54
- GOOGLEMAPS_API_KEY = os.environ.get('GOOGLEMAPS_API_KEY')
55
- if not GOOGLEMAPS_API_KEY:
56
- raise ValueError(
57
- "`GOOGLEMAPS_API_KEY` not found in environment "
58
- "variables. `GOOGLEMAPS_API_KEY` API keys are "
59
- "generated in the `Credentials` page of the "
60
- "`APIs & Services` tab of "
61
- "https://console.cloud.google.com/apis/credentials."
62
- )
63
- return GOOGLEMAPS_API_KEY
64
-
65
-
66
- def get_address_description(
67
- address: Union[str, List[str]],
68
- region_code: Optional[str] = None,
69
- locality: Optional[str] = None,
70
- ) -> str:
71
- r"""Validates an address via Google Maps API, returns a descriptive
72
- summary.
73
-
74
- Validates an address using Google Maps API, returning a summary that
75
- includes information on address completion, formatted address, location
76
- coordinates, and metadata types that are true for the given address.
77
-
78
- Args:
79
- address (Union[str, List[str]]): The address or components to validate.
80
- Can be a single string or a list representing different parts.
81
- region_code (str, optional): Country code for regional restriction,
82
- helps narrowing down results. (default: :obj:`None`)
83
- locality (str, optional): Restricts validation to a specific locality,
84
- e.g., "Mountain View". (default: :obj:`None`)
85
-
86
- Returns:
87
- str: Summary of the address validation results, including information
88
- on address completion, formatted address, geographical coordinates
89
- (latitude and longitude), and metadata types true for the address.
90
-
91
- Raises:
92
- ImportError: If the `googlemaps` library is not installed.
93
- Exception: For unexpected errors during the address validation.
94
- """
95
- googlemaps = import_googlemaps_or_raise()
96
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
97
- try:
98
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
99
- except Exception as e:
100
- return f"Error: {e!s}"
101
-
102
- try:
103
- addressvalidation_result = gmaps.addressvalidation(
104
- [address],
105
- regionCode=region_code,
106
- locality=locality,
107
- enableUspsCass=False,
108
- ) # Always False as per requirements
109
-
110
- # Check if the result contains an error
111
- if 'error' in addressvalidation_result:
112
- error_info = addressvalidation_result['error']
113
- error_message = error_info.get(
114
- 'message', 'An unknown error occurred'
115
- )
116
- error_status = error_info.get('status', 'UNKNOWN_STATUS')
117
- error_code = error_info.get('code', 'UNKNOWN_CODE')
118
- return (
119
- f"Address validation failed with error: {error_message} "
120
- f"Status: {error_status}, Code: {error_code}"
121
- )
122
-
123
- # Assuming the successful response structure includes a 'result' key
124
- result = addressvalidation_result['result']
125
- verdict = result.get('verdict', {})
126
- address_info = result.get('address', {})
127
- geocode = result.get('geocode', {})
128
- metadata = result.get('metadata', {})
129
-
130
- # Construct the descriptive string
131
- address_complete = (
132
- "Yes" if verdict.get('addressComplete', False) else "No"
133
- )
134
- formatted_address = address_info.get(
135
- 'formattedAddress', 'Not available'
136
- )
137
- location = geocode.get('location', {})
138
- latitude = location.get('latitude', 'Not available')
139
- longitude = location.get('longitude', 'Not available')
140
- true_metadata_types = [key for key, value in metadata.items() if value]
141
- true_metadata_types_str = (
142
- ', '.join(true_metadata_types) if true_metadata_types else 'None'
143
- )
144
-
145
- description = (
146
- f"Address completion status: {address_complete}. "
147
- f"Formatted address: {formatted_address}. "
148
- f"Location (latitude, longitude): ({latitude}, {longitude}). "
149
- f"Metadata indicating true types: {true_metadata_types_str}."
150
- )
151
-
152
- return description
153
- except Exception as e:
154
- return f"An unexpected error occurred: {e!s}"
155
-
156
-
157
- def handle_googlemaps_exceptions(
158
- func: Callable[..., Any],
159
- ) -> Callable[..., Any]:
160
- r"""Decorator to catch and handle exceptions raised by Google Maps API
161
- calls.
162
-
163
- Args:
164
- func (Callable): The function to be wrapped by the decorator.
165
-
166
- Returns:
167
- Callable: A wrapper function that calls the wrapped function and
168
- handles exceptions.
169
- """
170
-
171
- @wraps(func)
172
- def wrapper(*args: Any, **kwargs: Any) -> Any:
173
- try:
174
- from googlemaps.exceptions import ( # type: ignore[import-untyped] # isort: skip
175
- ApiError,
176
- HTTPError,
177
- Timeout,
178
- TransportError,
179
- )
180
- except ImportError:
181
- raise ImportError(
182
- "Please install `googlemaps` first. You can install "
183
- "it by running `pip install googlemaps`."
184
- )
185
-
186
- try:
187
- return func(*args, **kwargs)
188
- except ApiError as e:
189
- return (
190
- 'An exception returned by the remote API. '
191
- f'Status: {e.status}, Message: {e.message}'
192
- )
193
- except HTTPError as e:
194
- return (
195
- 'An unexpected HTTP error occurred. '
196
- f'Status Code: {e.status_code}'
197
- )
198
- except Timeout:
199
- return 'The request timed out.'
200
- except TransportError as e:
201
- return (
202
- 'Something went wrong while trying to execute the '
203
- f'request. Details: {e.base_exception}'
204
- )
205
- except Exception as e:
206
- return f'An unexpected error occurred: {e}'
207
-
208
- return wrapper
209
-
210
-
211
- @handle_googlemaps_exceptions
212
- def get_elevation(lat_lng: Tuple) -> str:
213
- r"""Retrieves elevation data for a given latitude and longitude.
214
-
215
- Uses the Google Maps API to fetch elevation data for the specified latitude
216
- and longitude. It handles exceptions gracefully and returns a description
217
- of the elevation, including its value in meters and the data resolution.
218
-
219
- Args:
220
- lat_lng (Tuple[float, float]): The latitude and longitude for
221
- which to retrieve elevation data.
222
-
223
- Returns:
224
- str: A description of the elevation at the specified location(s),
225
- including the elevation in meters and the data resolution. If
226
- elevation data is not available, a message indicating this is
227
- returned.
228
- """
229
- googlemaps = import_googlemaps_or_raise()
230
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
231
- try:
232
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
233
- except Exception as e:
234
- return f"Error: {e!s}"
235
-
236
- # Assuming gmaps is a configured Google Maps client instance
237
- elevation_result = gmaps.elevation(lat_lng)
238
-
239
- # Extract the elevation data from the first (and presumably only) result
240
- if elevation_result:
241
- elevation = elevation_result[0]['elevation']
242
- location = elevation_result[0]['location']
243
- resolution = elevation_result[0]['resolution']
244
-
245
- # Format the elevation data into a natural language description
246
- description = (
247
- f"The elevation at latitude {location['lat']}, "
248
- f"longitude {location['lng']} "
249
- f"is approximately {elevation:.2f} meters above sea level, "
250
- f"with a data resolution of {resolution:.2f} meters."
251
- )
252
- else:
253
- description = "Elevation data is not available for the given location."
254
-
255
- return description
256
-
257
-
258
- def format_offset_to_natural_language(offset: int) -> str:
259
- r"""Converts a time offset in seconds to a more natural language
260
- description using hours as the unit, with decimal places to represent
261
- minutes and seconds.
262
-
263
- Args:
264
- offset (int): The time offset in seconds. Can be positive, negative,
265
- or zero.
266
-
267
- Returns:
268
- str: A string representing the offset in hours, such as "+2.50 hours"
269
- or "-3.75 hours".
270
- """
271
- # Convert the offset to hours as a float
272
- hours = offset / 3600.0
273
- hours_str = f"{hours:+.2f} hour{'s' if abs(hours) != 1 else ''}"
274
- return hours_str
275
-
276
-
277
- @handle_googlemaps_exceptions
278
- def get_timezone(lat_lng: Tuple) -> str:
279
- r"""Retrieves timezone information for a given latitude and longitude.
280
-
281
- This function uses the Google Maps Timezone API to fetch timezone data for
282
- the specified latitude and longitude. It returns a natural language
283
- description of the timezone, including the timezone ID, name, standard
284
- time offset, daylight saving time offset, and the total offset from
285
- Coordinated Universal Time (UTC).
286
-
287
- Args:
288
- lat_lng (Tuple[float, float]): The latitude and longitude for
289
- which to retrieve elevation data.
290
-
291
- Returns:
292
- str: A descriptive string of the timezone information, including the
293
- timezone ID and name, standard time offset, daylight saving time
294
- offset, and total offset from UTC.
295
- """
296
- googlemaps = import_googlemaps_or_raise()
297
- GOOGLEMAPS_API_KEY = get_googlemap_api_key()
298
- try:
299
- gmaps = googlemaps.Client(key=GOOGLEMAPS_API_KEY)
300
- except Exception as e:
301
- return f"Error: {e!s}"
302
-
303
- # Get timezone information
304
- timezone_dict = gmaps.timezone(lat_lng)
305
-
306
- # Extract necessary information
307
- dst_offset = timezone_dict[
308
- 'dstOffset'
309
- ] # Daylight Saving Time offset in seconds
310
- raw_offset = timezone_dict['rawOffset'] # Standard time offset in seconds
311
- timezone_id = timezone_dict['timeZoneId']
312
- timezone_name = timezone_dict['timeZoneName']
313
-
314
- raw_offset_str = format_offset_to_natural_language(raw_offset)
315
- dst_offset_str = format_offset_to_natural_language(dst_offset)
316
- total_offset_seconds = dst_offset + raw_offset
317
- total_offset_str = format_offset_to_natural_language(total_offset_seconds)
318
-
319
- # Create a natural language description
320
- description = (
321
- f"Timezone ID is {timezone_id}, named {timezone_name}. "
322
- f"The standard time offset is {raw_offset_str}. "
323
- f"Daylight Saving Time offset is {dst_offset_str}. "
324
- f"The total offset from Coordinated Universal Time (UTC) is "
325
- f"{total_offset_str}, including any Daylight Saving Time adjustment "
326
- f"if applicable. "
327
- )
328
-
329
- return description
330
-
331
-
332
- MAP_FUNCS: List[OpenAIFunction] = [
333
- OpenAIFunction(func) # type: ignore[arg-type]
334
- for func in [get_address_description, get_elevation, get_timezone]
335
- ]
@@ -1,61 +0,0 @@
1
- # =========== Copyright 2023 @ 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 @ CAMEL-AI.org. All Rights Reserved. ===========
14
-
15
- from typing import List
16
-
17
- from camel.functions.openai_function import OpenAIFunction
18
-
19
-
20
- def add(a: int, b: int) -> int:
21
- r"""Adds two numbers.
22
-
23
- Args:
24
- a (int): The first number to be added.
25
- b (int): The second number to be added.
26
-
27
- Returns:
28
- integer: The sum of the two numbers.
29
- """
30
- return a + b
31
-
32
-
33
- def sub(a: int, b: int) -> int:
34
- r"""Do subtraction between two numbers.
35
-
36
- Args:
37
- a (int): The minuend in subtraction.
38
- b (int): The subtrahend in subtraction.
39
-
40
- Returns:
41
- integer: The result of subtracting :obj:`b` from :obj:`a`.
42
- """
43
- return a - b
44
-
45
-
46
- def mul(a: int, b: int) -> int:
47
- r"""Multiplies two integers.
48
-
49
- Args:
50
- a (int): The multiplier in the multiplication.
51
- b (int): The multiplicand in the multiplication.
52
-
53
- Returns:
54
- integer: The product of the two numbers.
55
- """
56
- return a * b
57
-
58
-
59
- MATH_FUNCS: List[OpenAIFunction] = [
60
- OpenAIFunction(func) for func in [add, sub, mul]
61
- ]