camel-ai 0.1.6.4__py3-none-any.whl → 0.1.6.5__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.
- camel/__init__.py +1 -1
- camel/configs/gemini_config.py +0 -1
- camel/configs/groq_config.py +1 -1
- camel/configs/mistral_config.py +1 -1
- camel/loaders/unstructured_io.py +10 -9
- camel/retrievers/auto_retriever.py +15 -17
- camel/retrievers/bm25_retriever.py +9 -6
- camel/retrievers/vector_retriever.py +10 -3
- camel/toolkits/retrieval_toolkit.py +1 -1
- {camel_ai-0.1.6.4.dist-info → camel_ai-0.1.6.5.dist-info}/METADATA +2 -2
- {camel_ai-0.1.6.4.dist-info → camel_ai-0.1.6.5.dist-info}/RECORD +12 -12
- {camel_ai-0.1.6.4.dist-info → camel_ai-0.1.6.5.dist-info}/WHEEL +0 -0
camel/__init__.py
CHANGED
camel/configs/gemini_config.py
CHANGED
|
@@ -81,7 +81,6 @@ class GeminiConfig(BaseConfig):
|
|
|
81
81
|
response_mime_type: Optional[str] = None
|
|
82
82
|
response_schema: Optional[Any] = None
|
|
83
83
|
safety_settings: Optional[Any] = None
|
|
84
|
-
tools: Optional[Any] = None
|
|
85
84
|
tool_config: Optional[Any] = None
|
|
86
85
|
request_options: Optional[Any] = None
|
|
87
86
|
|
camel/configs/groq_config.py
CHANGED
|
@@ -99,7 +99,7 @@ class GroqConfig(BaseConfig):
|
|
|
99
99
|
response_format: Union[dict, NotGiven] = NOT_GIVEN
|
|
100
100
|
frequency_penalty: float = 0.0
|
|
101
101
|
user: str = ""
|
|
102
|
-
tool_choice: Optional[Union[dict[str, str], str]] = "
|
|
102
|
+
tool_choice: Optional[Union[dict[str, str], str]] = "auto"
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
GROQ_API_PARAMS = {param for param in GroqConfig.model_fields.keys()}
|
camel/configs/mistral_config.py
CHANGED
|
@@ -74,7 +74,7 @@ class MistralConfig(BaseConfig):
|
|
|
74
74
|
if not isinstance(response_format, ResponseFormat):
|
|
75
75
|
raise ValueError(
|
|
76
76
|
f"The tool {response_format} should be an instance "
|
|
77
|
-
"of `mistralai.models.
|
|
77
|
+
"of `mistralai.models.ResponseFormat`."
|
|
78
78
|
)
|
|
79
79
|
return response_format
|
|
80
80
|
|
camel/loaders/unstructured_io.py
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
14
|
import uuid
|
|
15
|
+
import warnings
|
|
15
16
|
from typing import (
|
|
16
17
|
Any,
|
|
17
18
|
Dict,
|
|
@@ -91,7 +92,7 @@ class UnstructuredIO:
|
|
|
91
92
|
def parse_file_or_url(
|
|
92
93
|
input_path: str,
|
|
93
94
|
**kwargs: Any,
|
|
94
|
-
) -> List[Element]:
|
|
95
|
+
) -> Union[List[Element], None]:
|
|
95
96
|
r"""Loads a file or a URL and parses its contents into elements.
|
|
96
97
|
|
|
97
98
|
Args:
|
|
@@ -99,12 +100,12 @@ class UnstructuredIO:
|
|
|
99
100
|
**kwargs: Extra kwargs passed to the partition function.
|
|
100
101
|
|
|
101
102
|
Returns:
|
|
102
|
-
List[Element]: List of elements after parsing the file
|
|
103
|
+
Union[List[Element],None]: List of elements after parsing the file
|
|
104
|
+
or URL if success.
|
|
103
105
|
|
|
104
106
|
Raises:
|
|
105
107
|
FileNotFoundError: If the file does not exist at the path
|
|
106
108
|
specified.
|
|
107
|
-
Exception: For any other issues during file or URL parsing.
|
|
108
109
|
|
|
109
110
|
Notes:
|
|
110
111
|
Available document types:
|
|
@@ -128,8 +129,9 @@ class UnstructuredIO:
|
|
|
128
129
|
try:
|
|
129
130
|
elements = partition_html(url=input_path, **kwargs)
|
|
130
131
|
return elements
|
|
131
|
-
except Exception
|
|
132
|
-
|
|
132
|
+
except Exception:
|
|
133
|
+
warnings.warn(f"Failed to parse the URL: {input_path}")
|
|
134
|
+
return None
|
|
133
135
|
|
|
134
136
|
else:
|
|
135
137
|
# Handling file
|
|
@@ -146,10 +148,9 @@ class UnstructuredIO:
|
|
|
146
148
|
with open(input_path, "rb") as f:
|
|
147
149
|
elements = partition(file=f, **kwargs)
|
|
148
150
|
return elements
|
|
149
|
-
except Exception
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
) from e
|
|
151
|
+
except Exception:
|
|
152
|
+
warnings.warn(f"Failed to partition the file: {input_path}")
|
|
153
|
+
return None
|
|
153
154
|
|
|
154
155
|
@staticmethod
|
|
155
156
|
def clean_text_data(
|
|
@@ -15,7 +15,7 @@ import datetime
|
|
|
15
15
|
import os
|
|
16
16
|
import re
|
|
17
17
|
from pathlib import Path
|
|
18
|
-
from typing import List, Optional, Tuple, Union
|
|
18
|
+
from typing import Collection, List, Optional, Sequence, Tuple, Union
|
|
19
19
|
from urllib.parse import urlparse
|
|
20
20
|
|
|
21
21
|
from camel.embeddings import BaseEmbedding, OpenAIEmbedding
|
|
@@ -197,7 +197,7 @@ class AutoRetriever:
|
|
|
197
197
|
top_k: int = DEFAULT_TOP_K_RESULTS,
|
|
198
198
|
similarity_threshold: float = DEFAULT_SIMILARITY_THRESHOLD,
|
|
199
199
|
return_detailed_info: bool = False,
|
|
200
|
-
) -> str:
|
|
200
|
+
) -> dict[str, Sequence[Collection[str]]]:
|
|
201
201
|
r"""Executes the automatic vector retriever process using vector
|
|
202
202
|
storage.
|
|
203
203
|
|
|
@@ -216,9 +216,10 @@ class AutoRetriever:
|
|
|
216
216
|
metadata. Defaults to `False`.
|
|
217
217
|
|
|
218
218
|
Returns:
|
|
219
|
-
|
|
220
|
-
`return_detailed_info` is
|
|
221
|
-
|
|
219
|
+
dict[str, Sequence[Collection[str]]]: By default, returns
|
|
220
|
+
only the text information. If `return_detailed_info` is
|
|
221
|
+
`True`, return detailed information including similarity
|
|
222
|
+
score, content path and metadata.
|
|
222
223
|
|
|
223
224
|
Raises:
|
|
224
225
|
ValueError: If there's an vector storage existing with content
|
|
@@ -308,20 +309,17 @@ class AutoRetriever:
|
|
|
308
309
|
# Select the 'top_k' results
|
|
309
310
|
all_retrieved_info = all_retrieved_info_sorted[:top_k]
|
|
310
311
|
|
|
311
|
-
|
|
312
|
-
retrieved_infos_text = "\n".join(
|
|
313
|
-
info['text'] for info in all_retrieved_info if 'text' in info
|
|
314
|
-
)
|
|
312
|
+
text_retrieved_info = [item['text'] for item in all_retrieved_info]
|
|
315
313
|
|
|
316
|
-
detailed_info =
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
detailed_info = {
|
|
315
|
+
"Original Query": query,
|
|
316
|
+
"Retrieved Context": all_retrieved_info,
|
|
317
|
+
}
|
|
320
318
|
|
|
321
|
-
text_info =
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
319
|
+
text_info = {
|
|
320
|
+
"Original Query": query,
|
|
321
|
+
"Retrieved Context": text_retrieved_info,
|
|
322
|
+
}
|
|
325
323
|
|
|
326
324
|
if return_detailed_info:
|
|
327
325
|
return detailed_info
|
|
@@ -74,13 +74,16 @@ class BM25Retriever(BaseRetriever):
|
|
|
74
74
|
elements = self.unstructured_modules.parse_file_or_url(
|
|
75
75
|
content_input_path, **kwargs
|
|
76
76
|
)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if elements:
|
|
78
|
+
self.chunks = self.unstructured_modules.chunk_elements(
|
|
79
|
+
chunk_type=chunk_type, elements=elements
|
|
80
|
+
)
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
# Convert chunks to a list of strings for tokenization
|
|
83
|
+
tokenized_corpus = [str(chunk).split(" ") for chunk in self.chunks]
|
|
84
|
+
self.bm25 = BM25Okapi(tokenized_corpus)
|
|
85
|
+
else:
|
|
86
|
+
self.bm25 = None
|
|
84
87
|
|
|
85
88
|
def query(
|
|
86
89
|
self,
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# limitations under the License.
|
|
13
13
|
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
|
|
14
14
|
import os
|
|
15
|
+
import warnings
|
|
15
16
|
from typing import Any, Dict, List, Optional
|
|
16
17
|
from urllib.parse import urlparse
|
|
17
18
|
|
|
@@ -89,9 +90,15 @@ class VectorRetriever(BaseRetriever):
|
|
|
89
90
|
elements = self.uio.parse_file_or_url(content, **kwargs)
|
|
90
91
|
else:
|
|
91
92
|
elements = [self.uio.create_element_from_text(text=content)]
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
if elements:
|
|
94
|
+
chunks = self.uio.chunk_elements(
|
|
95
|
+
chunk_type=chunk_type, elements=elements
|
|
96
|
+
)
|
|
97
|
+
if not elements:
|
|
98
|
+
warnings.warn(
|
|
99
|
+
f"No elements were extracted from the content: {content}"
|
|
100
|
+
)
|
|
101
|
+
return
|
|
95
102
|
# Iterate to process and store embeddings, set batch of 50
|
|
96
103
|
for i in range(0, len(chunks), 50):
|
|
97
104
|
batch_chunks = chunks[i : i + 50]
|
|
@@ -57,7 +57,7 @@ class RetrievalToolkit(BaseToolkit):
|
|
|
57
57
|
retrieved_info = auto_retriever.run_vector_retriever(
|
|
58
58
|
query=query, contents=contents, top_k=3
|
|
59
59
|
)
|
|
60
|
-
return retrieved_info
|
|
60
|
+
return str(retrieved_info)
|
|
61
61
|
|
|
62
62
|
def get_tools(self) -> List[OpenAIFunction]:
|
|
63
63
|
r"""Returns a list of OpenAIFunction objects representing the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.1.6.
|
|
3
|
+
Version: 0.1.6.5
|
|
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.
|
|
205
|
+
git clone -b v0.1.6.5 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=
|
|
1
|
+
camel/__init__.py,sha256=_XswF67MSAdq-D9Yt9KcdGCUfyMao5xMv5mp5O0rEyc,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
|
|
@@ -15,10 +15,10 @@ camel/agents/tool_agents/hugging_face_tool_agent.py,sha256=1Z5tG6f_86eL0vmtRZ-BJ
|
|
|
15
15
|
camel/configs/__init__.py,sha256=BFnU7Wwk2-O6LAVBvZQYiXF-bxataeWMVJP2Ud3zfEo,1767
|
|
16
16
|
camel/configs/anthropic_config.py,sha256=DGQoPyYrayhYQ7aSjkYYGHOZ5VdQ9qahtaS0p_GpU0Q,3294
|
|
17
17
|
camel/configs/base_config.py,sha256=gjsDACMCk-hXDBk7qkeHcpbQrWy6jbp4iyzfqgghJEk,2485
|
|
18
|
-
camel/configs/gemini_config.py,sha256=
|
|
19
|
-
camel/configs/groq_config.py,sha256
|
|
18
|
+
camel/configs/gemini_config.py,sha256=YHJSNEAIxBxPX1NAj2rWvM4OOR7vmIANH88pZO-aOsY,6880
|
|
19
|
+
camel/configs/groq_config.py,sha256=-ihiO5h4N_kUSlPNeBqIlnIkLkhC7oXsC2FYyAqtKp0,5755
|
|
20
20
|
camel/configs/litellm_config.py,sha256=77k7HT-0s9Sq_g4KeDjL_MZId0Tx5TB8oupIyGQHx08,4692
|
|
21
|
-
camel/configs/mistral_config.py,sha256=
|
|
21
|
+
camel/configs/mistral_config.py,sha256=G9LuY0-3S6az-8j8kpqB-4asgoaxTOsZVYeZBYJl6LI,3634
|
|
22
22
|
camel/configs/ollama_config.py,sha256=xrT-ulqvANjIu0bVxOzN93uaKUs8e2gW1tmYK1jULEM,4357
|
|
23
23
|
camel/configs/openai_config.py,sha256=yQf7lkBcYTtCNAopow3SlZgcDMlMkiCpC5Dvhh9wb9M,7327
|
|
24
24
|
camel/configs/vllm_config.py,sha256=jfeveBnlkkBHC2RFkffG6ZlTkGzkwrX_WXMwHkg36Jg,5516
|
|
@@ -42,7 +42,7 @@ camel/loaders/__init__.py,sha256=ClE516UbyUes6Zut8CCiH0zWqFwwpgEcP9ur3dte8iU,949
|
|
|
42
42
|
camel/loaders/base_io.py,sha256=xzK67fqx66eYaM6fMXRJiSZfwKhFVNQmzuKURPtTzhk,10339
|
|
43
43
|
camel/loaders/firecrawl_reader.py,sha256=AJhZB2C0FTFwEVCW3UVo4Zp100Yqjeo9cRSqnayQA_g,7173
|
|
44
44
|
camel/loaders/jina_url_reader.py,sha256=ur_2Z3NFrz5AbPFi5REyZh5fISkJ9H_UZV4gtmOSO04,3607
|
|
45
|
-
camel/loaders/unstructured_io.py,sha256=
|
|
45
|
+
camel/loaders/unstructured_io.py,sha256=cY-5mqViE5Sobr3dnbK-KYcXjalUfeDfb8Yk6yOsu_g,16330
|
|
46
46
|
camel/memories/__init__.py,sha256=ml1Uj4Y_1Q2LfrTXOY38niF0x1H-N-u_zoN_VvR939U,1364
|
|
47
47
|
camel/memories/agent_memories.py,sha256=pzmjztFXPyNpabMWLi_-oJljMkYQvDP_s6Yq5U0hVEs,6097
|
|
48
48
|
camel/memories/base.py,sha256=kbyAmKkOfFdOKfHxwao8bIAbRSuOEXyzxPFd0NlvUCE,5003
|
|
@@ -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=
|
|
95
|
+
camel/retrievers/auto_retriever.py,sha256=YnhqzmpjbfNFwdj-eCwV2XVTaG64KgBKuVdfEIpoaJI,13130
|
|
96
96
|
camel/retrievers/base.py,sha256=sgqaJDwIkWluEgPBlukFN7RYZJnrp0imCAOEWm6bZ40,2646
|
|
97
|
-
camel/retrievers/bm25_retriever.py,sha256=
|
|
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=
|
|
99
|
+
camel/retrievers/vector_retriever.py,sha256=Jj2g98dP_r3nL13PrPp5DjPAHrru5aaM0jznaOM8WL0,7490
|
|
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
|
|
@@ -160,7 +160,7 @@ camel/toolkits/open_api_specs/web_scraper/paths/__init__.py,sha256=f3LXNDzN2XWWo
|
|
|
160
160
|
camel/toolkits/open_api_specs/web_scraper/paths/scraper.py,sha256=SQGbFkshLN4xm-Ya49ssbSvaU1nFVNFYhWsEPYVeFe0,1123
|
|
161
161
|
camel/toolkits/open_api_toolkit.py,sha256=rbQrhY6gHoZi9kiX9138pah9qZ2S8K5Vex1zFGWeCK8,23403
|
|
162
162
|
camel/toolkits/openai_function.py,sha256=eaE441qxLvuRKr_WrpYLGkr5P2Nav07VVdR29n76RkU,14767
|
|
163
|
-
camel/toolkits/retrieval_toolkit.py,sha256=
|
|
163
|
+
camel/toolkits/retrieval_toolkit.py,sha256=D16yeJX1WscWfXqeI7b_Y-x9UmaJdwn5ymnbv61jUks,2984
|
|
164
164
|
camel/toolkits/search_toolkit.py,sha256=vXe026bQpLic09iwY5PN4RS6SXeHYBBkjfnOlJYB670,12943
|
|
165
165
|
camel/toolkits/slack_toolkit.py,sha256=JdgDJe7iExTmG7dDXOG6v5KpVjZ6_My_d_WFTYSxkw4,10839
|
|
166
166
|
camel/toolkits/twitter_toolkit.py,sha256=oQw8wRkU7iDxaocsmWvio4pU75pmq6FJAorPdQ2xEAE,19810
|
|
@@ -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.
|
|
187
|
-
camel_ai-0.1.6.
|
|
188
|
-
camel_ai-0.1.6.
|
|
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,,
|
|
File without changes
|