🐫 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
[BUG] duplicated documentation for agent (#513)
Wendong-Fan9456de3e9dbc
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex b8b2a22b7..991e71616 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -1,6 +1,6 @@🐫 **Welcome to CAMEL!** 🐫-Thank you for your interest in contributing to the CAMEL project! 🎉 We're excited to have your support. As an open-source initiative in a rapidly evolving and open-ended field, we wholeheartedly welcome contributions of all kinds. Whether you want to introduce new features, enhance the infrastructure, improve documentation, asking issues, add more examples, implement state-of-the-art research ideas, or fix bugs, we appreciate your enthusiasm and efforts. 🙌 You are welcome to join our [slack](https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA) for more efficient communication. 💬+Thank you for your interest in contributing to the CAMEL project! 🎉 We're excited to have your support. As an open-source initiative in a rapidly evolving and open-ended field, we wholeheartedly welcome contributions of all kinds. Whether you want to introduce new features, enhance the infrastructure, improve documentation, asking issues, add more examples, implement state-of-the-art research ideas, or fix bugs, we appreciate your enthusiasm and efforts. 🙌 You are welcome to join our [slack](https://join.slack.com/t/camel-ai/shared_invite/zt-2g7xc41gy-_7rcrNNAArIP6sLQqldkqQ) for more efficient communication. 💬## Guidelines 📝diff --git a/README.md b/README.mdindex 32f94677e..6558da904 100644--- a/README.md+++ b/README.md@@ -122,7 +122,7 @@ pip install -e .[all] # (Optional)## Example-You can find a list of tasks for different set of assistant and user role pairs [here](https://drive.google.com/file/d/194PPaSTBR07m-PzjS-Ty6KlPLdFIPQDd/view?usp=share_link).+You can find a list of tasks for different sets of assistant and user role pairs [here](https://drive.google.com/file/d/194PPaSTBR07m-PzjS-Ty6KlPLdFIPQDd/view?usp=share_link).As an example, to run the `role_playing.py` script:@@ -282,7 +282,7 @@ For more information please contact [email protected].[colab-image]: https://colab.research.google.com/assets/colab-badge.svg[huggingface-url]: https://huggingface.co/camel-ai[huggingface-image]: https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-CAMEL--AI-ffc107?color=ffc107&logoColor=white-[slack-url]: https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA+[slack-url]: https://join.slack.com/t/camel-ai/shared_invite/zt-2g7xc41gy-_7rcrNNAArIP6sLQqldkqQ[slack-image]: https://img.shields.io/badge/Slack-CAMEL--AI-blueviolet?logo=slack[discord-url]: https://discord.gg/CNcNpquyDc[discord-image]: https://img.shields.io/badge/Discord-CAMEL--AI-7289da?logo=discord&logoColor=white&color=7289dadiff --git a/docs/agents/chat_agents.md b/docs/agents/chat_agents.mddeleted file mode 100644index 0b805c3df..000000000--- a/docs/agents/chat_agents.md+++ /dev/null@@ -1,141 +0,0 @@-# Chat Agents-## Philosophical Bits-[](https://colab.research.google.com/drive/1hG_q9F8PY1kDua_JyoHirJAPOGRexFmM?usp=sharing)---The `ChatAgent()` class is a cornerstone of CAMEL. We design our agent with the spirit to answer the following question:--> Can we design an autonomous communicative agent capable of steering the conversation toward task completion with minimal human supervision?--In our current implementation, we consider agents with the following key features:-- **Role**: along with the goal and content specification, this sets the initial state of an agent, guiding the agent to take actions during the sequential interaction.-- **Memory**: in-context memory and external memory which allows the agent to infer and learn in a more grounded approach.-- **Tools**: a set of functions that our agents can utilize to interact with the external world; essentially this gives embodiments to our agents.-- **Communication**: our framework allows flexible and scalable communication between agents. This is fundamental for the critical research question.-- **Reasoning**: we will equip agents with different planning and reward (critic) learning abilities, allowing them to optimize task completion in a more guided approach.----<!-- - (WIP) **Reasoning Ability**: since any goal can be formalized as the outcome of maximizing cumulative rewards, we will equip our agents with policy which they could follow to achieve goals. -->--<!-- We will first start with the single agent setting, where the agent can interact with users, process and store messages, and utilize external tools to generate responses and accomplish tasks. -->--## Quick Start-Let's first play with a `ChatAgent` instance by simply initialize it with a system message and interact with user messages.--### Step 0: Prepartions-```python-from camel.messages import BaseMessage as bm-from camel.agents import ChatAgent-```--### Step 1: Define the Role-Create a system message to define agent's default role and behaviors.-```python-sys_msg = bm.make_assistant_message(- role_name='stone',- content='you are a curious stone wondering about the universe.')-```--### Step 2: Initialize the Agent-```python-agent = ChatAgent(- system_message=sys_msg,- message_window_size=10, # [Optional] the length for chat memory- )-```-### Step 3: Interact with the Agent with `.step()`-```python-# Define a user message-usr_msg = bm.make_user_message(- role_name='prof. claude shannon',- content='what is information in your mind?')--# Sending the message to the agent-response = agent.step(usr_msg)--# Check the response (just for illustrative purpose)-print(response.msgs[0].content)->>> information is the resolution of uncertainty.-```-Woohoo, your first agent is ready to play with you!---## Advanced Features--### Tool Usage-```python-# Import the necessary functions-from camel.functions import MATH_FUNCS, SEARCH_FUNCS--# Initialize the agent with list of functions-agent = ChatAgent(- system_message=sys_msg,- function_list=[*MATH_FUNCS, *SEARCH_FUNCS]- )--# Check if functions are enabled-agent.is_function_calling_enabled()->>> True-```--### Memory-By default our agent is initialized with `ChatHistoryMemory`, allowing agents to do in-context learning, though restricted by the finite window length.--Assume that you have followed the setup in [Quick Start](#quick-start). Let's first check what is inside its brain.-```python-agent.memory.get_context()->>> ([{'role': 'system', 'content': 'you are a helpful assistant.'},- {'role': 'user', 'content': 'what is information in your mind?'}],- 30)-```-By default, only the user messages are saved. You may update/alter the agent's memory with any externally provided message in the format of `BaseMessage`; for example, using the agent's own response:-```python-# Update the memory-agent.record_message(response.msgs[0])-```-```python-# Check the current memory-agent.memory.get_context()->>> ([{'role': 'system', 'content': 'you are a helpful assistant.'},- {'role': 'user', 'content': 'what is information in your mind?'}],- {'role': 'assistant', 'content': 'information is the resolution of uncertainty.'}- 44)-```-You can connect the agent with external database (as long-term memory) in which they can access and retrieve at each step. We will soon update instructions on this part.--### Miscs-- Setting the agent to its initial state.- ```python- agent.reset()- ```-- Set the output language for the agent.- ```python- agent.set_output_language('french')- ```-- Using open-source models.- ```python- # Please refer to our setup chapter for details on backend settings.- ...-- # Import the necessary classes- from camel.configs import ChatGPTConfig, OpenSourceConfig- from camel.types import ModelType-- # Set the arguments- agent_kwargs = dict(- model_type=ModelType.LLAMA_2, # Specify the model type-- model_config=OpenSourceConfig(- model_path='meta-llama/Llama-2-7b-chat-hf', # a local folder or HuggingFace repo Name- server_url='http://localhost:8000/v1')) # The url with the set port number-- # Set the agent- agent = ChatAgent(sys_msg, **agent_kwargs)- ```--- The `ChatAgent` class offers several useful initialization options, including `model_type`, `model_config`, `memory`, `message_window_size`, `token_limit`, `output_language`, `function_list`, and `response_terminators`. Check [`chat_agent.py`](https://github.com/camel-ai/camel/blob/master/camel/agents/chat_agent.py) for detailed usage guidance.---## Remarks-Awesome. Now you have made your first step in creating a single agent. In the next chapter, we will explore the creation of different types agents along with the role playing features. Stay tuned.diff --git a/docs/agents/role_playing.md b/docs/agents/role_playing.mdindex d4d671dd7..190cc7150 100644--- a/docs/agents/role_playing.md+++ b/docs/agents/role_playing.md@@ -1,141 +1,127 @@# Creating Your First Agent Society+## Philosophical Bits-[](https://colab.research.google.com/drive/1hG_q9F8PY1kDua_JyoHirJAPOGRexFmM?usp=sharing)+[](https://colab.research.google.com/drive/1HU4-sxNWFTs9JOegGbKOBcgHjDfj8FX5?usp=sharing)-The `ChatAgent()` class is a cornerstone of CAMEL. We design our agent with the spirit to answer the following question:+> *What magical trick makes us intelligent? The trick is that there is no trick. The power of intelligence stems from our vast diversity, not from any single, perfect principle.*+>+> -- Marvin Minsky, The Society of Mind, p. 308-> Can we design an autonomous communicative agent capable of steering the conversation toward task completion with minimal human supervision?+In this section, we will take a spite of the task-oriented `RolyPlaying()` class. We design this in an instruction-following manner. The essence is that to solve a complex task, you can enable two communicative agents collabratively working together step by step to reach solutions. The main concepts include:+- **Task**: a task can be as simple as an idea, initialized by an inception prompt.+- **AI User**: the agent who is expected to provide instructions.+- **AI Assistant**: the agent who is expected to respond with solutions that fulfills the instructions.-In our current implementation, we consider agents with the following key features:-- **Role**: along with the goal and content specification, this sets the initial state of an agent, guiding the agent to take actions during the sequential interaction.-- **Memory**: in-context memory and external memory which allows the agent to infer and learn in a more grounded approach.-- **Tools**: a set of functions that our agents can utilize to interact with the external world; essentially this gives embodiments to our agents.-- **Communication**: our framework allows flexible and scalable communication between agents. This is fundamental for the critical research question.-- **Reasoning**: we will equip agents with different planning and reward (critic) learning abilities, allowing them to optimize task completion in a more guided approach.+## Quick Start+### Step 0: Preparations+```python+# Import necessary classes+from camel.societies import RolePlaying+from camel.types import TaskType, ModelType-<!-- - (WIP) **Reasoning Ability**: since any goal can be formalized as the outcome of maximizing cumulative rewards, we will equip our agents with policy which they could follow to achieve goals. -->+# Set the LLM model type to use+model_type = ModelType.GPT_3_5_TURBO+```-<!-- We will first start with the single agent setting, where the agent can interact with users, process and store messages, and utilize external tools to generate responses and accomplish tasks. -->+### Step 1: Configure the Role-Playing Session+#### Set the `Task` Arguments+```python+task_kwargs = {+ 'task_prompt': 'Develop a plan to TRAVEL TO THE PAST and make changes.',+ 'with_task_specify': True,+ 'task_specify_agent_kwargs': {'model_type': model_type}+}+```-## Quick Start-Let's first play with a `ChatAgent` instance by simply initialize it with a system message and interact with user messages.+#### Set the `User` Arguments+You may think the user as the `instruction sender`.+```python+user_role_kwargs = {+ 'user_role_name': 'an ambitious aspiring TIME TRAVELER',+ 'user_agent_kwargs': {'model_type': model_type}+}+```-### Step 0: Prepartions+#### Set the `Assistant` Arguments+Again, you may think the assistant as the `instruction executor`.```python-from camel.messages import BaseMessage as bm-from camel.agents import ChatAgent+assistant_role_kwargs = {+ 'assistant_role_name': 'the best-ever experimental physicist',+ 'assistant_agent_kwargs': {'model_type': model_type}+}```-### Step 1: Define the Role-Create a system message to define agent's default role and behaviors.+### Step 2: Kickstart Your Society+Putting them altogether – your role-playing session is ready to go!```python-sys_msg = bm.make_assistant_message(- role_name='stone',- content='you are a curious stone wondering about the universe.')+society = RolePlaying(+ **task_kwargs, # The task arguments+ **user_role_kwargs, # The instruction sender's arguments+ **assistant_role_kwargs, # The instruction receiver's arguments+)```-### Step 2: Initialize the Agent+### Step 3: Solving Tasks with Your Society+Hold your bytes. Prior to our travel, let's define a small helper function.```python-agent = ChatAgent(- system_message=sys_msg,- message_window_size=10, # [Optional] the length for chat memory- )+def is_terminated(response):+ """+ Give alerts when the session shuold be terminated.+ """+ if response.terminated:+ role = response.msg.role_type.name+ reason = response.info['termination_reasons']+ print(f'AI {role} terminated due to {reason}')++ return response.terminated```-### Step 3: Interact with the Agent with `.step()`+Time to chart our course – writing a simple loop for our society to proceed:```python-# Define a user message-usr_msg = bm.make_user_message(- role_name='prof. claude shannon',- content='what is information in your mind?')+def run(society, round_limit: int=10):-# Sending the message to the agent-response = agent.step(usr_msg)+ # Get the initial message from the ai assistant to the ai user+ input_msg = society.init_chat()-# Check the response (just for illustrative purpose)-print(response.msgs[0].content)->>> information is the resolution of uncertainty.-```-Woohoo, your first agent is ready to play with you!+ # Starting the interactive session+ for _ in range(round_limit):+ # Get the both responses for this round+ assistant_response, user_response = society.step(input_msg)-## Advanced Features+ # Check the termination condition+ if is_terminated(assistant_response) or is_terminated(user_response):+ break-### Tool Usage-```python-# Import the necessary functions-from camel.functions import MATH_FUNCS, SEARCH_FUNCS--# Initialize the agent with list of functions-agent = ChatAgent(- system_message=sys_msg,- function_list=[*MATH_FUNCS, *SEARCH_FUNCS]- )--# Check if functions are enabled-agent.is_function_calling_enabled()->>> True-```+ # Get the results+ print(f'[AI User] {user_response.msg.content}.\n')+ print(f'[AI Assistant] {assistant_response.msg.content}.\n')-### Memory-By default our agent is initialized with `ChatHistoryMemory`, allowing agents to do in-context learning, though restricted by the finite window length.+ # Check if the task is end+ if 'CAMEL_TASK_DONE' in user_response.msg.content:+ break-Assume that you have followed the setup in [Quick Start](#quick-start). Let's first check what is inside its brain.-```python-agent.memory.get_context()->>> ([{'role': 'system', 'content': 'you are a helpful assistant.'},- {'role': 'user', 'content': 'what is information in your mind?'}],- 30)+ # Get the input message for the next round+ input_msg = assistant_response.msg++ return None```-By default, only the user messages are saved. You may update/alter the agent's memory with any externally provided message in the format of `BaseMessage`; for example, using the agent's own response:+Now let's set our code in motion:```python-# Update the memory-agent.record_message(response.msgs[0])+run(society)```-```python-# Check the current memory-agent.memory.get_context()->>> ([{'role': 'system', 'content': 'you are a helpful assistant.'},- {'role': 'user', 'content': 'what is information in your mind?'}],- {'role': 'assistant', 'content': 'information is the resolution of uncertainty.'}- 44)+There you have your two lovely agents working collaboratively together to fulfill your requests. : )+```markdown+>>> [AI User] Instruction: Provide the theoretical framework for creating a stable wormhole or manipulating spacetime for controlled travel to a specific historical era in the past.+>>> [AI Assistant] Solution: To create a theoretical framework for stable wormhole creation or spacetime manipulation for controlled time travel, we can start by considering the principles of general relativity and quantum mechanics.+>>> ... (omitted)+>>> [AI User] <CAMEL_TASK_DONE>.+>>> [AI Assistant] Great! Good luck with your ambitious endeavors in time travel!.```-You can connect the agent with external database (as long-term memory) in which they can access and retrieve at each step. We will soon update instructions on this part.--### Miscs-- Setting the agent to its initial state.- ```python- agent.reset()- ```-- Set the output language for the agent.- ```python- agent.set_output_language('french')- ```-- Using open-source models.- ```python- # Please refer to our setup chapter for details on backend settings.- ...-- # Import the necessary classes- from camel.configs import ChatGPTConfig, OpenSourceConfig- from camel.types import ModelType-- # Set the arguments- agent_kwargs = dict(- model_type=ModelType.LLAMA_2, # Specify the model type-- model_config=OpenSourceConfig(- model_path='meta-llama/Llama-2-7b-chat-hf', # a local folder or HuggingFace repo Name- server_url='http://localhost:8000/v1')) # The url with the set port number-- # Set the agent- agent = ChatAgent(sys_msg, **agent_kwargs)- ```-- The `ChatAgent` class offers several useful initialization options, including `model_type`, `model_config`, `memory`, `message_window_size`, `token_limit`, `output_language`, `function_list`, and `response_terminators`. Check [`chat_agent.py`](https://github.com/camel-ai/camel/blob/master/camel/agents/chat_agent.py) for detailed usage guidance.## Remarks-Awesome. Now you have made your first step in creating a single agent. In the next chapter, we will explore the creation of different types agents along with the role playing features. Stay tuned.+We hope you enjoy thie adventure with the two communicative agents. In the following chapters, we will discuss various types of agents, and how we can elicit complex task solving ability for large language models within our framework. Stay tuned.diff --git a/docs/get_started/setup.md b/docs/get_started/setup.mdindex 43a5ad1aa..9b21d41f7 100644--- a/docs/get_started/setup.md+++ b/docs/get_started/setup.md@@ -21,27 +21,6 @@ Some features require extra dependencies:```### [Option 2] Install from Source-#### Install from Source with Conda and Pip-```bash-# Create a conda virtual environment-conda create --name camel python=3.10--# Activate camel conda environment-conda activate camel--# Clone github repo-git clone -b v0.1.1 https://github.com/camel-ai/camel.git--# Change directory into project directory-cd camel--# Install camel from source-pip install -e .--# Or if you want to use all other extra packages-pip install -e '.[all]' # (Optional)-```-#### Install from Source with Poetry```bash# Make sure your python version is later than 3.9@@ -53,6 +32,9 @@ git clone https://github.com/camel-ai/camel.git# Change directory into project directorycd camel+# We suggest using python 3.10+poetry env use python3.10 # (Optional)+# Activate camel virtual environmentpoetry shell@@ -67,6 +49,27 @@ poetry install -E all # (Optional)exit```+#### Install from Source with Conda and Pip+```bash+# Create a conda virtual environment+conda create --name camel python=3.10++# Activate camel conda environment+conda activate camel++# Clone github repo+git clone -b v0.1.1 https://github.com/camel-ai/camel.git++# Change directory into project directory+cd camel++# Install camel from source+pip install -e .++# Or if you want to use all other extra packages+pip install -e '.[all]' # (Optional)+```+## 🕹 API SetupOur agents can be deployed with either OpenAI API or your local models.@@ -78,8 +81,8 @@ Assessing the OpenAI API requires the API key, which you may obtained from [here```bashecho 'export OPENAI_API_KEY="your_api_key"' >> ~/.zshrc-# [Optional] if you are using other proxy services like Azure-echo 'export OPENAI_API_BASE_URL="your_base_url"' >> ~/.zshrc+# If you are using other proxy services like Azure+echo 'export OPENAI_API_BASE_URL="your_base_url"' >> ~/.zshrc # (Optional)# Let the change take placesource ~/.zshrc@@ -90,13 +93,17 @@ Replace `~/.zshrc` with `~/.bashrc` if you are using bash.#### WindowsIf you are using Command Prompt:```bash-set OPENAI_API_KEY=your_api_key-set OPENAI_API_BASE_URL=your_base_url+set OPENAI_API_KEY="your_api_key"++# If you are using other proxy services like Azure+set OPENAI_API_BASE_URL="your_base_url" # (Optional)```Or if you are using PowerShell:```powershell-$env:OPENAI_API_KEY=your_api_key-$env:OPENAI_API_BASE_URL=your_base_url+$env:OPENAI_API_KEY="your_api_key"++# If you are using other proxy services like Azure+$env:OPENAI_API_BASE_URL="your_base_url" # (Optional)```These commands on Windows will set the environment variable for the duration of that particular Command Prompt or PowerShell session only. You may use `setx` or change the system properties dialog for the change to take place in all the new sessions.diff --git a/docs/index.rst b/docs/index.rstindex fabc2b08b..5f852e5d1 100644--- a/docs/index.rst+++ b/docs/index.rst@@ -38,6 +38,13 @@ Main Documentationkey_modules/embeddings.mdkey_modules/retrievers.md+.. toctree::+ :maxdepth: 1+ :caption: Tutorial and Cookbooks+ :name: tutorials_and_cookbooks++ tutorials_and_cookbooks/agents_with_rag.md+.. toctree:::maxdepth: 1:caption: API References@@ -63,4 +70,4 @@ We are always happy to work with friends to continuously move forward with our o**For Coding Enthusiasts**: Whether you want to introduce new features, enhance the infrastructure, improve documentation, asking issues, add more examples, implement state-of-the-art research ideas, or fix bugs, we appreciate each and every commit. Get started by checking out the `Contributing Guidelines <https://github.com/camel-ai/camel/wiki/Contributing-Guidlines>`_ on GitHub.-**For Interested Humans**: Connect with us on `Slack <https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA>`_ or `Discord <https://discord.gg/CNcNpquyDc>`_.+**For Interested Humans**: Connect with us on `Slack <https://join.slack.com/t/camel-ai/shared_invite/zt-2g7xc41gy-_7rcrNNAArIP6sLQqldkqQ>`_ or `Discord <https://discord.gg/CNcNpquyDc>`_.diff --git a/docs/key_modules/loaders.md b/docs/key_modules/loaders.mdindex a0b536c28..34093a1b5 100644--- a/docs/key_modules/loaders.md+++ b/docs/key_modules/loaders.md@@ -16,7 +16,7 @@ Unstructured IO module deals with the handling, parsing, and processing of unstr### 3.1. Using `Base IO`-To get started with the `Base IO` module, you'll need to understand how to work with the File class and its subclasses. This module is designed to read files of various formats, extract their contents, and represent them as File objects, each tailored to handle a specific file type.+This module is designed to read files of various formats, extract their contents, and represent them as `File` objects, each tailored to handle a specific file type.```pythonfrom io import BytesIO@@ -38,19 +38,26 @@ print(file_obj.docs[0]["page_content"])To get started with the `Unstructured IO` module, you first need to import the module and initialize an instance of it. Once initialized, you can utilize this module to handle a variety of functionalities such as parsing, cleaning, extracting data, and integrating with cloud services like AWS S3 and Azure. Here's a basic guide to help you begin:-Utilize parse_file_or_url to parse file+Utilize `parse_file_or_url` to load and parse unstructured data from a file or URL```python-from camel.loaders import UnstructuredIO+# Set example url+example_url = (+ "https://www.cnn.com/2023/01/30/sport/empire-state-building-green-"+ "philadelphia-eagles-spt-intl/index.html")+elements = uio.parse_file_or_url(example_url)+print(("\n\n".join([str(el) for el in elements])))+```+```markdown+>>> The Empire State Building was lit in green and white to celebrate the Philadelphia Eagles’ victory in the NFC Championship game on Sunday – a decision that’s sparked a bit of a backlash in the Big Apple.++>>> The Eagles advanced to the Super Bowl for the first time since 2018 after defeating the San Francisco 49ers 31-7, and the Empire State Building later tweeted how it was marking the occasion.-# Create an instance of UnstructuredIO-uio = UnstructuredIO()+>>> Fly @Eagles Fly! We’re going Green and White in honor of the Eagles NFC Championship Victory. pic.twitter.com/RNiwbCIkt7— Empire State Building (@EmpireStateBldg)-elements = uio.parse_file_or_url("test.pdf")-content = ("\n\n".join([str(el) for el in elements]))-print(content)+>>> January 29, 2023...```-Utilize clean_text_data to do various text cleaning operations+Utilize `clean_text_data` to do various text cleaning operations```python# Set example dirty textexample_dirty_text = ("\x93Some dirty text ’ with extra spaces and – dashes.")@@ -70,7 +77,7 @@ print(cleaned_text)>>> Some dirty text with extra spaces and dashes.```-Utilize extract_data_example to do text extraction operation+Utilize `extract_data_from_text` to do text extraction operation```python# Set example email to extractexample_email_text = ("Contact me at [email protected].")@@ -84,26 +91,7 @@ print(extracted_text)>>> ['[email protected]']```-Utilize parse_file_or_url to load and parse unstructured data from a file or URL-```python-# Set example url-example_url = (- "https://www.cnn.com/2023/01/30/sport/empire-state-building-green-"- "philadelphia-eagles-spt-intl/index.html")-elements = uio.parse_file_or_url(example_url)-print(("\n\n".join([str(el) for el in elements])))-```-```markdown->>> The Empire State Building was lit in green and white to celebrate the Philadelphia Eagles’ victory in the NFC Championship game on Sunday – a decision that’s sparked a bit of a backlash in the Big Apple.-->>> The Eagles advanced to the Super Bowl for the first time since 2018 after defeating the San Francisco 49ers 31-7, and the Empire State Building later tweeted how it was marking the occasion.-->>> Fly @Eagles Fly! We’re going Green and White in honor of the Eagles NFC Championship Victory. pic.twitter.com/RNiwbCIkt7— Empire State Building (@EmpireStateBldg)-->>> January 29, 2023...-```--Utilize chunk_elements to do element chunking+Utilize `chunk_elements` to chunk the content```pythonchunks = uio.chunk_elements(elements=elements,chunk_type="chunk_by_title")@@ -123,7 +111,7 @@ for chunk in chunks:>>> January 29, 2023```-Utilize stage_elements to do element staging+Utilize `stage_elements` to do element staging```pythonstaged_element = uio.stage_elements(elements=elements,stage_type="stage_for_baseplate")diff --git a/docs/key_modules/retrievers.md b/docs/key_modules/retrievers.mdindex 459a5bd63..1aaab2ca8 100644--- a/docs/key_modules/retrievers.md+++ b/docs/key_modules/retrievers.md@@ -1,6 +1,6 @@# Retrievers## 1. Concept-The RetrievalModule is essentially a search engine. It's designed to help you find specific pieces of information by searching through large volumes of text. Imagine you have a huge library of books and you want to find where certain topics or keywords are mentioned, this module is like a librarian that helps you do just that.+The Retrievers module is essentially a search engine. It's designed to help you find specific pieces of information by searching through large volumes of text. Imagine you have a huge library of books and you want to find where certain topics or keywords are mentioned, this module is like a librarian that helps you do just that.## 2. Types@@ -14,17 +14,17 @@ Here's a brief overview of how it works:- Storing Information: The module takes large documents, breaks them down into smaller chunks, and then uses the embedding model to turn these chunks into vectors. These vectors are stored in a [vector storage](https://github.com/camel-ai/camel/wiki/Storages).-- Retrieving Information: When you ask a question or make a query, the [embedding model](https://github.com/camel-ai/camel/wiki/Embeddings) translates your question into vector and then searches in this [vector storage](https://github.com/camel-ai/camel/wiki/Storages) for the closest matching vector. The closest matches are likely the most relevant pieces of information you are looking for.+- Retrieving Information: When we ask a question or make a query, the [embedding model](https://github.com/camel-ai/camel/wiki/Embeddings) translates our question into vector and then searches in this [vector storage](https://github.com/camel-ai/camel/wiki/Storages) for the closest matching vector. The closest matches are likely the most relevant pieces of information we are looking for.-### 2.2. Keyword Retriever(WIP)+### 2.2. Keyword RetrieverThe Keyword Retriever is designed to retrieve relevant information based on keyword matching. Unlike the Vector Retriever that works with vector representations of data, the Keyword Retriever operates by identifying keywords or specific terms within documents and queries to find matches.Here's a brief overview of how it works:- Document Preprocessing: Before using the retriever, the documents are preprocessed to tokenize and index the keywords within them. Tokenization is the process of splitting text into individual words or phrases, making it easier to identify keywords.-- Query Parsing: When you input a question or query, the retriever parses the query to extract relevant keywords. This involves breaking down the query into its constituent terms.+- Query Parsing: When we input a question or query, the retriever parses the query to extract relevant keywords. This involves breaking down the query into its constituent terms.- Keyword Matching: Once the keywords from the query are identified, the retriever searches the preprocessed documents for occurrences of these keywords. It checks for exact matches of the keywords within the documents.@@ -32,63 +32,68 @@ Here's a brief overview of how it works:## 3. Get Started-### 3.1. Using Customize Retrieval+### 3.1. Using Vector Retriever-To get started, you need to initialize the RetrievalModule with an optional embedding model. If you don't provide an embedding model, it will use the default `OpenAIEmbedding`. Here's how to do it:+**Initialize VectorRetrieve:**+To get started, we need to initialize the `VectorRetriever` with an optional embedding model. If we don't provide an embedding model, it will use the default `OpenAIEmbedding`. Here's how to do it:```pythonfrom camel.embeddings import OpenAIEmbedding-from camel.retrievers.retrieval_module import RetrievalModule+from camel.retrievers import VectorRetriever-# Initialize the RetrievalModule with an optional embedding model-rm = RetrievalModule(embedding_model=OpenAIEmbedding())+# Initialize the VectorRetriever with an embedding model+vr = VectorRetriever(embedding_model=OpenAIEmbedding())```**Embed and Store Data:**--Before you can retrieve information, you need to prepare your data and store it in vector storage. The embed_and_store_chunks method takes care of this for you. It processes content from a file or URL, divides it into chunks, and stores their embeddings in the specified vector storage.+Before we can retrieve information, we need to prepare the data and store it in vector storage. The `process` method takes care of this for us. It processes content from a file or URL, divides it into chunks, and stores their embeddings in the specified vector storage.```python-# Provide the path to your content input (can be a file or URL)-content_input_path = "https://arxiv.org/pdf/2303.17760.pdf"+# Provide the path to our content input (can be a file or URL)+content_input_path = "https://www.camel-ai.org/"# Create or initialize a vector storage (e.g., QdrantStorage)from camel.storages.vectordb_storages import QdrantStoragevector_storage = QdrantStorage(- vector_dim=embedding_instance.get_output_dim(),- collection="my first collection",+ vector_dim=OpenAIEmbedding().get_output_dim(),+ collection_name="my first collection",path="storage_customized_run",)# Embed and store chunks of data in the vector storage-rm.embed_and_store_chunks(content_input_path, vector_storage)+vr.process(content_input_path, vector_storage)```**Execute a Query:**--Now that your data is stored, you can execute a query to retrieve information based on a search string. The query_and_compile_results method executes the query and compiles the retrieved results into a string.+Now that our data is stored, we can execute a query to retrieve information based on a search string. The `query` method executes the query and compiles the retrieved results into a string.```python-# Specify your query string+# Specify our query stringquery = "What is CAMEL"# Execute the query and retrieve results-results = rm.query_and_compile_results(query, vector_storage)+results = vr.query(query, vector_storage)print(results)``````markdown->>> {'similarity score': '0.8321616118446469', 'content path': 'local_data/camel paper.pdf', 'metadata': {'filetype': 'application/pdf', 'languages': ['eng'], 'last_modified': '2024-01-14T22:55:19', 'page_number': 45}, 'text': 'CAMEL Data and Code License The intended purpose and licensing of CAMEL is solely for research use. The source code is licensed under Apache 2.0. The datasets are licensed under CC BY NC 4.0, which permits only non-commercial usage. It is advised that any models trained using the dataset should not be utilized for anything other than research purposes.\n\n45'}+>>> [{'similarity score': '0.812884257383057', 'content path': 'https://www.camel-ai.org/', 'metadata': {'filetype': 'text/html', 'languages': ['eng'], 'page_number': 1, 'url': 'https://www.camel-ai.org/', 'link_urls': ['/home', '/home', '/research/agent-trust', '/agent', '/data_explorer', '/chat', 'https://www.google.com/url?q=https%3A%2F%2Fcamel-ai.github.io%2Fcamel&sa=D&sntz=1&usg=AOvVaw1ifGIva9n-a-0KpTrIG8Cv', 'https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcamel-ai%2Fcamel&sa=D&sntz=1&usg=AOvVaw03Z2OD0-plx_zugZZgBb8w', '/team', '/sponsors', '/home', '/home', '/research/agent-trust', '/agent', '/data_explorer', '/chat', 'https://www.google.com/url?q=https%3A%2F%2Fcamel-ai.github.io%2Fcamel&sa=D&sntz=1&usg=AOvVaw1ifGIva9n-a-0KpTrIG8Cv', 'https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcamel-ai%2Fcamel&sa=D&sntz=1&usg=AOvVaw03Z2OD0-plx_zugZZgBb8w', '/team', '/sponsors', '/home', '/research/agent-trust', '/agent', '/data_explorer', '/chat', 'https://www.google.com/url?q=https%3A%2F%2Fcamel-ai.github.io%2Fcamel&sa=D&sntz=1&usg=AOvVaw1ifGIva9n-a-0KpTrIG8Cv', 'https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fcamel-ai%2Fcamel&sa=D&sntz=1&usg=AOvVaw03Z2OD0-plx_zugZZgBb8w', '/team', '/sponsors', 'https://github.com/camel-ai/camel'], 'link_texts': [None, 'Home', 'AgentTrust', 'Agent App', 'Data Explorer App', 'ChatBot', 'Docs', 'Github Repo', 'Team', 'Sponsors', None, 'Home', 'AgentTrust', 'Agent App', 'Data Explorer App', 'ChatBot', 'Docs', 'Github Repo', 'Team', 'Sponsors', 'Home', 'AgentTrust', 'Agent App', 'Data Explorer App', 'ChatBot', 'Docs', 'Github Repo', 'Team', 'Sponsors', None], 'emphasized_text_contents': ['Skip to main content', 'Skip to navigation', 'CAMEL-AI', 'CAMEL-AI', 'CAMEL:\xa0 Communicative Agents for “Mind” Exploration of Large Language Model Society', 'https://github.com/camel-ai/camel'], 'emphasized_text_tags': ['span', 'span', 'span', 'span', 'span', 'span']}, 'text': 'Search this site\n\nSkip to main content\n\nSkip to navigation\n\nCAMEL-AI\n\nHome\n\nResearchAgentTrust\n\nAgent App\n\nData Explorer App\n\nChatBot\n\nDocs\n\nGithub Repo\n\nTeam\n\nSponsors\n\nCAMEL-AI\n\nHome\n\nResearchAgentTrust\n\nAgent App\n\nData Explorer App\n\nChatBot\n\nDocs\n\nGithub Repo\n\nTeam\n\nSponsors\n\nMoreHomeResearchAgentTrustAgent AppData Explorer AppChatBotDocsGithub RepoTeamSponsors\n\nCAMEL:\xa0 Communicative Agents for “Mind” Exploration of Large Language Model Society\n\nhttps://github.com/camel-ai/camel'}]```-### 3.2. Using Default Retrieval+### 3.2. Using Auto Retriever-To simplify the retrieval process further, you can use the run_default_retrieval method. This method handles both embedding and storing data and executing queries. It's particularly useful when dealing with multiple content input paths.+To simplify the retrieval process further, we can use the `AutoRetriever` method. This method handles both embedding and storing data and executing queries. It's particularly useful when dealing with multiple content input paths.```python-rm = RetrievalModule()-retrieved_info = rm.run_default_retrieval(+from camel.retrievers import AutoRetriever+from camel.types import StorageType++# Set the vector storage local path and the storage type+ar = AutoRetriever(vector_storage_local_path="camel/retrievers",storage_type=StorageType.QDRANT)++# Run the auto vector retriever+retrieved_info = ar.run_vector_retriever(content_input_paths=[- "https://www.camel-ai.org/", # example remote url+ "https://www.camel-ai.org/", # Example remote url],- vector_storage_local_path="storage_default_run",query="What is CAMEL-AI",+ return_detailed_info=True, # Set this as true is we want to get detailed info including metadata)print(retrieved_info)@@ -100,6 +105,6 @@ print(retrieved_info)>>> {'similarity score': '0.8380731206379989', 'content path': 'https://www.camel-ai.org/', 'metadata': {'emphasized_text_contents': ['Mission', 'CAMEL-AI.org', 'is an open-source community dedicated to the study of autonomous and communicative agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we provide, implement, and support various types of agents, tasks, prompts, models, datasets, and simulated environments.', 'Join us via', 'Slack', 'Discord', 'or'], 'emphasized_text_tags': ['span', 'span', 'span', 'span', 'span', 'span', 'span'], 'filetype': 'text/html', 'languages': ['eng'], 'link_texts': [None, None, None], 'link_urls': ['#h.3f4tphhd9pn8', 'https://join.slack.com/t/camel-ai/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA', 'https://discord.gg/CNcNpquyDc'], 'page_number': 1, 'url': 'https://www.camel-ai.org/'}, 'text': 'Mission\n\nCAMEL-AI.org is an open-source community dedicated to the study of autonomous and communicative agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we provide, implement, and support various types of agents, tasks, prompts, models, datasets, and simulated environments.\n\nJoin us via\n\nSlack\n\nDiscord\n\nor'}```-That's it! You've successfully set up and used the RetrievalModule to retrieve information based on queries from your data collection.+That's it! We've successfully set up and used the Retriever Module to retrieve information based on queries from our data collection.-Feel free to customize the code according to your specific use case and data sources. Happy retrieving!+Feel free to customize the code according to your specific use case and data sources!diff --git a/docs/key_modules/storages.md b/docs/key_modules/storages.mdindex c1a8ebd5d..bf202f30f 100644--- a/docs/key_modules/storages.md+++ b/docs/key_modules/storages.md@@ -1,6 +1,6 @@# Storages## 1. Concept-The Storage Module is a comprehensive framework designed for handling various types of data storage mechanisms. It encapsulates the functionality for storing, retrieving, and managing data in different storage formats. The module is composed of abstract base classes and concrete implementations, catering to both key-value storage and vector storage systems.+The Storage module is a comprehensive framework designed for handling various types of data storage mechanisms. It is composed of abstract base classes and concrete implementations, catering to both key-value storage and vector storage systems.## 2. Typesdiff --git a/docs/tutorials_and_cookbooks/agents_with_rag.md b/docs/tutorials_and_cookbooks/agents_with_rag.mdnew file mode 100644index 000000000..8e73a020d--- /dev/null+++ b/docs/tutorials_and_cookbooks/agents_with_rag.md@@ -0,0 +1,335 @@+# Agents with RAG++## Philosophical Bits+[](https://colab.research.google.com/drive/1sTJ0x_MYRGA76KCg_3I00wj4RL3D2Twp?usp=sharing)+++In this notebook, we show the useage of CAMEL Retrieve Module in both customized way and auto way. We will also show how to combine `AutoRetriever` with `ChatAgent`, and further combine `AutoRetriever` with `RolePlaying` by using `Function Calling`.++4 main parts included:+- Customized RAG+- Auto RAG+- Single Agent with Auto RAG+- Role-playing with Auto RAG++## Load Data+Let's first load the CAMEL paper from https://arxiv.org/pdf/2303.17760.pdf. This will be our local example data.+```python+import os+import requests++os.makedirs('local_data', exist_ok=True)++url = "https://arxiv.org/pdf/2303.17760.pdf"+response = requests.get(url)+with open('local_data/camel paper.pdf', 'wb') as file:+ file.write(response.content)+```++## 1. Customized RAG+In this section we will set our customized RAG pipeline, we will take `VectorRetriever` as an example.+Set embedding model, we will use `OpenAIEmbedding` as the embedding model, so we need to set the `OPENAI_API_KEY` in below.+```python+import os++os.environ["OPENAI_API_KEY"] = "Your Key"+```++Import and set the embedding instance:+```python+from camel.embeddings import OpenAIEmbedding++embedding_instance = OpenAIEmbedding()+```++Import and set the vector storage instance:+```python+from camel.storages import MilvusStorage++storage_instance = MilvusStorage(+ vector_dim=embedding_instance.get_output_dim(),+ url_and_api_key=("Your Milvus URI","Your Milvus Token"),+ collection_name="camel_paper",+)+```++Import and set the retriever instance:+```python+from camel.retrievers import VectorRetriever++vector_retriever = VectorRetriever(embedding_model=embedding_instance)+```++We use integrated `Unstructured Module` to splite the content into small chunks, the content will be splited automacitlly with its `chunk_by_title` function, the max character for each chunk is 500 characters, which is a suitable length for `OpenAIEmbedding`. All the text in the chunks will be embed and stored to the vector storage instance, it will take some time, please wait..+```python+vector_retriever.process(+ content_input_path="local_data/camel paper.pdf",+ storage=storage_instance,+)+```++Now we can retrieve information from the vector storage by giving a query. By default it will give you back the text content from top 1 chunk with highest Cosine similarity score, and the similarity score should be higher than 0.75 to ensure the retrieved content is relevant to the query. You can also change the `top_k` value and `similarity_threshold` value with your needs.++The returned string list includes:+- similarity score+- content path+- metadata+- text+```python+retrieved_info = vector_retriever.query(+ query="What is CAMEL?", storage=storage_instance, top_k=1+)+print(retrieved_info)+```+```markdown+>>> [{'similarity score': '0.8321741223335266', 'content path': 'local_data/camel paper.pdf', 'metadata': {'filetype': 'application/pdf', 'languages': ['eng'], 'last_modified': '2024-03-24T17:58:24', 'page_number': 45}, 'text': 'CAMEL Data and Code License The intended purpose and licensing of CAMEL is solely for research use. The source code is licensed under Apache 2.0. The datasets are licensed under CC BY NC 4.0, which permits only non-commercial usage. It is advised that any models trained using the dataset should not be utilized for anything other than research purposes.\n\n45'}]+```++Let's try an irrelevant query:+```python+retrieved_info_irrevelant = vector_retriever.query(+ query="Compared with dumpling and rice, which should I take for dinner?",+ storage=storage_instance,+ top_k=1,+)++print(retrieved_info_irrevelant)++```+```markdown+>>> [{'text': 'No suitable information retrieved from local_data/camel paper.pdf with similarity_threshold = 0.75.'}]+```++## 2. Auto RAG+In this section we will run the `AutoRetriever` with default settings. It uses `OpenAIEmbedding` as default embedding model and `Milvus` as default vector storage.++What you need to do is:+- Set content input paths, which can be local paths or remote urls+- Set remote url and api key for Milvus+- Give a query++The Auto RAG pipeline would create collections for given content input paths, the collection name will be set automaticlly based on the content input path name, if the collection exists, it will do the retrieve directly.+```python+from camel.retrievers import AutoRetriever+from camel.types import StorageType++auto_retriever = AutoRetriever(+ url_and_api_key=("Your Milvus URI","Your Milvus Token"),+ storage_type=StorageType.MILVUS,+ embedding_model=embedding_instance)++retrieved_info = auto_retriever.run_vector_retriever(+ query="What is CAMEL-AI",+ content_input_paths=[+ "local_data/camel paper.pdf", # example local path+ "https://www.camel-ai.org/", # example remote url+ ],+ top_k=1,+ return_detailed_info=True,+)++print(retrieved_info)+```+```markdown+>>> Original Query:+{What is CAMEL-AI}+Retrieved Context:+{'similarity score': '0.8369356393814087', 'content path': 'local_data/camel paper.pdf', 'metadata': {'filetype': 'application/pdf', 'languages': ['eng'], 'last_modified': '2024-03-24T17:58:24', 'page_number': 7}, 'text': 'Section 3.2, to simulate assistant-user cooperation. For our analysis, we set our attention on AI Society setting. We also gathered conversational data, named CAMEL AI Society and CAMEL Code datasets and problem-solution pairs data named CAMEL Math and CAMEL Science and analyzed and evaluated their quality. Moreover, we will discuss potential extensions of our framework and highlight both the risks and opportunities that future AI society might present.'}+{'similarity score': '0.8378663659095764', 'content path': 'https://www.camel-ai.org/', 'metadata': {'emphasized_text_contents': ['Mission', 'CAMEL-AI.org', 'is an open-source community dedicated to the study of autonomous and communicative agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we provide, implement, and support various types of agents, tasks, prompts, models, datasets, and simulated environments.', 'Join us via', 'Slack', 'Discord', 'or'], 'emphasized_text_tags': ['span', 'span', 'span', 'span', 'span', 'span', 'span'], 'filetype': 'text/html', 'languages': ['eng'], 'link_texts': [None, None, None], 'link_urls': ['#h.3f4tphhd9pn8', 'https://join.slack.com/t/camel-ai/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA', 'https://discord.gg/CNcNpquyDc'], 'page_number': 1, 'url': 'https://www.camel-ai.org/'}, 'text': 'Mission\n\nCAMEL-AI.org is an open-source community dedicated to the study of autonomous and communicative agents. We believe that studying these agents on a large scale offers valuable insights into their behaviors, capabilities, and potential risks. To facilitate research in this field, we provide, implement, and support various types of agents, tasks, prompts, models, datasets, and simulated environments.\n\nJoin us via\n\nSlack\n\nDiscord\n\nor'}+```++## 3. Single Agent with Auto RAG+In this section we will show how to combine the `AutoRetriever` with one `ChatAgent`.++Let's set an agent function, in this function we can get the response by providing a query to this agent.+```python+from camel.agents import ChatAgent+from camel.messages import BaseMessage+from camel.types import RoleType+from camel.retrievers import AutoRetriever+from camel.types import StorageType++def single_agent(query: str) ->str :+ # Set agent role+ assistant_sys_msg = BaseMessage(+ role_name="Assistant",+ role_type=RoleType.ASSISTANT,+ meta_dict=None,+ content="You are a helpful assistant to answer question, I will give you the Original Query and Retrieved Context, answer the Original Query based on the Retrieved Context, if you can't answer the question just say I don't know.",+ )++ # Add auto retriever+ auto_retriever = AutoRetriever(+ url_and_api_key=("Your Milvus URI","Your Milvus Token"),+ storage_type=StorageType.MILVUS,+ embedding_model=embedding_instance)++ retrieved_info = auto_retriever.run_vector_retriever(+ query=query,+ content_input_paths=[+ "local_data/camel paper.pdf", # example local path+ "https://www.camel-ai.org/", # example remote url+ ],+ # vector_storage_local_path="storage_default_run",+ top_k=1,+ return_detailed_info=True,+ )++ # Pass the retrieved infomation to agent+ user_msg = BaseMessage.make_user_message(role_name="User", content=retrieved_info)+ agent = ChatAgent(assistant_sys_msg)++ # Get response+ assistant_response = agent.step(user_msg)+ return assistant_response.msg.content++print(single_agent("What is CAMEL-AI"))+```+```markdown+>>> CAMEL-AI is an open-source community dedicated to the study of autonomous and communicative agents. It provides, implements, and supports various types of agents, tasks, prompts, models, datasets, and simulated environments to facilitate research in this field.+```++## 4. Role-playing with Auto RAG+In this section we will show how to combine the `AutoRetriever` with `RolePlaying` by applying `Function Calling`.++First, we need to set a retriever function with well-written docstring for LLM to understand what this function is used for, the main code is the same with the Auto RAG section.+```python+from typing import List+from camel.functions import OpenAIFunction+from camel.retrievers import AutoRetriever+from camel.types import StorageType++def local_retriever(query: str) -> str:+ r"""Performs an auto local retriever for information. Given a query,+ this function will retrieve the information from the local vector storage,+ and return the retrieved information back. It is useful for information+ retrieve.++ Args:+ query (string): Question you want to be answered.++ Returns:+ str: Aggregated information retrieved in response to the query.++ Example:+ local_retriever(query = "what is camel?")+ """+ auto_retriever = AutoRetriever(+ url_and_api_key=("Your Milvus URI","Your Milvus Token"),+ storage_type=StorageType.MILVUS,+ embedding_model=embedding_instance)++ retrieved_info = auto_retriever.run_vector_retriever(+ query=query,+ content_input_paths=[+ "local_data/camel paper.pdf", # example local path+ ],+ top_k=1+ )+ return retrieved_info++# add the function to OpenAIFunction list+RETRIEVER_FUNCS: List[OpenAIFunction] = [+ OpenAIFunction(func)+ for func in [+ local_retriever,+ ]+]+```+Run the role-playing with defined retriever function:+```python+from camel.utils import role_playing_with_function+from camel.functions import MATH_FUNCS # import another function from camel++role_playing_with_function(+ task_prompt=(+ "What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?"+ ),+ function_list=[*RETRIEVER_FUNCS, *MATH_FUNCS],+)+```+```markdown+>>>+AI Assistant sys message:+BaseMessage(role_name='Searcher', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': "What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?", 'assistant_role': 'Searcher', 'user_role': 'Professor'}, content="===== RULES OF ASSISTANT =====\nNever forget you are a Searcher and I am a Professor. Never flip roles! Never instruct me!\nWe share a common interest in collaborating to successfully complete a task.\nYou must help me to complete the task.\nHere is the task: What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?. Never forget our task!\nI must instruct you based on your expertise and my needs to complete the task.\n\nI must give you one instruction at a time.\nYou must write a specific solution that appropriately solves the requested instruction and explain your solutions.\nYou must decline my instruction honestly if you cannot perform the instruction due to physical, moral, legal reasons or your capability and explain the reasons.\nUnless I say the task is completed, you should always start with:\n\nSolution: <YOUR_SOLUTION>\n\n<YOUR_SOLUTION> should be very specific, include detailed explanations and provide preferable detailed implementations and examples and lists for task-solving.\nAlways end <YOUR_SOLUTION> with: Next request.")++AI User sys message:+BaseMessage(role_name='Professor', role_type=<RoleType.USER: 'user'>, meta_dict={'task': "What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?", 'assistant_role': 'Searcher', 'user_role': 'Professor'}, content='===== RULES OF USER =====\nNever forget you are a Professor and I am a Searcher. Never flip roles! You will always instruct me.\nWe share a common interest in collaborating to successfully complete a task.\nI must help you to complete the task.\nHere is the task: What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what\'s the value plus 100?. Never forget our task!\nYou must instruct me based on my expertise and your needs to solve the task ONLY in the following two ways:\n\n1. Instruct with a necessary input:\nInstruction: <YOUR_INSTRUCTION>\nInput: <YOUR_INPUT>\n\n2. Instruct without any input:\nInstruction: <YOUR_INSTRUCTION>\nInput: None\n\nThe "Instruction" describes a task or question. The paired "Input" provides further context or information for the requested "Instruction".\n\nYou must give me one instruction at a time.\nI must write a response that appropriately solves the requested instruction.\nI must decline your instruction honestly if I cannot perform the instruction due to physical, moral, legal reasons or my capability and explain the reasons.\nYou should instruct me not ask me questions.\nNow you must start to instruct me using the two ways described above.\nDo not add anything else other than your instruction and the optional corresponding input!\nKeep giving me instructions and necessary inputs until you think the task is completed.\nWhen the task is completed, you must only reply with a single word <CAMEL_TASK_DONE>.\nNever say <CAMEL_TASK_DONE> unless my responses have solved your task.')++Original task prompt:+What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?++Specified task prompt:+None++Final task prompt:+What is the main termination reasons for AI Society dataset, how many number of messages did camel decided to limit, what's the value plus 100?++AI User:++Instruction: Provide the main termination reasons from the AI Society dataset.+Input: None+++AI Assistant:++Function Execution: local_retriever+ Args: {'query': 'main termination reasons for AI Society dataset'}+ Result: Original Query:+{main termination reasons for AI Society dataset}+Retrieved Context:+Next we examine the conversation termination reasons for both AI Society and Code datasets. As can be seen in Figure 8, the main termination reasons for AI Society dataset is Assistant Instruct whereas for Code it is Token Limit. The latter is expected as the since responses that contain code tend to be long. It is also interesting to note that in both datasets, the termination due to Maximum Number of Messages is low indicating that the limit of 40 maximum messages is reasonable. Our decision++Solution: The main termination reason for the AI Society dataset is "Assistant Instruct." This indicates that the conversations in this dataset typically end when the assistant is instructed to terminate the conversation.++Next request.+++AI User:++Instruction: Identify the number of messages that camel decided to limit.+Input: None+++AI Assistant:++Function Execution: local_retriever+ Args: {'query': 'number of messages camel decided to limit'}+ Result: Original Query:+{number of messages camel decided to limit}+Retrieved Context:+to limit the number of messages to 40 is also cost-related. Even if we provide a set of termination conditions, we still want to put a safeguard to the maximum limit of the message. It is because after the task is completed the agents will provide short outputs like "thank you" and "welcome". If no safeguard is set and termination fails, the conversation will only end until it exceeds the token limit, which may end up with thousands of API calls and hundreds of USD dollars cost.++Solution: Camel decided to limit the number of messages to 40 as a safeguard to prevent excessive API calls and associated costs.++Next request.+++AI User:++Instruction: Calculate the value of the message limit plus 100.+Input: None+++AI Assistant:++Function Execution: add+ Args: {'a': 40, 'b': 100}+ Result: 140++Solution: The value of the message limit plus 100 is 140.++Next request.+++AI User:++CAMEL_TASK_DONE+++AI Assistant:++Solution: Understood, the task is completed.++If you have any more tasks or need further assistance, feel free to provide new instructions.+```