Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

feat: Add max_characters setting to RAG (#895)

Wendong-Fanbdd69fa3a807
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index c97d65010..e4201ec01 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -27,7 +27,7 @@ body:
attributes:
label: What version of camel are you using?
description: Run command `python3 -c 'print(__import__("camel").__version__)'` in your shell and paste the output here.
- placeholder: E.g., 0.1.6.8
+ placeholder: E.g., 0.1.6.9
validations:
required: true
diff --git a/README.md b/README.md
index 67c29ef5a..30dfaea55 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.1.6.8 https://github.com/camel-ai/camel.git
+git clone -b v0.1.6.9 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/camel/__init__.py b/camel/__init__.py
index bb6495c27..3690856b8 100644
--- a/camel/__init__.py
+++ b/camel/__init__.py
@@ -12,7 +12,7 @@
# limitations under the License.
# =========== Copyright 2023 @ CAMEL-AI.org. All Rights Reserved. ===========
-__version__ = '0.1.6.8'
+__version__ = '0.1.6.9'
__all__ = [
'__version__',
diff --git a/camel/retrievers/auto_retriever.py b/camel/retrievers/auto_retriever.py
index 2572cca58..af4cada9b 100644
--- a/camel/retrievers/auto_retriever.py
+++ b/camel/retrievers/auto_retriever.py
@@ -181,6 +181,7 @@ class AutoRetriever:
top_k: int = DEFAULT_TOP_K_RESULTS,
similarity_threshold: float = DEFAULT_SIMILARITY_THRESHOLD,
return_detailed_info: bool = False,
+ max_characters: int = 500,
) -> dict[str, Sequence[Collection[str]]]:
r"""Executes the automatic vector retriever process using vector
storage.
@@ -198,6 +199,8 @@ class AutoRetriever:
return_detailed_info (bool, optional): Whether to return detailed
information including similarity score, content path and
metadata. Defaults to `False`.
+ max_characters (int): Max number of characters in each chunk.
+ Defaults to `500`.
Returns:
dict[str, Sequence[Collection[str]]]: By default, returns
@@ -262,7 +265,7 @@ class AutoRetriever:
storage=vector_storage_instance,
embedding_model=self.embedding_model,
)
- vr.process(content)
+ vr.process(content=content, max_characters=max_characters)
else:
vr = VectorRetriever(
storage=vector_storage_instance,
diff --git a/camel/retrievers/vector_retriever.py b/camel/retrievers/vector_retriever.py
index 5ba1d2ef3..f58bfd162 100644
--- a/camel/retrievers/vector_retriever.py
+++ b/camel/retrievers/vector_retriever.py
@@ -76,6 +76,7 @@ class VectorRetriever(BaseRetriever):
self,
content: Union[str, Element],
chunk_type: str = "chunk_by_title",
+ max_characters: int = 500,
**kwargs: Any,
) -> None:
r"""Processes content from a file or URL, divides it into chunks by
@@ -87,6 +88,8 @@ class VectorRetriever(BaseRetriever):
string content or Element object.
chunk_type (str): Type of chunking going to apply. Defaults to
"chunk_by_title".
+ max_characters (int): Max number of characters in each chunk.
+ Defaults to `500`.
**kwargs (Any): Additional keyword arguments for content parsing.
"""
if isinstance(content, Element):
@@ -101,7 +104,9 @@ class VectorRetriever(BaseRetriever):
elements = [self.uio.create_element_from_text(text=content)]
if elements:
chunks = self.uio.chunk_elements(
- chunk_type=chunk_type, elements=elements
+ chunk_type=chunk_type,
+ elements=elements,
+ max_characters=max_characters,
)
if not elements:
warnings.warn(
diff --git a/docs/conf.py b/docs/conf.py
index 64ce11737..e6b8d12d8 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -27,7 +27,7 @@ sys.path.insert(0, os.path.abspath('..'))
project = 'CAMEL'
copyright = '2023, CAMEL-AI.org'
author = 'CAMEL-AI.org'
-release = '0.1.6.8'
+release = '0.1.6.9'
html_favicon = (
'https://raw.githubusercontent.com/camel-ai/camel/master/misc/favicon.png'
diff --git a/docs/get_started/setup.md b/docs/get_started/setup.md
index e030e0a1b..f4144e2ff 100644
--- a/docs/get_started/setup.md
+++ b/docs/get_started/setup.md
@@ -61,7 +61,7 @@ conda create --name camel python=3.10
conda activate camel
# Clone github repo
-git clone -b v0.1.6.8 https://github.com/camel-ai/camel.git
+git clone -b v0.1.6.9 https://github.com/camel-ai/camel.git
# Change directory into project directory
cd camel
diff --git a/pyproject.toml b/pyproject.toml
index 6cd5bc21c..fa02ccfea 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "camel-ai"
-version = "0.1.6.8"
+version = "0.1.6.9"
authors = ["CAMEL-AI.org"]
description = "Communicative Agents for AI Society Study"
readme = "README.md"