camel-ai 0.2.4__py3-none-any.whl → 0.2.4a0__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 +1 -1
- camel/retrievers/auto_retriever.py +87 -1
- {camel_ai-0.2.4.dist-info → camel_ai-0.2.4a0.dist-info}/METADATA +2 -2
- {camel_ai-0.2.4.dist-info → camel_ai-0.2.4a0.dist-info}/RECORD +6 -6
- {camel_ai-0.2.4.dist-info → camel_ai-0.2.4a0.dist-info}/LICENSE +0 -0
- {camel_ai-0.2.4.dist-info → camel_ai-0.2.4a0.dist-info}/WHEEL +0 -0
camel/__init__.py
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
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
|
+
import datetime
|
|
15
|
+
import os
|
|
14
16
|
import re
|
|
15
17
|
import uuid
|
|
16
18
|
from typing import (
|
|
@@ -29,6 +31,7 @@ from camel.storages import (
|
|
|
29
31
|
BaseVectorStorage,
|
|
30
32
|
MilvusStorage,
|
|
31
33
|
QdrantStorage,
|
|
34
|
+
VectorDBQuery,
|
|
32
35
|
)
|
|
33
36
|
from camel.types import StorageType
|
|
34
37
|
from camel.utils import Constants
|
|
@@ -123,6 +126,62 @@ class AutoRetriever:
|
|
|
123
126
|
|
|
124
127
|
return collection_name
|
|
125
128
|
|
|
129
|
+
def _get_file_modified_date_from_file(
|
|
130
|
+
self, content_input_path: str
|
|
131
|
+
) -> str:
|
|
132
|
+
r"""Retrieves the last modified date and time of a given file. This
|
|
133
|
+
function takes a file path as input and returns the last modified date
|
|
134
|
+
and time of that file.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
content_input_path (str): The file path of the content whose
|
|
138
|
+
modified date is to be retrieved.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
str: The last modified time from file.
|
|
142
|
+
"""
|
|
143
|
+
mod_time = os.path.getmtime(content_input_path)
|
|
144
|
+
readable_mod_time = datetime.datetime.fromtimestamp(
|
|
145
|
+
mod_time
|
|
146
|
+
).isoformat(timespec='seconds')
|
|
147
|
+
return readable_mod_time
|
|
148
|
+
|
|
149
|
+
def _get_file_modified_date_from_storage(
|
|
150
|
+
self, vector_storage_instance: BaseVectorStorage
|
|
151
|
+
) -> str:
|
|
152
|
+
r"""Retrieves the last modified date and time of a given file. This
|
|
153
|
+
function takes vector storage instance as input and returns the last
|
|
154
|
+
modified date from the metadata.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
vector_storage_instance (BaseVectorStorage): The vector storage
|
|
158
|
+
where modified date is to be retrieved from metadata.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
str: The last modified date from vector storage.
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
# Insert any query to get modified date from vector db
|
|
165
|
+
# NOTE: Can be optimized when CAMEL vector storage support
|
|
166
|
+
# direct chunk payload extraction
|
|
167
|
+
query_vector_any = self.embedding_model.embed(obj="any_query")
|
|
168
|
+
query_any = VectorDBQuery(query_vector_any, top_k=1)
|
|
169
|
+
result_any = vector_storage_instance.query(query_any)
|
|
170
|
+
|
|
171
|
+
# Extract the file's last modified date from the metadata
|
|
172
|
+
# in the query result
|
|
173
|
+
if result_any[0].record.payload is not None:
|
|
174
|
+
file_modified_date_from_meta = result_any[0].record.payload[
|
|
175
|
+
"metadata"
|
|
176
|
+
]['last_modified']
|
|
177
|
+
else:
|
|
178
|
+
raise ValueError(
|
|
179
|
+
"The vector storage exits but the payload is None,"
|
|
180
|
+
"please check the collection"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
return file_modified_date_from_meta
|
|
184
|
+
|
|
126
185
|
def run_vector_retriever(
|
|
127
186
|
self,
|
|
128
187
|
query: str,
|
|
@@ -187,7 +246,34 @@ class AutoRetriever:
|
|
|
187
246
|
collection_name
|
|
188
247
|
)
|
|
189
248
|
|
|
190
|
-
|
|
249
|
+
# Check the modified time of the input file path, only works
|
|
250
|
+
# for local path since no standard way for remote url
|
|
251
|
+
file_is_modified = False # initialize with a default value
|
|
252
|
+
if (
|
|
253
|
+
vector_storage_instance.status().vector_count != 0
|
|
254
|
+
and isinstance(content, str)
|
|
255
|
+
and os.path.exists(content)
|
|
256
|
+
):
|
|
257
|
+
# Get original modified date from file
|
|
258
|
+
modified_date_from_file = (
|
|
259
|
+
self._get_file_modified_date_from_file(content)
|
|
260
|
+
)
|
|
261
|
+
# Get modified date from vector storage
|
|
262
|
+
modified_date_from_storage = (
|
|
263
|
+
self._get_file_modified_date_from_storage(
|
|
264
|
+
vector_storage_instance
|
|
265
|
+
)
|
|
266
|
+
)
|
|
267
|
+
# Determine if the file has been modified since the last
|
|
268
|
+
# check
|
|
269
|
+
file_is_modified = (
|
|
270
|
+
modified_date_from_file != modified_date_from_storage
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
if (
|
|
274
|
+
vector_storage_instance.status().vector_count == 0
|
|
275
|
+
or file_is_modified
|
|
276
|
+
):
|
|
191
277
|
# Clear the vector storage
|
|
192
278
|
vector_storage_instance.clear()
|
|
193
279
|
# Process and store the content to the vector storage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: camel-ai
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4a0
|
|
4
4
|
Summary: Communicative Agents for AI Society Study
|
|
5
5
|
Home-page: https://www.camel-ai.org/
|
|
6
6
|
License: Apache-2.0
|
|
@@ -221,7 +221,7 @@ conda create --name camel python=3.10
|
|
|
221
221
|
conda activate camel
|
|
222
222
|
|
|
223
223
|
# Clone github repo
|
|
224
|
-
git clone -b v0.2.
|
|
224
|
+
git clone -b v0.2.4a https://github.com/camel-ai/camel.git
|
|
225
225
|
|
|
226
226
|
# Change directory into project directory
|
|
227
227
|
cd camel
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
camel/__init__.py,sha256=
|
|
1
|
+
camel/__init__.py,sha256=I4MEIgT9cQYnIJCfLDD7vczcL81hEfFuBK41Wz9bJDw,779
|
|
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=eA7kuzbfQkEdnvefxk6t_-MhB64ibSgSiQ54ztiqvJI,44764
|
|
@@ -104,7 +104,7 @@ camel/prompts/video_description_prompt.py,sha256=HRd3fHXftKwBm5QH7Tvm3FabgZPCoAv
|
|
|
104
104
|
camel/responses/__init__.py,sha256=edtTQskOgq5obyITziRFL62HTJP9sAikAtP9vrFacEQ,795
|
|
105
105
|
camel/responses/agent_responses.py,sha256=sGlGwXz2brWI-FpiU5EhVRpZvcfGWUmooAF0ukqAF3I,1771
|
|
106
106
|
camel/retrievers/__init__.py,sha256=CuP3B77zl2PoF-W2y9xSkTGRzoK2J4TlUHdCtuJD8dg,1059
|
|
107
|
-
camel/retrievers/auto_retriever.py,sha256=
|
|
107
|
+
camel/retrievers/auto_retriever.py,sha256=WJ1b-xOGu13nSqb1Sz5gs0xVRvVnbp71Lp9lXJ2Yq2Y,13010
|
|
108
108
|
camel/retrievers/base.py,sha256=sgqaJDwIkWluEgPBlukFN7RYZJnrp0imCAOEWm6bZ40,2646
|
|
109
109
|
camel/retrievers/bm25_retriever.py,sha256=Dr7Yfkjw45sovI1EVNByGIMj7KERWrr8JHlh8csSF1s,5155
|
|
110
110
|
camel/retrievers/cohere_rerank_retriever.py,sha256=HvnFqXpsX9EdBOab0kFLDyxxJnknPFMVxyQJQDlHbOA,4100
|
|
@@ -202,7 +202,7 @@ camel/workforce/task_channel.py,sha256=WE3SHp5TKaXDzKnoul9KPfk-PkBMcGT6akVId0RtW
|
|
|
202
202
|
camel/workforce/utils.py,sha256=kBrjA_k9BblJBT13kW0eQYcBDjetyjOUHMbRuh_IfPM,2270
|
|
203
203
|
camel/workforce/worker.py,sha256=oZtl3PhxgpizKy7W_wB94Qm4Z2Tw4k1SQsqAGAi_XoI,3844
|
|
204
204
|
camel/workforce/workforce.py,sha256=IV911OlzSng_qR8KafFlDvkUEzEFa6A_upTgi8kZKxI,18191
|
|
205
|
-
camel_ai-0.2.
|
|
206
|
-
camel_ai-0.2.
|
|
207
|
-
camel_ai-0.2.
|
|
208
|
-
camel_ai-0.2.
|
|
205
|
+
camel_ai-0.2.4a0.dist-info/LICENSE,sha256=id0nB2my5kG0xXeimIu5zZrbHLS6EQvxvkKkzIHaT2k,11343
|
|
206
|
+
camel_ai-0.2.4a0.dist-info/METADATA,sha256=Zv3sAPnj-Q5zRNMUAMtZPkgNpVaYPfcG2cCWmOlQ2iM,23184
|
|
207
|
+
camel_ai-0.2.4a0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
208
|
+
camel_ai-0.2.4a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|