camel-ai 0.1.6.5__py3-none-any.whl → 0.1.6.6__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.

camel/__init__.py CHANGED
@@ -12,7 +12,7 @@
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
14
 
15
- __version__ = '0.1.6.5'
15
+ __version__ = '0.1.6.6'
16
16
 
17
17
  __all__ = [
18
18
  '__version__',
@@ -103,3 +103,19 @@ class OpenAICompatibilityModel:
103
103
  bool: Whether the model is in stream mode.
104
104
  """
105
105
  return self.model_config_dict.get('stream', False)
106
+
107
+ @property
108
+ def token_limit(self) -> int:
109
+ r"""Returns the maximum token limit for the given model.
110
+
111
+ Returns:
112
+ int: The maximum token limit for the given model.
113
+ """
114
+ max_tokens = self.model_config_dict.get("max_tokens")
115
+ if isinstance(max_tokens, int):
116
+ return max_tokens
117
+ print(
118
+ "Must set `max_tokens` as an integer in `model_config_dict` when"
119
+ " setting up the model. Using 4096 as default value."
120
+ )
121
+ return 4096
@@ -28,6 +28,11 @@ from camel.storages import (
28
28
  )
29
29
  from camel.types import StorageType
30
30
 
31
+ try:
32
+ from unstructured.documents.elements import Element
33
+ except ImportError:
34
+ Element = None
35
+
31
36
  DEFAULT_TOP_K_RESULTS = 1
32
37
  DEFAULT_SIMILARITY_THRESHOLD = 0.75
33
38
 
@@ -97,15 +102,19 @@ class AutoRetriever:
97
102
  f"Unsupported vector storage type: {self.storage_type}"
98
103
  )
99
104
 
100
- def _collection_name_generator(self, content: str) -> str:
105
+ def _collection_name_generator(self, content: Union[str, Element]) -> str:
101
106
  r"""Generates a valid collection name from a given file path or URL.
102
107
 
103
108
  Args:
104
- contents (str): Local file path, remote URL or string content.
109
+ content (Union[str, Element]): Local file path, remote URL,
110
+ string content or Element object.
105
111
 
106
112
  Returns:
107
113
  str: A sanitized, valid collection name suitable for use.
108
114
  """
115
+ if isinstance(content, Element):
116
+ content = content.metadata.file_directory
117
+
109
118
  # Check if the content is URL
110
119
  parsed_url = urlparse(content)
111
120
  is_url = all([parsed_url.scheme, parsed_url.netloc])
@@ -193,7 +202,7 @@ class AutoRetriever:
193
202
  def run_vector_retriever(
194
203
  self,
195
204
  query: str,
196
- contents: Union[str, List[str]],
205
+ contents: Union[str, List[str], Element, List[Element]],
197
206
  top_k: int = DEFAULT_TOP_K_RESULTS,
198
207
  similarity_threshold: float = DEFAULT_SIMILARITY_THRESHOLD,
199
208
  return_detailed_info: bool = False,
@@ -203,8 +212,8 @@ class AutoRetriever:
203
212
 
204
213
  Args:
205
214
  query (str): Query string for information retriever.
206
- contents (Union[str, List[str]]): Local file paths, remote URLs or
207
- string contents.
215
+ contents (Union[str, List[str], Element, List[Element]]): Local
216
+ file paths, remote URLs, string contents or Element objects.
208
217
  top_k (int, optional): The number of top results to return during
209
218
  retrieve. Must be a positive integer. Defaults to
210
219
  `DEFAULT_TOP_K_RESULTS`.
@@ -230,7 +239,9 @@ class AutoRetriever:
230
239
  if not contents:
231
240
  raise ValueError("content cannot be empty.")
232
241
 
233
- contents = [contents] if isinstance(contents, str) else contents
242
+ contents = (
243
+ [contents] if isinstance(contents, (str, Element)) else contents
244
+ )
234
245
 
235
246
  all_retrieved_info = []
236
247
  for content in contents:
@@ -246,6 +257,7 @@ class AutoRetriever:
246
257
  file_is_modified = False # initialize with a default value
247
258
  if (
248
259
  vector_storage_instance.status().vector_count != 0
260
+ and isinstance(content, str)
249
261
  and os.path.exists(content)
250
262
  ):
251
263
  # Get original modified date from file
@@ -13,7 +13,7 @@
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
14
  import os
15
15
  import warnings
16
- from typing import Any, Dict, List, Optional
16
+ from typing import Any, Dict, List, Optional, Union
17
17
  from urllib.parse import urlparse
18
18
 
19
19
  from camel.embeddings import BaseEmbedding, OpenAIEmbedding
@@ -26,6 +26,11 @@ from camel.storages import (
26
26
  VectorRecord,
27
27
  )
28
28
 
29
+ try:
30
+ from unstructured.documents.elements import Element
31
+ except ImportError:
32
+ Element = None
33
+
29
34
  DEFAULT_TOP_K_RESULTS = 1
30
35
  DEFAULT_SIMILARITY_THRESHOLD = 0.75
31
36
 
@@ -69,7 +74,7 @@ class VectorRetriever(BaseRetriever):
69
74
 
70
75
  def process(
71
76
  self,
72
- content: str,
77
+ content: Union[str, Element],
73
78
  chunk_type: str = "chunk_by_title",
74
79
  **kwargs: Any,
75
80
  ) -> None:
@@ -78,18 +83,22 @@ class VectorRetriever(BaseRetriever):
78
83
  vector storage.
79
84
 
80
85
  Args:
81
- contents (str): Local file path, remote URL or string content.
86
+ content (Union[str, Element]): Local file path, remote URL,
87
+ string content or Element object.
82
88
  chunk_type (str): Type of chunking going to apply. Defaults to
83
89
  "chunk_by_title".
84
90
  **kwargs (Any): Additional keyword arguments for content parsing.
85
91
  """
86
- # Check if the content is URL
87
- parsed_url = urlparse(content)
88
- is_url = all([parsed_url.scheme, parsed_url.netloc])
89
- if is_url or os.path.exists(content):
90
- elements = self.uio.parse_file_or_url(content, **kwargs)
92
+ if isinstance(content, Element):
93
+ elements = [content]
91
94
  else:
92
- elements = [self.uio.create_element_from_text(text=content)]
95
+ # Check if the content is URL
96
+ parsed_url = urlparse(content)
97
+ is_url = all([parsed_url.scheme, parsed_url.netloc])
98
+ if is_url or os.path.exists(content):
99
+ elements = self.uio.parse_file_or_url(content, **kwargs) or []
100
+ else:
101
+ elements = [self.uio.create_element_from_text(text=content)]
93
102
  if elements:
94
103
  chunks = self.uio.chunk_elements(
95
104
  chunk_type=chunk_type, elements=elements
@@ -110,7 +119,12 @@ class VectorRetriever(BaseRetriever):
110
119
  # Prepare the payload for each vector record, includes the content
111
120
  # path, chunk metadata, and chunk text
112
121
  for vector, chunk in zip(batch_vectors, batch_chunks):
113
- content_path_info = {"content path": content}
122
+ if isinstance(content, str):
123
+ content_path_info = {"content path": content}
124
+ elif isinstance(content, Element):
125
+ content_path_info = {
126
+ "content path": content.metadata.file_directory
127
+ }
114
128
  chunk_metadata = {"metadata": chunk.metadata.to_dict()}
115
129
  chunk_text = {"text": str(chunk)}
116
130
  combined_dict = {
camel/types/enums.py CHANGED
@@ -26,7 +26,6 @@ class RoleType(Enum):
26
26
  class ModelType(Enum):
27
27
  GPT_3_5_TURBO = "gpt-3.5-turbo"
28
28
  GPT_4 = "gpt-4"
29
- GPT_4_32K = "gpt-4-32k"
30
29
  GPT_4_TURBO = "gpt-4-turbo"
31
30
  GPT_4O = "gpt-4o"
32
31
  GPT_4O_MINI = "gpt-4o-mini"
@@ -96,7 +95,6 @@ class ModelType(Enum):
96
95
  return self in {
97
96
  ModelType.GPT_3_5_TURBO,
98
97
  ModelType.GPT_4,
99
- ModelType.GPT_4_32K,
100
98
  ModelType.GPT_4_TURBO,
101
99
  ModelType.GPT_4O,
102
100
  ModelType.GPT_4O_MINI,
@@ -110,7 +108,6 @@ class ModelType(Enum):
110
108
  return self in {
111
109
  ModelType.GPT_3_5_TURBO,
112
110
  ModelType.GPT_4,
113
- ModelType.GPT_4_32K,
114
111
  ModelType.GPT_4_TURBO,
115
112
  ModelType.GPT_4O,
116
113
  }
@@ -231,7 +228,6 @@ class ModelType(Enum):
231
228
  }:
232
229
  return 16_384
233
230
  elif self in {
234
- ModelType.GPT_4_32K,
235
231
  ModelType.MISTRAL_CODESTRAL,
236
232
  ModelType.MISTRAL_7B,
237
233
  ModelType.MISTRAL_MIXTRAL_8x7B,
@@ -440,7 +436,7 @@ class ModelPlatformType(Enum):
440
436
  AZURE = "azure"
441
437
  ANTHROPIC = "anthropic"
442
438
  GROQ = "groq"
443
- OPENSOURCE = "opensource"
439
+ OPEN_SOURCE = "open-source"
444
440
  OLLAMA = "ollama"
445
441
  LITELLM = "litellm"
446
442
  ZHIPU = "zhipuai"
@@ -448,7 +444,7 @@ class ModelPlatformType(Enum):
448
444
  GEMINI = "gemini"
449
445
  VLLM = "vllm"
450
446
  MISTRAL = "mistral"
451
- OPENAICOMPATIBILITYMODEL = "openai-compatibility-model"
447
+ OPENAI_COMPATIBILITY_MODEL = "openai-compatibility-model"
452
448
 
453
449
  @property
454
450
  def is_openai(self) -> bool:
@@ -498,13 +494,13 @@ class ModelPlatformType(Enum):
498
494
  @property
499
495
  def is_open_source(self) -> bool:
500
496
  r"""Returns whether this platform is opensource."""
501
- return self is ModelPlatformType.OPENSOURCE
497
+ return self is ModelPlatformType.OPEN_SOURCE
502
498
 
503
499
  @property
504
500
  def is_openai_compatibility_model(self) -> bool:
505
501
  r"""Returns whether this is a platform supporting openai
506
502
  compatibility"""
507
- return self is ModelPlatformType.OPENAICOMPATIBILITYMODEL
503
+ return self is ModelPlatformType.OPENAI_COMPATIBILITY_MODEL
508
504
 
509
505
  @property
510
506
  def is_gemini(self) -> bool:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: camel-ai
3
- Version: 0.1.6.5
3
+ Version: 0.1.6.6
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Home-page: https://www.camel-ai.org/
6
6
  License: Apache-2.0
@@ -202,7 +202,7 @@ conda create --name camel python=3.9
202
202
  conda activate camel
203
203
 
204
204
  # Clone github repo
205
- git clone -b v0.1.6.5 https://github.com/camel-ai/camel.git
205
+ git clone -b v0.1.6.6 https://github.com/camel-ai/camel.git
206
206
 
207
207
  # Change directory into project directory
208
208
  cd camel
@@ -1,4 +1,4 @@
1
- camel/__init__.py,sha256=_XswF67MSAdq-D9Yt9KcdGCUfyMao5xMv5mp5O0rEyc,780
1
+ camel/__init__.py,sha256=SDBoO0TP3AuDhtAatS9glrX7-aEUX9Bb9M7ethOchTY,780
2
2
  camel/agents/__init__.py,sha256=SSU1wbhZXWwQnE0rRxkpyN57kEu72KklsZNcdLkXfTs,1551
3
3
  camel/agents/base.py,sha256=X39qWSiT1WnDqaJ9k3gQrTpOQSwUKzNEVpp5AY6fDH8,1130
4
4
  camel/agents/chat_agent.py,sha256=8yqGmaXnhfVE9dIgBanK74cfEZvHgKtx36YqUDvFuWE,36217
@@ -68,7 +68,7 @@ camel/models/nemotron_model.py,sha256=2Idf4wrZervxvfu6av42EKjefFtDnBb6cKnWCJUkqI
68
68
  camel/models/ollama_model.py,sha256=VG5i3D3P9mHeRb9hJiIPFe3F5puFamXMg66UXiHw6Q8,4867
69
69
  camel/models/open_source_model.py,sha256=p5a2sCeZl5SyrgkygClndOrHEjpJxmyhE1CqKE2fZSw,6363
70
70
  camel/models/openai_audio_models.py,sha256=_ddOxqzFZCVZaK6h33Z0THU6HXk2XlJTxVWquZ3oOaQ,10042
71
- camel/models/openai_compatibility_model.py,sha256=pgb7MI8HKQe37hRpGPJVeH4E38pkaxTRc5-kJGLZr7E,3712
71
+ camel/models/openai_compatibility_model.py,sha256=bK4sWo6ftags4sK5AI1qSxwE_Vrpw0Zl4tg_5CNpd_8,4239
72
72
  camel/models/openai_model.py,sha256=uOtiLmbdH7sDKqk9oV0i1HEVni_4ApPXCukShZwQDKA,4611
73
73
  camel/models/stub_model.py,sha256=DuqaBsS55STSbcLJsk025Uwo_u4ixrSSKqKEoZj2ihY,3680
74
74
  camel/models/vllm_model.py,sha256=i8zOK4XvVx0ietQLT74MgkcjMXYc2CMmsYS4EeT0N-w,5005
@@ -92,11 +92,11 @@ camel/prompts/video_description_prompt.py,sha256=HRd3fHXftKwBm5QH7Tvm3FabgZPCoAv
92
92
  camel/responses/__init__.py,sha256=edtTQskOgq5obyITziRFL62HTJP9sAikAtP9vrFacEQ,795
93
93
  camel/responses/agent_responses.py,sha256=sGlGwXz2brWI-FpiU5EhVRpZvcfGWUmooAF0ukqAF3I,1771
94
94
  camel/retrievers/__init__.py,sha256=CuP3B77zl2PoF-W2y9xSkTGRzoK2J4TlUHdCtuJD8dg,1059
95
- camel/retrievers/auto_retriever.py,sha256=YnhqzmpjbfNFwdj-eCwV2XVTaG64KgBKuVdfEIpoaJI,13130
95
+ camel/retrievers/auto_retriever.py,sha256=2sBIYdx0oBWgugsgDwfNWkgFx_zXsVu3zlYbvmiX3Gk,13539
96
96
  camel/retrievers/base.py,sha256=sgqaJDwIkWluEgPBlukFN7RYZJnrp0imCAOEWm6bZ40,2646
97
97
  camel/retrievers/bm25_retriever.py,sha256=Dr7Yfkjw45sovI1EVNByGIMj7KERWrr8JHlh8csSF1s,5155
98
98
  camel/retrievers/cohere_rerank_retriever.py,sha256=HvnFqXpsX9EdBOab0kFLDyxxJnknPFMVxyQJQDlHbOA,4100
99
- camel/retrievers/vector_retriever.py,sha256=Jj2g98dP_r3nL13PrPp5DjPAHrru5aaM0jznaOM8WL0,7490
99
+ camel/retrievers/vector_retriever.py,sha256=iNYS3A8UxjP6Q7HYqQ05P7sI_2Rmwy-BxsHJR7oYmwY,8019
100
100
  camel/societies/__init__.py,sha256=JhGwUHjht4CewzC3shKuxmgB3oS7FIxIxmiKyhNsfIs,832
101
101
  camel/societies/babyagi_playing.py,sha256=bDeHFPQ1Zocnb8HSu56xZMlC6-AZACZWqGM5l9KB-EA,11866
102
102
  camel/societies/role_playing.py,sha256=VZRethoZxYtm-phEao79ksSyQqo2HHm8taNY-BjFDVE,22262
@@ -166,7 +166,7 @@ camel/toolkits/slack_toolkit.py,sha256=JdgDJe7iExTmG7dDXOG6v5KpVjZ6_My_d_WFTYSxk
166
166
  camel/toolkits/twitter_toolkit.py,sha256=oQw8wRkU7iDxaocsmWvio4pU75pmq6FJAorPdQ2xEAE,19810
167
167
  camel/toolkits/weather_toolkit.py,sha256=n4YrUI_jTIH7oqH918IdHbXLgfQ2BPGIWWK8Jp8G1Uw,7054
168
168
  camel/types/__init__.py,sha256=ArKXATj3z_Vv4ISmROVeo6Mv3tj5kE1dTkqfgwyxVY4,1975
169
- camel/types/enums.py,sha256=dFZCE013R8CQJRPWQKk-qj2Lv4_JnJso4LDPKTlXudo,16303
169
+ camel/types/enums.py,sha256=BNKsarTCBABAcF4BP8isuXetenqETt0DGqEtvTrf_To,16183
170
170
  camel/types/openai_types.py,sha256=BNQ6iCzKTjSvgcXFsAFIgrUS_YUFZBU6bDoyAp387hI,2045
171
171
  camel/utils/__init__.py,sha256=KBpIUiwA1iUCtMGk62y0FQ3Eatk4W8WNgMJjJUU1Ja8,2255
172
172
  camel/utils/async_func.py,sha256=SLo8KPkrNKdsONvFf3KBb33EgFn4gH2EKSX1aI_LKes,1578
@@ -183,6 +183,6 @@ camel/workforce/utils.py,sha256=Z-kODz5PMPtfeKKVqpcQq-b-B8oqC7XSwi_F3__Ijhs,3526
183
183
  camel/workforce/worker_node.py,sha256=wsRqk2rugCvvkcmCzvn-y-gQuyuJGAG8PIr1KtgqJFw,3878
184
184
  camel/workforce/workforce.py,sha256=SVJJgSSkYvk05RgL9oaJzHwzziH7u51KLINRuzLB8BI,1773
185
185
  camel/workforce/workforce_prompt.py,sha256=cAWYEIA0rau5itEekSoUIFttBzpKM9RzB6x-mfukGSU,4665
186
- camel_ai-0.1.6.5.dist-info/METADATA,sha256=IsvDDPKdCVrevQgSaOD872LZjqf8GB7vEAR4ewBGPb0,24282
187
- camel_ai-0.1.6.5.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
188
- camel_ai-0.1.6.5.dist-info/RECORD,,
186
+ camel_ai-0.1.6.6.dist-info/METADATA,sha256=LGesNJn_ZdO-2oE8md4_BiNfculqhWzIcudmLi7s5as,24282
187
+ camel_ai-0.1.6.6.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
188
+ camel_ai-0.1.6.6.dist-info/RECORD,,