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

@@ -13,7 +13,10 @@
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
14
  from typing import Optional, Union
15
15
 
16
- from unstructured.documents.elements import Element
16
+ try:
17
+ from unstructured.documents.elements import Element
18
+ except ImportError:
19
+ Element = None
17
20
 
18
21
  from camel.agents import ChatAgent
19
22
  from camel.messages import BaseMessage
camel/embeddings/base.py CHANGED
@@ -11,8 +11,10 @@
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
+ from __future__ import annotations
15
+
14
16
  from abc import ABC, abstractmethod
15
- from typing import Any, Generic, List, TypeVar
17
+ from typing import Any, Generic, TypeVar
16
18
 
17
19
  T = TypeVar('T')
18
20
 
@@ -23,19 +25,18 @@ class BaseEmbedding(ABC, Generic[T]):
23
25
  @abstractmethod
24
26
  def embed_list(
25
27
  self,
26
- objs: List[T],
28
+ objs: list[T],
27
29
  **kwargs: Any,
28
- ) -> List[List[float]]:
30
+ ) -> list[list[float]]:
29
31
  r"""Generates embeddings for the given texts.
30
32
 
31
33
  Args:
32
- objs (List[T]): The objects for which to generate the embeddings.
34
+ objs (list[T]): The objects for which to generate the embeddings.
33
35
  **kwargs (Any): Extra kwargs passed to the embedding API.
34
36
 
35
37
  Returns:
36
- List[List[float]]: A list that represents the
37
- generated embedding as a list of floating-point numbers or a
38
- numpy matrix with embeddings.
38
+ list[list[float]]: A list that represents the
39
+ generated embedding as a list of floating-point numbers.
39
40
  """
40
41
  pass
41
42
 
@@ -43,7 +44,7 @@ class BaseEmbedding(ABC, Generic[T]):
43
44
  self,
44
45
  obj: T,
45
46
  **kwargs: Any,
46
- ) -> List[float]:
47
+ ) -> list[float]:
47
48
  r"""Generates an embedding for the given text.
48
49
 
49
50
  Args:
@@ -51,7 +52,7 @@ class BaseEmbedding(ABC, Generic[T]):
51
52
  **kwargs (Any): Extra kwargs passed to the embedding API.
52
53
 
53
54
  Returns:
54
- List[float]: A list of floating-point numbers representing the
55
+ list[float]: A list of floating-point numbers representing the
55
56
  generated embedding.
56
57
  """
57
58
  return self.embed_list([obj], **kwargs)[0]
@@ -11,10 +11,12 @@
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
+ from __future__ import annotations
15
+
14
16
  import os
15
- from typing import Any, List, Optional
17
+ from typing import Any
16
18
 
17
- from openai import OpenAI
19
+ from openai import NOT_GIVEN, NotGiven, OpenAI
18
20
 
19
21
  from camel.embeddings.base import BaseEmbedding
20
22
  from camel.types import EmbeddingModelType
@@ -25,10 +27,13 @@ class OpenAIEmbedding(BaseEmbedding[str]):
25
27
  r"""Provides text embedding functionalities using OpenAI's models.
26
28
 
27
29
  Args:
28
- model (OpenAiEmbeddingModel, optional): The model type to be used for
29
- generating embeddings. (default: :obj:`ModelType.ADA_2`)
30
- api_key (Optional[str]): The API key for authenticating with the
30
+ model_type (EmbeddingModelType, optional): The model type to be
31
+ used for text embeddings.
32
+ (default: :obj:`TEXT_EMBEDDING_3_SMALL`)
33
+ api_key (str, optional): The API key for authenticating with the
31
34
  OpenAI service. (default: :obj:`None`)
35
+ dimensions (int, optional): The text embedding output dimensions.
36
+ (default: :obj:`NOT_GIVEN`)
32
37
 
33
38
  Raises:
34
39
  RuntimeError: If an unsupported model type is specified.
@@ -36,36 +41,44 @@ class OpenAIEmbedding(BaseEmbedding[str]):
36
41
 
37
42
  def __init__(
38
43
  self,
39
- model_type: EmbeddingModelType = EmbeddingModelType.ADA_2,
40
- api_key: Optional[str] = None,
44
+ model_type: EmbeddingModelType = (
45
+ EmbeddingModelType.TEXT_EMBEDDING_3_SMALL
46
+ ),
47
+ api_key: str | None = None,
48
+ dimensions: int | NotGiven = NOT_GIVEN,
41
49
  ) -> None:
42
50
  if not model_type.is_openai:
43
51
  raise ValueError("Invalid OpenAI embedding model type.")
44
52
  self.model_type = model_type
45
- self.output_dim = model_type.output_dim
53
+ if dimensions == NOT_GIVEN:
54
+ self.output_dim = model_type.output_dim
55
+ else:
56
+ assert isinstance(dimensions, int)
57
+ self.output_dim = dimensions
46
58
  self._api_key = api_key or os.environ.get("OPENAI_API_KEY")
47
59
  self.client = OpenAI(timeout=60, max_retries=3, api_key=self._api_key)
48
60
 
49
61
  @model_api_key_required
50
62
  def embed_list(
51
63
  self,
52
- objs: List[str],
64
+ objs: list[str],
53
65
  **kwargs: Any,
54
- ) -> List[List[float]]:
66
+ ) -> list[list[float]]:
55
67
  r"""Generates embeddings for the given texts.
56
68
 
57
69
  Args:
58
- objs (List[str]): The texts for which to generate the embeddings.
70
+ objs (list[str]): The texts for which to generate the embeddings.
59
71
  **kwargs (Any): Extra kwargs passed to the embedding API.
60
72
 
61
73
  Returns:
62
- List[List[float]]: A list that represents the generated embedding
74
+ list[list[float]]: A list that represents the generated embedding
63
75
  as a list of floating-point numbers.
64
76
  """
65
77
  # TODO: count tokens
66
78
  response = self.client.embeddings.create(
67
79
  input=objs,
68
80
  model=self.model_type.value,
81
+ dimensions=self.output_dim,
69
82
  **kwargs,
70
83
  )
71
84
  return [data.embedding for data in response.data]
@@ -11,51 +11,63 @@
11
11
  # See the License for the specific language governing permissions and
12
12
  # limitations under the License.
13
13
  # =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
14
- from typing import Any, List
14
+ from __future__ import annotations
15
+
16
+ from typing import Any
17
+
18
+ from numpy import ndarray
15
19
 
16
20
  from camel.embeddings.base import BaseEmbedding
17
21
 
18
22
 
19
23
  class SentenceTransformerEncoder(BaseEmbedding[str]):
20
- r"""This class provides functionalities to generate embeddings
21
- using a specified model from `Sentence Transformers`.
24
+ r"""This class provides functionalities to generate text
25
+ embeddings using `Sentence Transformers`.
22
26
 
23
27
  References:
24
28
  https://www.sbert.net/
25
29
  """
26
30
 
27
- def __init__(self, model_name: str = 'intfloat/e5-large-v2'):
31
+ def __init__(
32
+ self,
33
+ model_name: str = "intfloat/e5-large-v2",
34
+ **kwargs,
35
+ ):
28
36
  r"""Initializes the: obj: `SentenceTransformerEmbedding` class
29
37
  with the specified transformer model.
30
38
 
31
39
  Args:
32
40
  model_name (str, optional): The name of the model to use.
33
- Defaults to `intfloat/e5-large-v2`.
41
+ (default: :obj:`intfloat/e5-large-v2`)
42
+ **kwargs (optional): Additional arguments of
43
+ :class:`SentenceTransformer`, such as :obj:`prompts` etc.
34
44
  """
35
45
  from sentence_transformers import SentenceTransformer
36
46
 
37
- self.model = SentenceTransformer(model_name)
47
+ self.model = SentenceTransformer(model_name, **kwargs)
38
48
 
39
49
  def embed_list(
40
50
  self,
41
- objs: List[str],
51
+ objs: list[str],
42
52
  **kwargs: Any,
43
- ) -> List[List[float]]:
53
+ ) -> list[list[float]]:
44
54
  r"""Generates embeddings for the given texts using the model.
45
55
 
46
56
  Args:
47
- objs (List[str]): The texts for which to generate the
48
- embeddings.
57
+ objs (list[str]): The texts for which to generate the
58
+ embeddings.
49
59
 
50
60
  Returns:
51
- List[List[float]]: A list that represents the generated embedding
61
+ list[list[float]]: A list that represents the generated embedding
52
62
  as a list of floating-point numbers.
53
63
  """
54
64
  if not objs:
55
65
  raise ValueError("Input text list is empty")
56
- return self.model.encode(
66
+ embeddings = self.model.encode(
57
67
  objs, normalize_embeddings=True, **kwargs
58
- ).tolist()
68
+ )
69
+ assert isinstance(embeddings, ndarray)
70
+ return embeddings.tolist()
59
71
 
60
72
  def get_output_dim(self) -> int:
61
73
  r"""Returns the output dimension of the embeddings.
@@ -63,4 +75,6 @@ class SentenceTransformerEncoder(BaseEmbedding[str]):
63
75
  Returns:
64
76
  int: The dimensionality of the embeddings.
65
77
  """
66
- return self.model.get_sentence_embedding_dimension()
78
+ output_dim = self.model.get_sentence_embedding_dimension()
79
+ assert isinstance(output_dim, int)
80
+ return output_dim
@@ -159,11 +159,11 @@ class AutoRetriever:
159
159
  ) -> str:
160
160
  r"""Retrieves the last modified date and time of a given file. This
161
161
  function takes vector storage instance as input and returns the last
162
- modified date from the meta data.
162
+ modified date from the metadata.
163
163
 
164
164
  Args:
165
165
  vector_storage_instance (BaseVectorStorage): The vector storage
166
- where modified date is to be retrieved from meta data.
166
+ where modified date is to be retrieved from metadata.
167
167
 
168
168
  Returns:
169
169
  str: The last modified date from vector storage.
@@ -16,7 +16,10 @@ from __future__ import annotations
16
16
  from dataclasses import dataclass, field
17
17
  from typing import List, Union
18
18
 
19
- from unstructured.documents.elements import Element
19
+ try:
20
+ from unstructured.documents.elements import Element
21
+ except ImportError:
22
+ Element = None
20
23
 
21
24
 
22
25
  @dataclass
@@ -72,3 +75,8 @@ class GraphElement:
72
75
  nodes: List[Node]
73
76
  relationships: List[Relationship]
74
77
  source: Element
78
+
79
+ def __post_init__(self):
80
+ if Element is None:
81
+ raise ImportError("""The 'unstructured' package is required to use
82
+ the 'source' attribute.""")
camel/types/enums.py CHANGED
@@ -49,6 +49,7 @@ class ModelType(Enum):
49
49
  CLAUDE_3_OPUS = "claude-3-opus-20240229"
50
50
  CLAUDE_3_SONNET = "claude-3-sonnet-20240229"
51
51
  CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
52
+ CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20240620"
52
53
 
53
54
  # Nvidia models
54
55
  NEMOTRON_4_REWARD = "nvidia/nemotron-4-340b-reward"
@@ -104,6 +105,7 @@ class ModelType(Enum):
104
105
  ModelType.CLAUDE_3_OPUS,
105
106
  ModelType.CLAUDE_3_SONNET,
106
107
  ModelType.CLAUDE_3_HAIKU,
108
+ ModelType.CLAUDE_3_5_SONNET,
107
109
  }
108
110
 
109
111
  @property
@@ -155,6 +157,7 @@ class ModelType(Enum):
155
157
  ModelType.CLAUDE_3_OPUS,
156
158
  ModelType.CLAUDE_3_SONNET,
157
159
  ModelType.CLAUDE_3_HAIKU,
160
+ ModelType.CLAUDE_3_5_SONNET,
158
161
  }:
159
162
  return 200_000
160
163
  elif self is ModelType.NEMOTRON_4_REWARD:
@@ -186,35 +189,27 @@ class ModelType(Enum):
186
189
 
187
190
 
188
191
  class EmbeddingModelType(Enum):
189
- ADA_2 = "text-embedding-ada-002"
190
- ADA_1 = "text-embedding-ada-001"
191
- BABBAGE_1 = "text-embedding-babbage-001"
192
- CURIE_1 = "text-embedding-curie-001"
193
- DAVINCI_1 = "text-embedding-davinci-001"
192
+ TEXT_EMBEDDING_ADA_2 = "text-embedding-ada-002"
193
+ TEXT_EMBEDDING_3_SMALL = "text-embedding-3-small"
194
+ TEXT_EMBEDDING_3_LARGE = "text-embedding-3-large"
194
195
 
195
196
  @property
196
197
  def is_openai(self) -> bool:
197
198
  r"""Returns whether this type of models is an OpenAI-released model."""
198
199
  return self in {
199
- EmbeddingModelType.ADA_2,
200
- EmbeddingModelType.ADA_1,
201
- EmbeddingModelType.BABBAGE_1,
202
- EmbeddingModelType.CURIE_1,
203
- EmbeddingModelType.DAVINCI_1,
200
+ EmbeddingModelType.TEXT_EMBEDDING_ADA_2,
201
+ EmbeddingModelType.TEXT_EMBEDDING_3_SMALL,
202
+ EmbeddingModelType.TEXT_EMBEDDING_3_LARGE,
204
203
  }
205
204
 
206
205
  @property
207
206
  def output_dim(self) -> int:
208
- if self is EmbeddingModelType.ADA_2:
207
+ if self is EmbeddingModelType.TEXT_EMBEDDING_ADA_2:
209
208
  return 1536
210
- elif self is EmbeddingModelType.ADA_1:
211
- return 1024
212
- elif self is EmbeddingModelType.BABBAGE_1:
213
- return 2048
214
- elif self is EmbeddingModelType.CURIE_1:
215
- return 4096
216
- elif self is EmbeddingModelType.DAVINCI_1:
217
- return 12288
209
+ elif self is EmbeddingModelType.TEXT_EMBEDDING_3_SMALL:
210
+ return 1536
211
+ elif self is EmbeddingModelType.TEXT_EMBEDDING_3_LARGE:
212
+ return 3072
218
213
  else:
219
214
  raise ValueError(f"Unknown model type {self}.")
220
215
 
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: camel-ai
3
- Version: 0.1.5.3
3
+ Version: 0.1.5.4
4
4
  Summary: Communicative Agents for AI Society Study
5
5
  Home-page: https://www.camel-ai.org/
6
6
  License: Apache-2.0
7
7
  Keywords: communicative-ai,ai-societies,artificial-intelligence,deep-learning,multi-agent-systems,cooperative-ai,natural-language-processing,large-language-models
8
8
  Author: CAMEL-AI.org
9
- Requires-Python: >=3.8.1,<3.12
9
+ Requires-Python: >=3.9.0,<3.12
10
10
  Classifier: License :: OSI Approved :: Apache Software License
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Classifier: Programming Language :: Python :: 3.9
@@ -23,7 +23,7 @@ Provides-Extra: tools
23
23
  Provides-Extra: vector-databases
24
24
  Requires-Dist: PyMuPDF (>=1.22.5,<2.0.0) ; extra == "tools" or extra == "all"
25
25
  Requires-Dist: accelerate (>=0,<1) ; extra == "huggingface-agent" or extra == "all"
26
- Requires-Dist: anthropic (>=0.28.0,<0.29.0)
26
+ Requires-Dist: anthropic (>=0.29.0,<0.30.0)
27
27
  Requires-Dist: beautifulsoup4 (>=4,<5) ; extra == "tools" or extra == "all"
28
28
  Requires-Dist: cohere (>=4.56,<5.0) ; extra == "retrievers" or extra == "all"
29
29
  Requires-Dist: colorama (>=0,<1)
@@ -35,7 +35,7 @@ Requires-Dist: docstring-parser (>=0.15,<0.16)
35
35
  Requires-Dist: docx2txt (>=0.8,<0.9) ; extra == "tools" or extra == "all"
36
36
  Requires-Dist: duckduckgo-search (>=6.1.0,<7.0.0) ; extra == "tools" or extra == "all"
37
37
  Requires-Dist: googlemaps (>=4.10.0,<5.0.0) ; extra == "tools" or extra == "all"
38
- Requires-Dist: imageio (>=2.34.1,<3.0.0) ; extra == "tools" or extra == "all"
38
+ Requires-Dist: imageio[pyav] (>=2.34.2,<3.0.0) ; extra == "tools" or extra == "all"
39
39
  Requires-Dist: jsonschema (>=4,<5)
40
40
  Requires-Dist: litellm (>=1.38.1,<2.0.0) ; extra == "model-platforms" or extra == "all"
41
41
  Requires-Dist: mock (>=5,<6) ; extra == "test"
@@ -60,7 +60,7 @@ Requires-Dist: pytest-asyncio (>=0.23.0,<0.24.0) ; extra == "test"
60
60
  Requires-Dist: qdrant-client (>=1.9.0,<2.0.0) ; extra == "vector-databases" or extra == "all"
61
61
  Requires-Dist: rank-bm25 (>=0.2.2,<0.3.0) ; extra == "retrievers" or extra == "all"
62
62
  Requires-Dist: requests_oauthlib (>=1.3.1,<2.0.0) ; extra == "tools" or extra == "all"
63
- Requires-Dist: sentence-transformers (>=2.2.2,<3.0.0) ; extra == "encoders" or extra == "all"
63
+ Requires-Dist: sentence-transformers (>=3.0.1,<4.0.0) ; extra == "encoders" or extra == "all"
64
64
  Requires-Dist: sentencepiece (>=0,<1) ; extra == "huggingface-agent" or extra == "all"
65
65
  Requires-Dist: slack-sdk (>=3.27.2,<4.0.0) ; extra == "tools" or extra == "all"
66
66
  Requires-Dist: soundfile (>=0,<1) ; extra == "huggingface-agent" or extra == "all"
@@ -180,13 +180,13 @@ exit
180
180
  Install `CAMEL` from source with conda and pip:
181
181
  ```sh
182
182
  # Create a conda virtual environment
183
- conda create --name camel python=3.10
183
+ conda create --name camel python=3.9
184
184
 
185
185
  # Activate CAMEL conda environment
186
186
  conda activate camel
187
187
 
188
188
  # Clone github repo
189
- git clone -b v0.1.5.3 https://github.com/camel-ai/camel.git
189
+ git clone -b v0.1.5.4 https://github.com/camel-ai/camel.git
190
190
 
191
191
  # Change directory into project directory
192
192
  cd camel
@@ -5,25 +5,22 @@ camel/agents/chat_agent.py,sha256=yeSSVTnKbRmA7DUFv2waaPz3rMM6z-Gevi0DoYQ8-Uo,27
5
5
  camel/agents/critic_agent.py,sha256=M3XNxRS0wAs5URjc_0kvtXqUlD-KpXq3L5ADz-KCKGU,7199
6
6
  camel/agents/deductive_reasoner_agent.py,sha256=8R9hY_yCr_guq_ySuIE3eaYbiPeHVrsh6HKqIWrR0zY,13180
7
7
  camel/agents/embodied_agent.py,sha256=Mm2-wvcpduXOvsHMBcavroACyvK06Mxe6QYTf80tdfI,7160
8
- camel/agents/knowledge_graph_agent.py,sha256=WvKee0ja-vqB4L38pu7c8iqgExSTI7bgHP78D7zOpvY,8770
8
+ camel/agents/knowledge_graph_agent.py,sha256=h3LdqqX0KPPyq5v9O4WXZTdcyS2Exz5cMGZPei38ZNo,8818
9
9
  camel/agents/role_assignment_agent.py,sha256=IWfu5b2RW1gYziffskErhdmybJOusVvhb9gqLF9_5mw,4800
10
10
  camel/agents/search_agent.py,sha256=TMyV2LoBVB0hMnSex6q7xbyLRGsF_EMKxCZ8xbZBX9o,4404
11
11
  camel/agents/task_agent.py,sha256=aNpn8bYoe2VlVSlWfbV6ynI5zG9pXq6V5NcppqJGVlU,14253
12
12
  camel/agents/tool_agents/__init__.py,sha256=ulTNWU2qoFGe3pvVmCq_sdfeSX3NKZ0due66TYvsL-M,862
13
13
  camel/agents/tool_agents/base.py,sha256=nQAhfWi8a_bCgzlf5-G-tmj1fKm6AjpRc89NQkWwpnc,1399
14
14
  camel/agents/tool_agents/hugging_face_tool_agent.py,sha256=1Z5tG6f_86eL0vmtRZ-BJvoLDFFLhoHt8JtDvgat1xU,8723
15
- camel/bots/__init__.py,sha256=DGgIhb7Gr_ShnAldq-4wAXucOdSvKtiV3m6e9G10rbA,834
16
- camel/bots/discord_bot.py,sha256=y4rUyKgeowBpkMkhK29UKyE-DPfJhoouh7onqh7NzXE,3595
17
- camel/bots/telegram_bot.py,sha256=bekO5vQcd62UcyUmEbdiSMJao9CWDsu3Okb6bXXQFUg,2890
18
15
  camel/configs/__init__.py,sha256=9yc5rMGH_FHYCRyC89vmtozNi7RGhN8XHLXxtnIzRh4,1170
19
16
  camel/configs/anthropic_config.py,sha256=zD7VMFUw4s7wmBlr64oSXxpEUkhp7wj9mvAd0WK2zFc,3308
20
17
  camel/configs/base_config.py,sha256=CEF8ryl_dkH6LgOhwuP5_EgjaWCUCB-E3GcMWR-2YFE,870
21
18
  camel/configs/litellm_config.py,sha256=6nghqAD1G7nsvW6W56LHpSKEnJyRiCLEcLgtzpPr-ac,5542
22
19
  camel/configs/openai_config.py,sha256=tFEiPDQ8Cdvkfds83T7_5osNikwA3NuRGbpjV0wq4Ao,7593
23
20
  camel/embeddings/__init__.py,sha256=9TI7392iYxrlYYerPoboDBOFvpEmP_nSSgtEjks1vJQ,1034
24
- camel/embeddings/base.py,sha256=nauXLNEJlPnk2sKigFzvNTk_RKsC_2l_EQiyPyj_ATo,2208
25
- camel/embeddings/openai_embedding.py,sha256=nlBIlbTqps34OT-ydrA1CUYOOZMJqbNSsqyjCx-16wM,2885
26
- camel/embeddings/sentence_transformers_embeddings.py,sha256=BbgrBHrT8ACrID3RCaALIfuXAHGJG9jcuWu6W-Gd93I,2372
21
+ camel/embeddings/base.py,sha256=deX70VXGmWGRAPal3HheXvMaarymRR5I1i90KPWGWXs,2196
22
+ camel/embeddings/openai_embedding.py,sha256=o16yl8uULjOoPB5DFuNGd6JDIIaQyGCrkj2LBaDEj6g,3324
23
+ camel/embeddings/sentence_transformers_embeddings.py,sha256=ayYIBOADdmmhlmo1iZS8tI_mZ-rX0sxjljyQpkuftcw,2730
27
24
  camel/embeddings/vlm_embedding.py,sha256=VvD_b737snNrZTRE4ejFvWLjd_YT1DCTKl8yKIgRM-g,5436
28
25
  camel/functions/__init__.py,sha256=3d1ZI3xx67DvHeBQhQQAu7IwTohC6Sa-_EPZeDE8_50,1737
29
26
  camel/functions/google_maps_function.py,sha256=AmhlIyqkrkZF6Vb4O-wdtEKTQjRh5mMjHjS56ciGgjk,12468
@@ -111,7 +108,7 @@ camel/prompts/translation.py,sha256=V_40Ko2is5dAOCZ8DzsHo6DO7l8_jnEV9KjCKH7GxtY,
111
108
  camel/responses/__init__.py,sha256=edtTQskOgq5obyITziRFL62HTJP9sAikAtP9vrFacEQ,795
112
109
  camel/responses/agent_responses.py,sha256=UsTZHi4jPs2wfChPQWttVNyHneoGdQtdrRouatywE4w,1714
113
110
  camel/retrievers/__init__.py,sha256=CuP3B77zl2PoF-W2y9xSkTGRzoK2J4TlUHdCtuJD8dg,1059
114
- camel/retrievers/auto_retriever.py,sha256=malgItbxMWYhg7LAw8BuZl-osmbriG7BPtzvPYxI5UE,13469
111
+ camel/retrievers/auto_retriever.py,sha256=3UPGsGXIkEclg75Fj-EbW0Y8_jrBK8Li2lA0NBn-O-8,13467
115
112
  camel/retrievers/base.py,sha256=sgqaJDwIkWluEgPBlukFN7RYZJnrp0imCAOEWm6bZ40,2646
116
113
  camel/retrievers/bm25_retriever.py,sha256=-aWMZBF_WqSeyk_0Gcf9x4B12ywSBwHScSzxQmFZkXw,5199
117
114
  camel/retrievers/cohere_rerank_retriever.py,sha256=jDAo5OxAWZBQhgH9cSo0_3h057AN4z6_oDMIy6HZvik,4142
@@ -122,7 +119,7 @@ camel/societies/role_playing.py,sha256=C5hQIPH8gwP7_dkh65nOPplsw50lYQiYXk-aapODq
122
119
  camel/storages/__init__.py,sha256=crRaZKmgvs8RCzfffREYIVo09J4q_HVu44JGb4CJMfo,1480
123
120
  camel/storages/graph_storages/__init__.py,sha256=vsJZkedaCS-cLQ-KgMqio8cxXvbousBWVqzZJvlimT8,897
124
121
  camel/storages/graph_storages/base.py,sha256=-Ys1BIuz4H5FvYMZTBIjg8Cfv40CPQ-OsovwMzygEgU,2858
125
- camel/storages/graph_storages/graph_element.py,sha256=fQNxY-BHCRlTT9I_VY3NODysxW4vuqk-zjvTCMwAoH4,2356
122
+ camel/storages/graph_storages/graph_element.py,sha256=cz3eQdSockPsJwEVo6R_X_QeuS81_x5XrZjpzK1Q7cw,2599
126
123
  camel/storages/graph_storages/neo4j_graph.py,sha256=wvOiHLsMPN5dTIBk97oOyyAhwU7TJHxFRaMsBimt25k,22077
127
124
  camel/storages/key_value_storages/__init__.py,sha256=lZOFtqj1iTQ9pRB4DkCYSMyPwEwaJDVzU06kM5jxFd4,916
128
125
  camel/storages/key_value_storages/base.py,sha256=knxni8WiyTXJ2emZQO-JIsbxw6Ei7EO6dj-bU2YCoSY,2183
@@ -140,12 +137,12 @@ camel/toolkits/__init__.py,sha256=2-z9eGt53U6_1uwMtiu0-GgU7k5iFkS3HEMXuB3Qs2A,83
140
137
  camel/toolkits/base.py,sha256=znjnZtgxA5gbT7OMnrKQF_a9FK3A7Xk5s_lP94u76vI,923
141
138
  camel/toolkits/github_toolkit.py,sha256=ZBShnR7Vc3xQhQiTHsiF2esyBn7JEJxldvlgg-Cnsgk,11631
142
139
  camel/types/__init__.py,sha256=ArKXATj3z_Vv4ISmROVeo6Mv3tj5kE1dTkqfgwyxVY4,1975
143
- camel/types/enums.py,sha256=qcpDy5pnI_-5LoQyWtRQeVID5X2bSCFQv7NFUjFY1lE,10909
140
+ camel/types/enums.py,sha256=nGxWYhGuZkbNfampLcmKrRIlHXuDD085CZXuajAn1KA,10858
144
141
  camel/types/openai_types.py,sha256=BNQ6iCzKTjSvgcXFsAFIgrUS_YUFZBU6bDoyAp387hI,2045
145
142
  camel/utils/__init__.py,sha256=qFRBTiHE_QXYDSQoNecobtJYSFuNHEULx7nr00Q1S6Y,1827
146
143
  camel/utils/commons.py,sha256=1p50ci5bnX1sQdJG_bewGbG6WKwR220YrCr3yoJmtu0,12110
147
144
  camel/utils/constants.py,sha256=ZIw5ILfOyJFyjEAYrbJMANeg1_EZI-zMK_xVrkwALbM,1105
148
145
  camel/utils/token_counting.py,sha256=_eX314B0ikffz76bUwnN7xbLGnHJ3rezvesxwPNwfQ0,14410
149
- camel_ai-0.1.5.3.dist-info/METADATA,sha256=dQemzv34rEPO-VZ7CEswERffe8-Ja_MZgZ0rdWk9G0k,21608
150
- camel_ai-0.1.5.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
151
- camel_ai-0.1.5.3.dist-info/RECORD,,
146
+ camel_ai-0.1.5.4.dist-info/METADATA,sha256=WYQIg_PPHVlLYtw61If3DhtVye-75emt2B5dpcz0_Wk,21613
147
+ camel_ai-0.1.5.4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
148
+ camel_ai-0.1.5.4.dist-info/RECORD,,
camel/bots/__init__.py DELETED
@@ -1,20 +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
- from .discord_bot import DiscordBot
15
- from .telegram_bot import TelegramBot
16
-
17
- __all__ = [
18
- 'DiscordBot',
19
- 'TelegramBot',
20
- ]
camel/bots/discord_bot.py DELETED
@@ -1,103 +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 typing import TYPE_CHECKING, List, Optional
16
-
17
- from camel.agents import ChatAgent
18
- from camel.messages import BaseMessage
19
-
20
- if TYPE_CHECKING:
21
- from discord import Message
22
-
23
-
24
- class DiscordBot:
25
- r"""Represents a Discord bot that is powered by an agent.
26
-
27
- Attributes:
28
- chat_agent (ChatAgent): Chat agent that will power the bot.
29
- channel_ids (List[int], optional): The channel IDs that the bot will
30
- listen to.
31
- discord_token (str, optional): The bot token.
32
- """
33
-
34
- def __init__(
35
- self,
36
- chat_agent: ChatAgent,
37
- channel_ids: Optional[List[int]] = None,
38
- discord_token: Optional[str] = None,
39
- ) -> None:
40
- self.chat_agent = chat_agent
41
- self.token = discord_token or os.getenv('DISCORD_TOKEN')
42
- self.channel_ids = channel_ids
43
-
44
- if not self.token:
45
- raise ValueError(
46
- "`DISCORD_TOKEN` not found in environment variables. Get it"
47
- " here: `https://discord.com/developers/applications`."
48
- )
49
-
50
- try:
51
- import discord
52
- except ImportError:
53
- raise ImportError(
54
- "Please install `discord` first. You can install it by running"
55
- " `python3 -m pip install -U discord.py`."
56
- )
57
- intents = discord.Intents.default()
58
- intents.message_content = True
59
- self.client = discord.Client(intents=intents)
60
-
61
- # Register event handlers
62
- self.client.event(self.on_ready)
63
- self.client.event(self.on_message)
64
-
65
- def run(self) -> None:
66
- r"""Start the Discord bot using its token.
67
-
68
- This method starts the Discord bot by running the client with the
69
- provided token.
70
- """
71
- self.client.run(self.token) # type: ignore[arg-type]
72
-
73
- async def on_ready(self) -> None:
74
- r"""This method is called when the bot has successfully connected to
75
- the Discord server.
76
-
77
- It prints a message indicating that the bot has logged in and displays
78
- the username of the bot.
79
- """
80
- print(f'We have logged in as {self.client.user}')
81
-
82
- async def on_message(self, message: 'Message') -> None:
83
- r"""Event handler for when a message is received.
84
-
85
- Args:
86
- message (discord.Message): The message object received.
87
- """
88
- if message.author == self.client.user:
89
- return
90
-
91
- if self.channel_ids and message.channel.id not in self.channel_ids:
92
- return
93
-
94
- if not self.client.user or not self.client.user.mentioned_in(message):
95
- return
96
-
97
- self.chat_agent.reset()
98
-
99
- user_msg = BaseMessage.make_user_message(
100
- role_name="User", content=message.content
101
- )
102
- assistant_response = self.chat_agent.step(user_msg)
103
- await message.channel.send(assistant_response.msg.content)
@@ -1,84 +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 typing import TYPE_CHECKING, Optional
16
-
17
- from camel.agents import ChatAgent
18
- from camel.messages import BaseMessage
19
-
20
- # Conditionally import telebot types only for type checking
21
- if TYPE_CHECKING:
22
- from telebot.types import Message # type: ignore[import-untyped]
23
-
24
-
25
- class TelegramBot:
26
- r"""Represents a Telegram bot that is powered by an agent.
27
-
28
- Attributes:
29
- chat_agent (ChatAgent): Chat agent that will power the bot.
30
- telegram_token (str, optional): The bot token.
31
- """
32
-
33
- def __init__(
34
- self,
35
- chat_agent: ChatAgent,
36
- telegram_token: Optional[str] = None,
37
- ) -> None:
38
- self.chat_agent = chat_agent
39
-
40
- if not telegram_token:
41
- self.token = os.getenv('TELEGRAM_TOKEN')
42
- if not self.token:
43
- raise ValueError(
44
- "`TELEGRAM_TOKEN` not found in environment variables. "
45
- "Get it from t.me/BotFather."
46
- )
47
- else:
48
- self.token = telegram_token
49
-
50
- try:
51
- import telebot # type: ignore[import-untyped]
52
- except ImportError:
53
- raise ImportError(
54
- "Please install `telegram_bot` first. "
55
- "You can install it by running "
56
- "`pip install pyTelegramBotAPI`."
57
- )
58
- self.bot = telebot.TeleBot(token=self.token)
59
-
60
- # Register the message handler within the constructor
61
- self.bot.message_handler(func=lambda message: True)(self.on_message)
62
-
63
- def run(self) -> None:
64
- r"""Start the Telegram bot."""
65
- print("Telegram bot is running...")
66
- self.bot.infinity_polling()
67
-
68
- def on_message(self, message: 'Message') -> None:
69
- r"""Handles incoming messages from the user.
70
-
71
- Args:
72
- message (types.Message): The incoming message object.
73
- """
74
- self.chat_agent.reset()
75
-
76
- if not message.text:
77
- return
78
-
79
- user_msg = BaseMessage.make_user_message(
80
- role_name="User", content=message.text
81
- )
82
- assistant_response = self.chat_agent.step(user_msg)
83
-
84
- self.bot.reply_to(message, assistant_response.msg.content)