🐫 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: AutoRAG collection naming generator uniqueness (#2532)
Wendong-Fand37cac3fd56c
diff --git a/camel/agents/mcp_agent.py b/camel/agents/mcp_agent.pyindex 49bf803c6..780950e15 100644--- a/camel/agents/mcp_agent.py+++ b/camel/agents/mcp_agent.py@@ -431,7 +431,7 @@ class MCPAgent(ChatAgent):# Use create_task and run with a futurecoro = self.astep(input_message, *args, **kwargs)future = asyncio.ensure_future(coro)- return asyncio.run_coroutine_threadsafe(future, loop).result()+ return asyncio.run_coroutine_threadsafe(future, loop).result() # type: ignore [arg-type]else:# Safe to run normallyreturn asyncio.run(self.astep(input_message, *args, **kwargs))diff --git a/camel/retrievers/auto_retriever.py b/camel/retrievers/auto_retriever.pyindex a2111b101..c31a83bfb 100644--- a/camel/retrievers/auto_retriever.py+++ b/camel/retrievers/auto_retriever.py@@ -128,12 +128,31 @@ class AutoRetriever:Returns:str: A sanitized, valid collection name suitable for use."""+ import hashlib+ import os+from unstructured.documents.elements import Elementif isinstance(content, Element):content = content.metadata.file_directory or str(uuid.uuid4())- collection_name = re.sub(r'[^a-zA-Z0-9]', '', content)[:20]+ # For file paths, use a combination of directory hash and filename+ if os.path.isfile(content):+ # Get directory and filename+ directory = os.path.dirname(content)+ filename = os.path.basename(content)+ # Create a short hash of the directory path+ dir_hash = hashlib.md5(directory.encode()).hexdigest()[:6]+ # Get filename without extension and remove special chars+ base_name = os.path.splitext(filename)[0]+ clean_name = re.sub(r'[^a-zA-Z0-9]', '', base_name)[:10]+ # Combine for a unique name+ collection_name = f"{clean_name}_{dir_hash}"+ else:+ # For URL content+ content_hash = hashlib.md5(content.encode()).hexdigest()[:6]+ clean_content = re.sub(r'[^a-zA-Z0-9]', '', content)[-10:]+ collection_name = f"{clean_content}_{content_hash}"# Ensure the first character is either an underscore or a letter for# Milvusdiff --git a/docs/mintlify/reference/camel.toolkits.pptx_toolkit.mdx b/docs/mintlify/reference/camel.toolkits.pptx_toolkit.mdxindex a8b5321f3..37f1c1cd1 100644--- a/docs/mintlify/reference/camel.toolkits.pptx_toolkit.mdx+++ b/docs/mintlify/reference/camel.toolkits.pptx_toolkit.mdx@@ -8,7 +8,8 @@class PPTXToolkit(BaseToolkit):```-A toolkit for creating and writing PowerPoint presentations (PPTX files).+A toolkit for creating and writing PowerPoint presentations (PPTX+files).This class provides cross-platform support for creating PPTX files withtitle slides, content slides, text formatting, and image embedding.@@ -82,7 +83,8 @@ def _format_text():```-Apply bold and italic formatting while preserving the original word order.+Apply bold and italic formatting while preserving the original+word order.**Parameters:**@@ -97,9 +99,9 @@ Apply bold and italic formatting while preserving the original word order.```pythondef _add_bulleted_items(self,- text_frame: pptx.text.text.TextFrame,- flat_items_list: list,- set_color_to_white = False+ text_frame: 'TextFrame',+ flat_items_list: List[Tuple[str, int]],+ set_color_to_white: bool = False):```@@ -107,8 +109,8 @@ Add a list of texts as bullet points and apply formatting.**Parameters:**-- **text_frame**: The text frame where text is to be displayed.-- **flat_items_list**: The list of items to be displayed.+- **text_frame** (TextFrame): The text frame where text is to be displayed.+- **flat_items_list** (List[Tuple[str, int]]): The list of items to be displayed.- **set_color_to_white** (bool): Whether to set the font color to white. (default: :obj: `False`)<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._get_flat_list_of_contents"></a>@@ -116,33 +118,34 @@ Add a list of texts as bullet points and apply formatting.### _get_flat_list_of_contents```python-def _get_flat_list_of_contents(self, items: list, level: int):+def _get_flat_list_of_contents(self, items: List[Union[str, List[Any]]], level: int):```Flatten a hierarchical list of bullet points to a single list.**Parameters:**-- **items**: A bullet point (string or list).-- **level**: The current level of hierarchy.+- **items** (List[Union[str, List[Any]]]): A bullet point (string or list).+- **level** (int): The current level of hierarchy.**Returns:**- List[Tuple]: A list of (bullet item text, hierarchical level) tuples.+ List[Tuple[str, int]]: A list of (bullet item text, hierarchical+level) tuples.<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._get_slide_width_height_inches"></a>### _get_slide_width_height_inches```python-def _get_slide_width_height_inches(self, presentation: Any):+def _get_slide_width_height_inches(self, presentation: 'presentation.Presentation'):```Get the dimensions of a slide in inches.**Parameters:**-- **presentation**: The presentation object.+- **presentation** (presentation.Presentation): The presentation object.**Returns:**@@ -166,8 +169,8 @@ Write text content to a PPTX file with enhanced formatting.**Parameters:**- **file_path** (Path): The target file path.-- **content** (List[Dict[str, Any]]): The content to write to the PPTX file. Must be a list of dictionaries where: - First element: Title slide with keys 'title' and 'subtitle' - Subsequent elements: Content slides with keys 'title', 'text' (optional)-- **template** (Optional[str]): The name of the template to use. If not provided, the default template will be used.+- **content** (List[Dict[str, Any]]): The content to write to the PPTX file. Must be a list of dictionaries where: - First element: Title slide with keys 'title' and 'subtitle' - Subsequent elements: Content slides with keys 'title', 'text'+- **template** (Optional[str]): The name of the template to use. If not provided, the default template will be used. (default: :obj: `None`)<a id="camel.toolkits.pptx_toolkit.PPTXToolkit.create_presentation"></a>@@ -188,54 +191,50 @@ Create a PowerPoint presentation (PPTX) file.- **content** (str): The content to write to the PPTX file as a JSON string. Must represent a list of dictionaries with the following structure: - First dict: title slide `{"title": str, "subtitle": str}` - Other dicts: content slides, which can be one of: * Bullet/step slides: `{"heading": str, "bullet_points": list of str or nested lists, "img_keywords": str (optional)}` - If any bullet point starts with '>> ', it will be rendered as a step-by-step process. - "img_keywords" can be a URL or search keywords for an image (optional). * Table slides: `{"heading": str, "table": {"headers": list of str, "rows": list of list of str}}`- **filename** (str): The name or path of the file. If a relative path is supplied, it is resolved to self.output_dir.-- **template** (Optional[str]): The path to the template PPTX file. Initializes a presentation from a given template file Or PPTX file.+- **template** (Optional[str]): The path to the template PPTX file. Initializes a presentation from a given template file Or PPTX file. (default: :obj: `None`)**Returns:**str: A success message indicating the file was created.-<a id="camel.toolkits.pptx_toolkit.PPTXToolkit.get_tools"></a>--### get_tools--```python-def get_tools(self):-```--**Returns:**-- List[FunctionTool]: A list of FunctionTool objects-representing the functions in the toolkit.-<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._handle_default_display"></a>### _handle_default_display```python-def _handle_default_display(self, presentation: Any, slide_json: dict):+def _handle_default_display(+ self,+ presentation: 'presentation.Presentation',+ slide_json: Dict[str, Any]+):```Display a list of text in a slide.**Parameters:**-- **presentation**: The presentation object.-- **slide_json**: The content of the slide as JSON data.+- **presentation** (presentation.Presentation): The presentation object.+- **slide_json** (Dict[str, Any]): The content of the slide as JSON data.<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._handle_display_image__in_foreground"></a>### _handle_display_image__in_foreground```python-def _handle_display_image__in_foreground(self, presentation: Any, slide_json: dict):+def _handle_display_image__in_foreground(+ self,+ presentation: 'presentation.Presentation',+ slide_json: Dict[str, Any]+):```-Create a slide with text and image using a picture placeholder layout.+Create a slide with text and image using a picture placeholder+layout.**Parameters:**-- **presentation**: The presentation object.-- **slide_json**: The content of the slide as JSON data.+- **presentation** (presentation.Presentation): The presentation object.+- **slide_json** (Dict[str, Any]): The content of the slide as JSON data.**Returns:**@@ -246,15 +245,19 @@ Create a slide with text and image using a picture placeholder layout.### _handle_table```python-def _handle_table(self, presentation: Any, slide_json: dict):+def _handle_table(+ self,+ presentation: 'presentation.Presentation',+ slide_json: Dict[str, Any]+):```Add a table to a slide.**Parameters:**-- **presentation**: The presentation object.-- **slide_json**: The content of the slide as JSON data.+- **presentation** (presentation.Presentation): The presentation object.+- **slide_json** (Dict[str, Any]): The content of the slide as JSON data.<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._handle_step_by_step_process"></a>@@ -263,8 +266,8 @@ Add a table to a slide.```pythondef _handle_step_by_step_process(self,- presentation: Any,- slide_json: dict,+ presentation: 'presentation.Presentation',+ slide_json: Dict[str, Any],slide_width_inch: float,slide_height_inch: float):@@ -274,10 +277,10 @@ Add shapes to display a step-by-step process in the slide.**Parameters:**-- **presentation**: The presentation object.-- **slide_json**: The content of the slide as JSON data.-- **slide_width_inch**: The width of the slide in inches.-- **slide_height_inch**: The height of the slide in inches.+- **presentation** (presentation.Presentation): The presentation object.+- **slide_json** (Dict[str, Any]): The content of the slide as JSON data.+- **slide_width_inch** (float): The width of the slide in inches.+- **slide_height_inch** (float): The height of the slide in inches.<a id="camel.toolkits.pptx_toolkit.PPTXToolkit._remove_slide_number_from_heading"></a>@@ -291,7 +294,7 @@ Remove the slide number from a given slide header.**Parameters:**-- **header**: The header of a slide.+- **header** (str): The header of a slide.**Returns:**@@ -302,16 +305,29 @@ Remove the slide number from a given slide header.### _get_slide_placeholders```python-def _get_slide_placeholders(self, slide: Any, layout_number: int):+def _get_slide_placeholders(self, slide: 'Slide'):```Return the index and name of all placeholders present in a slide.**Parameters:**-- **slide**: The slide.-- **layout_number**: The layout number used by the slide.+- **slide** (Slide): The slide.++**Returns:**++ List[Tuple[int, str]]: A list containing placeholders (idx, name)+tuples.++<a id="camel.toolkits.pptx_toolkit.PPTXToolkit.get_tools"></a>++### get_tools++```python+def get_tools(self):+```**Returns:**- List[Tuple[int, str]]: A list containing placeholders (idx, name) tuples.+ List[FunctionTool]: A list of FunctionTool objects+representing the functions in the toolkit.