🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: Remove collection name generator in auto_retriever (#872)
Wendong-Fanc936461b0008
diff --git a/camel/retrievers/auto_retriever.py b/camel/retrievers/auto_retriever.pyindex 4cbc2c4bc..2572cca58 100644--- a/camel/retrievers/auto_retriever.py+++ b/camel/retrievers/auto_retriever.py@@ -14,9 +14,7 @@import datetimeimport osimport re-from pathlib import Pathfrom typing import Collection, List, Optional, Sequence, Tuple, Union-from urllib.parse import urlparsefrom camel.embeddings import BaseEmbedding, OpenAIEmbeddingfrom camel.retrievers.vector_retriever import VectorRetriever@@ -112,35 +110,12 @@ class AutoRetriever:Returns:str: A sanitized, valid collection name suitable for use."""+if isinstance(content, Element):content = content.metadata.file_directory- # Check if the content is URL- parsed_url = urlparse(content)- is_url = all([parsed_url.scheme, parsed_url.netloc])-- # Convert given path into a collection name, ensuring it only- # contains numbers, letters, and underscores- if is_url:- # For URLs, remove https://, replace /, and any characters not- # allowed by Milvus with _- collection_name = re.sub(- r'[^0-9a-zA-Z]+',- '_',- content.replace("https://", ""),- )- elif os.path.exists(content):- # For file paths, get the stem and replace spaces with _, also- # ensuring only allowed characters are present- collection_name = re.sub(r'[^0-9a-zA-Z]+', '_', Path(content).stem)- else:- # the content is string input- collection_name = content[:10]+ collection_name = re.sub(r'[^a-zA-Z0-9]', '', content)[:20]- # Ensure the collection name does not start or end with underscore- collection_name = collection_name.strip("_")- # Limit the maximum length of the collection name to 30 characters- collection_name = collection_name[:30]return collection_namedef _get_file_modified_date_from_file(