🐫 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
docs: update core modules part (#1116)
Wendong-Fan29f926942543
diff --git a/camel/toolkits/dalle_toolkit.py b/camel/toolkits/dalle_toolkit.pyindex 29b4bf7a8..8b2907e78 100644--- a/camel/toolkits/dalle_toolkit.py+++ b/camel/toolkits/dalle_toolkit.py@@ -25,9 +25,8 @@ from camel.toolkits.base import BaseToolkitclass DalleToolkit(BaseToolkit):- r"""A class representing a toolkit for image generation using OpenAI's.-- This class provides methods handle image generation using OpenAI's DALL-E.+ r"""A class representing a toolkit for image generation using OpenAI's+ DALL-E model."""def base64_to_image(self, base64_string: str) -> Optional[Image.Image]:diff --git a/docs/conf.py b/docs/conf.pyindex 53a83c72d..c5e9672b4 100644--- a/docs/conf.py+++ b/docs/conf.py@@ -59,7 +59,7 @@ html_theme_options = {"logo": {"text": f"CAMEL {release}","image_light": "https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png",- "image_dark": "https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_dark.png",+ "image_dark": "https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png",}}diff --git a/docs/cookbooks/agents_message.ipynb b/docs/cookbooks/agents_message.ipynbindex a6e171009..9f864d557 100644--- a/docs/cookbooks/agents_message.ipynb+++ b/docs/cookbooks/agents_message.ipynb@@ -17,7 +17,7 @@{"cell_type": "markdown","source": [- "# 🐫 CAMEL Message Cookbook"+ "# Message Cookbook"],"metadata": {"id": "w5_pa5kKPzAE"@@ -139,7 +139,7 @@"id": "PNBFEXc-R-0s","outputId": "3efcae2c-a001-4098-a78f-bb8fb611925f"},- "execution_count": 2,+ "execution_count": null,"outputs": [{"name": "stdout",@@ -186,7 +186,7 @@"outputId": "aacee56c-7f1e-4220-d98d-f08baeaabb0d","id": "DKcOX661Xvfd"},- "execution_count": 3,+ "execution_count": null,"outputs": [{"output_type": "stream",@@ -228,6 +228,7 @@"- `meta_dict`: An metadata dictionary for the message.\n","\n","Below are optional arguments you can pass:\n",+ "\n","- `video_bytes`: Optional bytes of a video associated with the message.\n","- `image_list`: Optional list of PIL Image objects associated with the message.\n","- `image_detail`: Detail level of the images associated with the message. Default is \"auto\".\n",@@ -255,7 +256,7 @@"metadata": {"id": "pAdDeN7DdUgr"},- "execution_count": 8,+ "execution_count": null,"outputs": []},{@@ -282,7 +283,7 @@"metadata": {"id": "pEiFYV-yez5j"},- "execution_count": 9,+ "execution_count": null,"outputs": []},{@@ -307,7 +308,7 @@"metadata": {"id": "iIWWSfSpEf2n"},- "execution_count": 10,+ "execution_count": null,"outputs": []},{@@ -582,7 +583,7 @@"id": "nbr7nIKxGz07","outputId": "18d99774-b808-4f59-bca4-37606e075ed3"},- "execution_count": 11,+ "execution_count": null,"outputs": [{"output_type": "stream",diff --git a/docs/cookbooks/agents_prompting.ipynb b/docs/cookbooks/agents_prompting.ipynbindex 1e510cccf..2f1e9daa1 100644--- a/docs/cookbooks/agents_prompting.ipynb+++ b/docs/cookbooks/agents_prompting.ipynb@@ -1,113 +1,93 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 CAMEL Prompting Cookbook\n"- ],"metadata": {"id": "SQMBlxsBv1cH"- }+ },+ "source": [+ "# Prompting Cookbook\n"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1VcjPuy2UEYm0xLdriT7OMGt6I2yX9z32?usp=sharing)"- ],"metadata": {"id": "XFyl4eJue3Sm"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1VcjPuy2UEYm0xLdriT7OMGt6I2yX9z32?usp=sharing)"+ ]},{"cell_type": "markdown",- "source": [- "## *TLDR*"- ],"metadata": {"id": "-nCRZU5sInDK"- }+ },+ "source": [+ "## *TLDR*"+ ]},{"cell_type": "markdown",- "source": [- "The CAMEL Prompt module offers a powerful way to guide AI models in producing accurate, contextually relevant, and personalized outputs. This cookbook demonstrates how to use various prompt templates, create custom prompts, and leverage different prompt dictionaries for tasks ranging from role-playing to code generation, evaluation, and more. By mastering the Prompt module, you can significantly enhance your AI agents' capabilities and tailor them to specific tasks."- ],"metadata": {"id": "AwnfLQvMvtXo"- }+ },+ "source": [+ "The CAMEL Prompt module offers a powerful way to guide AI models in producing accurate, contextually relevant, and personalized outputs. This cookbook demonstrates how to use various prompt templates, create custom prompts, and leverage different prompt dictionaries for tasks ranging from role-playing to code generation, evaluation, and more. By mastering the Prompt module, you can significantly enhance your AI agents' capabilities and tailor them to specific tasks."+ ]},{"cell_type": "markdown",- "source": [- "### Installation"- ],"metadata": {"id": "XuZwbB1IIuUi"- }+ },+ "source": [+ "### Installation"+ ]},{"cell_type": "markdown",- "source": [- "Ensure you have CAMEL AI installed in your Python environment:"- ],"metadata": {"id": "gIJK4Lu5Iwm0"- }+ },+ "source": [+ "Ensure you have CAMEL AI installed in your Python environment:"+ ]},{"cell_type": "code",- "source": [- "!pip install \"camel-ai==0.2.4\""- ],+ "execution_count": null,"metadata": {- "id": "HTKnWg9Xv_y4",- "collapsed": true+ "collapsed": true,+ "id": "HTKnWg9Xv_y4"},- "execution_count": null,- "outputs": []+ "outputs": [],+ "source": [+ "!pip install \"camel-ai==0.2.4\""+ ]},{"cell_type": "markdown",- "source": [- "### 🔑 Setting Up API Keys"- ],"metadata": {"id": "MyTTCe3IR_Lr"- }+ },+ "source": [+ "### 🔑 Setting Up API Keys"+ ]},{"cell_type": "markdown",- "source": [- "You'll need to set up your API keys for OpenAI."- ],"metadata": {"id": "REqzgGL9SEaD"- }+ },+ "source": [+ "You'll need to set up your API keys for OpenAI."+ ]},{"cell_type": "code",- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"- ],+ "execution_count": 2,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -115,7 +95,6 @@"id": "PNBFEXc-R-0s","outputId": "781a8745-1042-4d30-d5b0-25da839667bd"},- "execution_count": 2,"outputs": [{"name": "stdout",@@ -124,20 +103,47 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{"cell_type": "markdown",+ "metadata": {+ "id": "GB5JK4Xs2fe6"+ },"source": ["## Getting Started with Prompt Templates\n","CAMEL offers a wide range of pre-defined prompt templates that you can use to quickly create specialized AI agents. Let's start with a basic example using the TaskSpecifyAgent with the AI_SOCIETY task type."- ],- "metadata": {- "id": "GB5JK4Xs2fe6"- }+ ]},{"cell_type": "code",+ "execution_count": 3,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "754A8R7X2rnP",+ "outputId": "c4daf659-df39-4fb5-8e2b-10e01f75f505"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "Specified task prompt:\n",+ "Design a personalized workshop where the Musician guides the Student through dynamic exercises, including improvisational movement, vocal projection techniques, and audience engagement strategies. Incorporate a mock performance at the end, allowing the Student to showcase their enhanced stage presence, receive constructive feedback, and refine their unique artistic persona.\n",+ "\n"+ ]+ }+ ],"source": ["from camel.agents import TaskSpecifyAgent\n","from camel.configs import ChatGPTConfig\n",@@ -164,70 +170,21 @@")\n","\n","print(f\"Specified task prompt:\\n{specified_task_prompt}\\n\")"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "754A8R7X2rnP",- "outputId": "c4daf659-df39-4fb5-8e2b-10e01f75f505"- },- "execution_count": 3,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "Specified task prompt:\n",- "Design a personalized workshop where the Musician guides the Student through dynamic exercises, including improvisational movement, vocal projection techniques, and audience engagement strategies. Incorporate a mock performance at the end, allowing the Student to showcase their enhanced stage presence, receive constructive feedback, and refine their unique artistic persona.\n",- "\n"- ]- }]},{"cell_type": "markdown",+ "metadata": {+ "id": "JlX8L7-H3Csb"+ },"source": ["## Creating Custom Prompts\n","CAMEL also allows you to create your own custom prompts. Here's an example of how to create and use a custom prompt template:"- ],- "metadata": {- "id": "JlX8L7-H3Csb"- }+ ]},{"cell_type": "code",- "source": [- "from camel.agents import TaskSpecifyAgent\n",- "from camel.configs import ChatGPTConfig\n",- "from camel.models import ModelFactory\n",- "from camel.prompts import TextPrompt\n",- "from camel.types import ModelPlatformType, ModelType\n",- "\n",- "# Set up the model\n",- "model = ModelFactory.create(\n",- " model_platform=ModelPlatformType.OPENAI,\n",- " model_type=ModelType.GPT_4O_MINI,\n",- ")\n",- "\n",- "# Create a custom prompt template\n",- "my_prompt_template = TextPrompt(\n",- " 'Here is a task: I\\'m a {occupation} and I want to {task}. Help me to make this task more specific.'\n",- ")\n",- "\n",- "# Create a task specify agent with the custom prompt\n",- "task_specify_agent = TaskSpecifyAgent(\n",- " model=model, task_specify_prompt=my_prompt_template\n",- ")\n",- "\n",- "# Run the agent with a task prompt\n",- "response = task_specify_agent.run(\n",- " task_prompt=\"get promotion\",\n",- " meta_dict=dict(occupation=\"Software Engineer\"),\n",- ")\n",- "\n",- "print(response)"- ],+ "execution_count": 5,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -235,11 +192,10 @@"id": "uJJQD0LV3DSB","outputId": "5e8a7922-2e7d-4643-f004-152829194d47"},- "execution_count": 5,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["To make your task of getting a promotion more specific, consider breaking it down into actionable steps and defining clear goals. Here’s a refined version of your task:\n","\n",@@ -276,47 +232,61 @@"By following these specific steps, you can create a clear roadmap toward achieving your promotion as a Software Engineer.\n"]}+ ],+ "source": [+ "from camel.agents import TaskSpecifyAgent\n",+ "from camel.configs import ChatGPTConfig\n",+ "from camel.models import ModelFactory\n",+ "from camel.prompts import TextPrompt\n",+ "from camel.types import ModelPlatformType, ModelType\n",+ "\n",+ "# Set up the model\n",+ "model = ModelFactory.create(\n",+ " model_platform=ModelPlatformType.OPENAI,\n",+ " model_type=ModelType.GPT_4O_MINI,\n",+ ")\n",+ "\n",+ "# Create a custom prompt template\n",+ "my_prompt_template = TextPrompt(\n",+ " 'Here is a task: I\\'m a {occupation} and I want to {task}. Help me to make this task more specific.'\n",+ ")\n",+ "\n",+ "# Create a task specify agent with the custom prompt\n",+ "task_specify_agent = TaskSpecifyAgent(\n",+ " model=model, task_specify_prompt=my_prompt_template\n",+ ")\n",+ "\n",+ "# Run the agent with a task prompt\n",+ "response = task_specify_agent.run(\n",+ " task_prompt=\"get promotion\",\n",+ " meta_dict=dict(occupation=\"Software Engineer\"),\n",+ ")\n",+ "\n",+ "print(response)"]},{"cell_type": "markdown",+ "metadata": {+ "id": "l30b1iv53a-C"+ },"source": ["## Advanced Prompt Usage\n","CAMEL provides various prompt dictionaries for different purposes. Let's explore some advanced uses of these prompt templates:"- ],- "metadata": {- "id": "l30b1iv53a-C"- }+ ]},{"cell_type": "markdown",- "source": [- "### 1. Code Generation with CodePromptTemplateDict"- ],"metadata": {"id": "cR_mIHA53dWy"- }+ },+ "source": [+ "### 1. Code Generation with CodePromptTemplateDict"+ ]},{"cell_type": "code",- "source": [- "from camel.prompts import CodePromptTemplateDict\n",- "\n",- "# Generate programming languages\n",- "languages_prompt = CodePromptTemplateDict.GENERATE_LANGUAGES.format(num_languages=5)\n",- "print(f\"Languages prompt:\\n{languages_prompt}\\n\")\n",- "\n",- "# Generate coding tasks\n",- "tasks_prompt = CodePromptTemplateDict.GENERATE_TASKS.format(num_tasks=3)\n",- "print(f\"Tasks prompt:\\n{tasks_prompt}\\n\")\n",- "\n",- "# Create an AI coding assistant prompt\n",- "assistant_prompt = CodePromptTemplateDict.ASSISTANT_PROMPT.format(\n",- " assistant_role=\"Python Expert\",\n",- " task_description=\"Implement a binary search algorithm\",\n",- ")\n",- "print(f\"Assistant prompt:\\n{assistant_prompt}\\n\")"- ],+ "execution_count": 6,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -324,11 +294,10 @@"id": "xdQdjQzy3f9u","outputId": "dcc7446b-e4c3-4e91-d70b-cda2814d8e7c"},- "execution_count": 6,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Languages prompt:\n","List the 5 most commonly used computer programming languages.\n",@@ -357,30 +326,38 @@"\n"]}+ ],+ "source": [+ "from camel.prompts import CodePromptTemplateDict\n",+ "\n",+ "# Generate programming languages\n",+ "languages_prompt = CodePromptTemplateDict.GENERATE_LANGUAGES.format(num_languages=5)\n",+ "print(f\"Languages prompt:\\n{languages_prompt}\\n\")\n",+ "\n",+ "# Generate coding tasks\n",+ "tasks_prompt = CodePromptTemplateDict.GENERATE_TASKS.format(num_tasks=3)\n",+ "print(f\"Tasks prompt:\\n{tasks_prompt}\\n\")\n",+ "\n",+ "# Create an AI coding assistant prompt\n",+ "assistant_prompt = CodePromptTemplateDict.ASSISTANT_PROMPT.format(\n",+ " assistant_role=\"Python Expert\",\n",+ " task_description=\"Implement a binary search algorithm\",\n",+ ")\n",+ "print(f\"Assistant prompt:\\n{assistant_prompt}\\n\")"]},{"cell_type": "markdown",- "source": [- "### 2. Evaluation with EvaluationPromptTemplateDict"- ],"metadata": {"id": "FV6Jpu8f3m-Z"- }+ },+ "source": [+ "### 2. Evaluation with EvaluationPromptTemplateDict"+ ]},{"cell_type": "code",- "source": [- "from camel.prompts import EvaluationPromptTemplateDict\n",- "\n",- "# Generate evaluation questions\n",- "questions_prompt = EvaluationPromptTemplateDict.GENERATE_QUESTIONS.format(\n",- " num_questions=5,\n",- " field=\"Machine Learning\",\n",- " examples=\"1. What is the difference between supervised and unsupervised learning?\\n2. Explain the concept of overfitting.\",\n",- ")\n",- "print(f\"Evaluation questions prompt:\\n{questions_prompt}\\n\")"- ],+ "execution_count": 7,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -388,11 +365,10 @@"id": "f-Q-gZAi3nbR","outputId": "f670ef3f-dcdc-4285-b4a2-280806dd779c"},- "execution_count": 7,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Evaluation questions prompt:\n","Generate 5 {category} diverse questions.\n",@@ -404,26 +380,31 @@"\n"]}+ ],+ "source": [+ "from camel.prompts import EvaluationPromptTemplateDict\n",+ "\n",+ "# Generate evaluation questions\n",+ "questions_prompt = EvaluationPromptTemplateDict.GENERATE_QUESTIONS.format(\n",+ " num_questions=5,\n",+ " field=\"Machine Learning\",\n",+ " examples=\"1. What is the difference between supervised and unsupervised learning?\\n2. Explain the concept of overfitting.\",\n",+ ")\n",+ "print(f\"Evaluation questions prompt:\\n{questions_prompt}\\n\")"]},{"cell_type": "markdown",- "source": [- "### 3. Object Recognition with ObjectRecognitionPromptTemplateDict"- ],"metadata": {"id": "sq3fTArB3qEx"- }+ },+ "source": [+ "### 3. Object Recognition with ObjectRecognitionPromptTemplateDict"+ ]},{"cell_type": "code",- "source": [- "from camel.prompts import ObjectRecognitionPromptTemplateDict\n",- "\n",- "# Create an object recognition assistant prompt\n",- "recognition_prompt = ObjectRecognitionPromptTemplateDict.ASSISTANT_PROMPT\n",- "print(f\"Object recognition prompt:\\n{recognition_prompt}\\n\")"- ],+ "execution_count": 8,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -431,11 +412,10 @@"id": "5XTQuohX3sOk","outputId": "e0557d9d-3c9f-4c45-aab8-a96bb5b3204f"},- "execution_count": 8,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Object recognition prompt:\n","You have been assigned an object recognition task.\n",@@ -445,26 +425,27 @@"\n"]}+ ],+ "source": [+ "from camel.prompts import ObjectRecognitionPromptTemplateDict\n",+ "\n",+ "# Create an object recognition assistant prompt\n",+ "recognition_prompt = ObjectRecognitionPromptTemplateDict.ASSISTANT_PROMPT\n",+ "print(f\"Object recognition prompt:\\n{recognition_prompt}\\n\")"]},{"cell_type": "markdown",- "source": [- "### 4. Translation with TranslationPromptTemplateDict"- ],"metadata": {"id": "OxgxXQBt3uRt"- }+ },+ "source": [+ "### 4. Translation with TranslationPromptTemplateDict"+ ]},{"cell_type": "code",- "source": [- "from camel.prompts import TranslationPromptTemplateDict\n",- "\n",- "# Create a translation assistant prompt\n",- "translation_prompt = TranslationPromptTemplateDict.ASSISTANT_PROMPT.format(target_language=\"Spanish\")\n",- "print(f\"Translation prompt:\\n{translation_prompt}\\n\")"- ],+ "execution_count": 9,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -472,11 +453,10 @@"id": "w1k00XLu3xIk","outputId": "5f09d70a-4095-496d-cfae-c7fe05dbc7a7"},- "execution_count": 9,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Translation prompt:\n","You are an expert English to {language} translator.\n",@@ -488,17 +468,38 @@"\n"]}+ ],+ "source": [+ "from camel.prompts import TranslationPromptTemplateDict\n",+ "\n",+ "# Create a translation assistant prompt\n",+ "translation_prompt = TranslationPromptTemplateDict.ASSISTANT_PROMPT.format(target_language=\"Spanish\")\n",+ "print(f\"Translation prompt:\\n{translation_prompt}\\n\")"]},{"cell_type": "markdown",+ "metadata": {+ "id": "vGTRxblx3zHR"+ },"source": ["## Conclusion\n","The CAMEL Prompt module provides a powerful and flexible way to guide AI models in producing desired outputs. By using pre-defined prompt templates, creating custom prompts, and leveraging different prompt dictionaries, you can create highly specialized AI agents tailored to your specific needs."- ],- "metadata": {- "id": "vGTRxblx3zHR"- }+ ]}- ]-}\ No newline at end of file+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/agents_society.ipynb b/docs/cookbooks/agents_society.ipynbindex 0ae431ac0..677a3c222 100644--- a/docs/cookbooks/agents_society.ipynb+++ b/docs/cookbooks/agents_society.ipynb@@ -1,12 +1,13 @@{"cells": [{+ "attachments": {},"cell_type": "markdown","metadata": {"id": "GsSUEbff5MPM"},"source": [- "# 🐫 CAMEL Society Cookbook"+ "# Society Cookbook"]},{@@ -167,21 +168,21 @@},{"cell_type": "markdown",- "source": [- "### Installation"- ],"metadata": {"id": "kETDiaP2Rrdb"- }+ },+ "source": [+ "### Installation"+ ]},{"cell_type": "markdown",- "source": [- "Ensure you have CAMEL AI installed in your Python environment:"- ],"metadata": {"id": "Cg96MkbcRtQR"- }+ },+ "source": [+ "Ensure you have CAMEL AI installed in your Python environment:"+ ]},{"cell_type": "code",@@ -196,32 +197,25 @@},{"cell_type": "markdown",- "source": [- "### Setting Up API Keys"- ],"metadata": {"id": "MyTTCe3IR_Lr"- }+ },+ "source": [+ "### Setting Up API Keys"+ ]},{"cell_type": "markdown",- "source": [- "You'll need to set up your API keys for OpenAI."- ],"metadata": {"id": "REqzgGL9SEaD"- }+ },+ "source": [+ "You'll need to set up your API keys for OpenAI."+ ]},{"cell_type": "code",- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"- ],+ "execution_count": 2,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -229,7 +223,6 @@"id": "PNBFEXc-R-0s","outputId": "4873f5cd-f658-4102-f254-f3df2300156c"},- "execution_count": 2,"outputs": [{"name": "stdout",@@ -238,6 +231,14 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{@@ -253,10 +254,10 @@"cell_type": "code","execution_count": 3,"metadata": {+ "id": "i6_PTBS65MPS","vscode": {"languageId": "plaintext"- },- "id": "i6_PTBS65MPS"+ }},"outputs": [],"source": [@@ -270,19 +271,19 @@"cell_type": "code","execution_count": 4,"metadata": {- "vscode": {- "languageId": "plaintext"- },"colab": {"base_uri": "https://localhost:8080/"},"id": "Q7NPevJj5MPS",- "outputId": "83c5549e-23b4-4a92-f8c4-94fbd34d11b3"+ "outputId": "83c5549e-23b4-4a92-f8c4-94fbd34d11b3",+ "vscode": {+ "languageId": "plaintext"+ }},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[32mAI Assistant sys message:\n","BaseMessage(role_name='Python Programmer', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': 'Develop a Python-based trading bot that utilizes machine learning to analyze historical stock data, identify patterns, and execute buy/sell orders automatically. The bot should incorporate risk management strategies, backtesting capabilities, and real-time market data integration, focusing on tech stocks with a minimum trading volume of 1 million shares daily.', 'assistant_role': 'Python Programmer', 'user_role': 'Stock Trader'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a Python Programmer and I am a Stock Trader. 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: Develop a Python-based trading bot that utilizes machine learning to analyze historical stock data, identify patterns, and execute buy/sell orders automatically. The bot should incorporate risk management strategies, backtesting capabilities, and real-time market data integration, focusing on tech stocks with a minimum trading volume of 1 million shares daily.. 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.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n",@@ -1644,17 +1645,17 @@}],"metadata": {- "language_info": {- "name": "python"- },"colab": {"provenance": []},"kernelspec": {- "name": "python3",- "display_name": "Python 3"+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"}},"nbformat": 4,"nbformat_minor": 0-}\ No newline at end of file+}diff --git a/docs/cookbooks/agents_tracking.ipynb b/docs/cookbooks/agents_tracking.ipynbindex 34a6d3615..54e9a826a 100644--- a/docs/cookbooks/agents_tracking.ipynb+++ b/docs/cookbooks/agents_tracking.ipynb@@ -1,72 +1,59 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 Using AgentOps to Track CAMEL Agents"- ],"metadata": {"id": "xfCn_BAUzUn1"- }+ },+ "source": [+ "# Track CAMEL Agents with AgentOps"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1z1-c0zYuErO7Zh2EATPyDSgrlkrxGTFR?usp=sharing)"- ],"metadata": {"id": "8XgBUh3mU7iZ"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1z1-c0zYuErO7Zh2EATPyDSgrlkrxGTFR?usp=sharing)"+ ]},{"cell_type": "markdown",- "source": [- "*Goal: Track and analysis the running of CAMEL Single Agent and Multiple Agents including LLMs and Tools usage*"- ],"metadata": {"id": "vB9bXVtbz2G3"- }+ },+ "source": [+ "*Goal: Track and analysis the running of CAMEL Single Agent and Multiple Agents including LLMs and Tools usage*"+ ]},{"cell_type": "markdown",- "source": [- "<img src=\"https://raw.githubusercontent.com/AgentOps-AI/agentops/main/docs/images/external/app_screenshots/drilldown.gif\"/>"- ],"metadata": {"id": "MW7aNzQJBYp7"- }+ },+ "source": [+ "<img src=\"https://raw.githubusercontent.com/AgentOps-AI/agentops/main/docs/images/external/app_screenshots/drilldown.gif\"/>"+ ]},{"cell_type": "markdown",- "source": [- "## 📦 Installation"- ],"metadata": {"id": "hKWiwah20PNq"- }+ },+ "source": [+ "## 📦 Installation"+ ]},{"cell_type": "markdown",- "source": [- "First, install the CAMEL and AgentOps package with all its dependencies:"- ],"metadata": {"id": "DpO2RbCY52fk"- }+ },+ "source": [+ "First, install the CAMEL and AgentOps package with all its dependencies:"+ ]},{"cell_type": "code",@@ -83,33 +70,29 @@},{"cell_type": "markdown",- "source": [- "## 🔑 Setting Up API Keys"- ],"metadata": {"id": "tsI56w-N5-Fk"- }+ },+ "source": [+ "## 🔑 Setting Up API Keys"+ ]},{"cell_type": "code",+ "execution_count": 2,+ "metadata": {+ "id": "BSWFiGJ4uKJS"+ },+ "outputs": [],"source": ["import agentops\n","import os\n","from getpass import getpass"- ],- "metadata": {- "id": "BSWFiGJ4uKJS"- },- "execution_count": 2,- "outputs": []+ ]},{"cell_type": "code",- "source": [- "# Prompt for the OpenAI API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"- ],+ "execution_count": 3,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -117,7 +100,6 @@"id": "7AftfweruKxo","outputId": "b510aa61-6a11-4fd2-915c-e9dc55540a3a"},- "execution_count": 3,"outputs": [{"name": "stdout",@@ -126,24 +108,25 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "# Prompt for the OpenAI API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{"cell_type": "markdown",- "source": [- "You can go to [here](https://app.agentops.ai/signin) to get **free** API Key from AgentOps"- ],"metadata": {"id": "fHwVVDMJ0lLx"- }+ },+ "source": [+ "You can go to [here](https://app.agentops.ai/signin) to get **free** API Key from AgentOps"+ ]},{"cell_type": "code",- "source": [- "# Prompt for the AgentOps API key securely\n",- "agentops_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key"- ],+ "execution_count": 4,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -151,7 +134,6 @@"id": "WpYY5oTyuS7P","outputId": "fcd40766-01e2-4303-ef01-723435ae3a8e"},- "execution_count": 4,"outputs": [{"name": "stdout",@@ -160,58 +142,58 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "# Prompt for the AgentOps API key securely\n",+ "agentops_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key"]},{"cell_type": "markdown",- "source": [- "## 🤖 Run CAMEL Single Agent with Tool by using AgentOps to track the whole process!"- ],"metadata": {"id": "htBhPJx00ycJ"- }+ },+ "source": [+ "## 🤖 Run CAMEL Single Agent with Tool by using AgentOps to track the whole process!"+ ]},{"cell_type": "markdown",- "source": [- "Import required modules from CAMEL"- ],"metadata": {"id": "tD681Bxi1vRo"- }+ },+ "source": [+ "Import required modules from CAMEL"+ ]},{"cell_type": "code",+ "execution_count": 5,+ "metadata": {+ "id": "CuJQPZG-1yey"+ },+ "outputs": [],"source": ["from camel.agents import ChatAgent\n","from camel.configs import ChatGPTConfig\n","from camel.messages import BaseMessage\n","from camel.models import ModelFactory\n","from camel.types import ModelPlatformType, ModelType"- ],- "metadata": {- "id": "CuJQPZG-1yey"- },- "execution_count": 5,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Initilize AgentOps, you need to import toolkits after init of agentops so that the tool useage would be tracked."- ],"metadata": {"id": "Kc3uKwd71sHG"- }+ },+ "source": [+ "Initilize AgentOps, you need to import toolkits after init of agentops so that the tool useage would be tracked."+ ]},{"cell_type": "code",- "source": [- "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\n",- "agentops.init(AGENTOPS_API_KEY, default_tags=[\"CAMEL X AgentOps Single Agent with Tool Example\"])\n",- "\n",- "from camel.toolkits import SearchToolkit"- ],+ "execution_count": 6,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -220,29 +202,39 @@"id": "_3FycEiQ1qDy","outputId": "c578e8a5-1059-483c-b623-7f9ae4617f66"},- "execution_count": 6,"outputs": [{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: WARNING: agentops is out of date. Please update with the command: 'pip install --upgrade agentops'\n","🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=db687abe-4e5c-43d5-8eb2-21bf403256e7\u001b[0m\u001b[0m\n"]}+ ],+ "source": [+ "AGENTOPS_API_KEY = os.getenv(\"AGENTOPS_API_KEY\")\n",+ "agentops.init(AGENTOPS_API_KEY, default_tags=[\"CAMEL X AgentOps Single Agent with Tool Example\"])\n",+ "\n",+ "from camel.toolkits import SearchToolkit"]},{"cell_type": "markdown",- "source": [- "Set one Agent with Search Tools"- ],"metadata": {"id": "Ehu6-xC610Bj"- }+ },+ "source": [+ "Set one Agent with Search Tools"+ ]},{"cell_type": "code",+ "execution_count": 7,+ "metadata": {+ "id": "DhMcowdE19Ti"+ },+ "outputs": [],"source": ["# Define system message\n","sys_msg = BaseMessage.make_assistant_message(\n",@@ -264,35 +256,20 @@" model=model,\n"," tools=tools,\n",")"- ],- "metadata": {- "id": "DhMcowdE19Ti"- },- "execution_count": 7,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Set user query and run the agent"- ],"metadata": {"id": "vbFL0h-O1_PM"- }+ },+ "source": [+ "Set user query and run the agent"+ ]},{"cell_type": "code",- "source": [- "# Define a user message\n",- "usr_msg = 'What is CAMEL-AI.org?'\n",- "\n",- "# Get response information\n",- "response = camel_agent.step(usr_msg)\n",- "print(response)\n",- "\n",- "\n",- "agentops.end_session(\"Success\")"- ],+ "execution_count": 8,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -300,63 +277,78 @@"id": "3TT62TanuYqI","outputId": "b19d730e-d2f7-416b-af1b-1cbeb7a4d248"},- "execution_count": 8,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["msgs=[BaseMessage(role_name='Tools calling opertor', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={}, content='CAMEL-AI.org is the official website for CAMEL, which is described as the first large language model (LLM) multi-agent framework. It is an open-source community dedicated to exploring the scaling laws of agents. The framework allows users to customize agents using modular components for specific tasks, facilitating research and development in the field of artificial intelligence.\\n\\nHere are some key points about CAMEL-AI:\\n\\n1. **Multi-Agent Framework**: CAMEL provides a structure for developing and utilizing multiple agents that can work together.\\n2. **Open Source**: The project is open-source, encouraging collaboration and contributions from the community.\\n3. **Customization**: Users can customize agents to perform specific tasks, enhancing their functionality and adaptability.\\n4. **Research Focus**: The initiative aims to study agents on a large scale to gain insights into their behaviors, capabilities, and potential risks.\\n\\nFor more information, you can visit their official website: [CAMEL-AI.org](https://www.camel-ai.org/).', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')] terminated=False info={'id': 'chatcmpl-ALp4yBEZ70iWRyC2nU7Ns5Y4cqS5N', 'usage': {'completion_tokens': 204, 'prompt_tokens': 993, 'total_tokens': 1197, 'completion_tokens_details': {'audio_tokens': None, 'reasoning_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': None, 'cached_tokens': 0}}, 'termination_reasons': ['stop'], 'num_tokens': 679, 'tool_calls': [FunctionCallingRecord(func_name='search_google', args={'query': 'CAMEL-AI.org'}, result=[{'error': 'google search failed.'}]), FunctionCallingRecord(func_name='search_duckduckgo', args={'query': 'CAMEL-AI.org'}, result=[{'result_id': 1, 'title': 'Camel-ai', 'description': 'CAMEL-AI.org is the 1st LLM multi-agent framework and an open-source community dedicated to finding the scaling law of agents. Get Started. 1 Customize agents. Customizable agents are the fundamental entities of the CAMEL architecture. CAMEL empowers you to customize agents using our modular components for specific tasks.', 'url': 'https://www.camel-ai.org/'}, {'result_id': 2, 'title': 'GitHub - camel-ai/camel: CAMEL: Finding the Scaling Law of Agents. A ...', 'description': '🐫 CAMEL: Finding the Scaling Law of Agents. A multi-agent framework. https://www.camel-ai.org - camel-ai/camel', 'url': 'https://github.com/camel-ai/camel'}, {'result_id': 3, 'title': 'CAMEL-AI - CRAB: Cross-environment Agent Benchmark for Multimodal ...', 'description': 'Please open the X app on my phone, search for CAMEL-AI.org, check the latest post, summarize them, and then send the summary to Tianqi Xu on Slack from my PC. Settings: OpenAI GPT-4o + Single Agent Demo videos are edited for a better viewing experience. In actual execution, there are tens of seconds of waiting time between each step.', 'url': 'https://crab.camel-ai.org/'}, {'result_id': 4, 'title': \"Welcome to CAMEL's documentation! — CAMEL 0.2.2 documentation\", 'description': \"Welcome to CAMEL's documentation! #. We design practical artificial general intelligence. CAMEL emerges as the earliest LLM-based multi-agent framework, and is now a generic framework to build and use LLM-based agents for real-world task solving. We believe that studying these agents on a large scale offers valuable insights into their ...\", 'url': 'https://docs.camel-ai.org/'}, {'result_id': 5, 'title': 'Team - CAMEL-AI', 'description': 'Camel-AI Team. We are finding the scaling law of agent. 🐫 CAMEL is an open-source library designed for 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 implement ...', 'url': 'https://www.camel-ai.org/about'}])], 'external_tool_request': None}\n"]},{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: This run's cost $0.000411\n","🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=db687abe-4e5c-43d5-8eb2-21bf403256e7\u001b[0m\u001b[0m\n"]}+ ],+ "source": [+ "# Define a user message\n",+ "usr_msg = 'What is CAMEL-AI.org?'\n",+ "\n",+ "# Get response information\n",+ "response = camel_agent.step(usr_msg)\n",+ "print(response)\n",+ "\n",+ "\n",+ "agentops.end_session(\"Success\")"]},{"cell_type": "markdown",- "source": [- "### 🎉 Go to the AgentOps link shown above, you will be able to see the detailed record for this running like below."- ],"metadata": {"id": "gRdtzKEn2F9t"- }+ },+ "source": [+ "### 🎉 Go to the AgentOps link shown above, you will be able to see the detailed record for this running like below."+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "Glt8bYV4yHwW"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- "## 🤖🤖 Run CAMEL Multi-agent with Tool by using AgentOps to track the whole process!"- ],"metadata": {"id": "jnCwxeW82YEw"- }+ },+ "source": [+ "## 🤖🤖 Run CAMEL Multi-agent with Tool by using AgentOps to track the whole process!"+ ]},{"cell_type": "markdown",- "source": [- "Import required modules"- ],"metadata": {"id": "7cw_P_ab2gLp"- }+ },+ "source": [+ "Import required modules"+ ]},{"cell_type": "code",+ "execution_count": 9,+ "metadata": {+ "id": "8DJgHQ7_2qxI"+ },+ "outputs": [],"source": ["from typing import List\n","\n",@@ -370,32 +362,20 @@"from camel.utils import print_text_animated\n","\n","import agentops"- ],- "metadata": {- "id": "8DJgHQ7_2qxI"- },- "execution_count": 9,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Initilize AgentOps, you need to import toolkits after init of agentops so that the tool useage would be tracked."- ],"metadata": {"id": "W-lbshs42tFE"- }+ },+ "source": [+ "Initilize AgentOps, you need to import toolkits after init of agentops so that the tool useage would be tracked."+ ]},{"cell_type": "code",- "source": [- "agentops.start_session(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n",- "\n",- "from camel.toolkits import (\n",- " SearchToolkit,\n",- " MathToolkit,\n",- ")"- ],+ "execution_count": 10,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -403,28 +383,40 @@"id": "Sl0WYG_P2zm0","outputId": "b1454134-523c-4130-9f13-f1e745b382ac"},- "execution_count": 10,"outputs": [{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=6c46dfa1-662b-40e1-8343-b40934c5659c\u001b[0m\u001b[0m\n"]}+ ],+ "source": [+ "agentops.start_session(tags=[\"CAMEL X AgentOps Multi-agent with Tools\"])\n",+ "\n",+ "from camel.toolkits import (\n",+ " SearchToolkit,\n",+ " MathToolkit,\n",+ ")"]},{"cell_type": "markdown",- "source": [- "Set your task prompt"- ],"metadata": {"id": "7-eQpg4M3JDq"- }+ },+ "source": [+ "Set your task prompt"+ ]},{"cell_type": "code",+ "execution_count": 11,+ "metadata": {+ "id": "dOuEoNyK3KlM"+ },+ "outputs": [],"source": ["task_prompt = (\n"," \"Assume now is 2024 in the Gregorian calendar, \"\n",@@ -433,47 +425,47 @@" \"and get the current weather of the city where \"\n"," \"the University is located.\"\n",")"- ],- "metadata": {- "id": "dOuEoNyK3KlM"- },- "execution_count": 11,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Set tools for the assistant agent, we wish the agent would be able to do mathmatic calculation and search information from websites"- ],"metadata": {"id": "yiRYDJ8M3UDE"- }+ },+ "source": [+ "Set tools for the assistant agent, we wish the agent would be able to do mathmatic calculation and search information from websites"+ ]},{"cell_type": "code",+ "execution_count": 12,+ "metadata": {+ "id": "7Re8DJ4r3YyY"+ },+ "outputs": [],"source": ["tools = [\n"," *MathToolkit().get_tools(),\n"," *SearchToolkit().get_tools(),\n","]"- ],- "metadata": {- "id": "7Re8DJ4r3YyY"- },- "execution_count": 12,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Set up Role Playing session"- ],"metadata": {"id": "P3KGyxYi4MNC"- }+ },+ "source": [+ "Set up Role Playing session"+ ]},{"cell_type": "code",+ "execution_count": 13,+ "metadata": {+ "id": "m1BPtWgi33FJ"+ },+ "outputs": [],"source": ["role_play_session = RolePlaying(\n"," assistant_role_name=\"Searcher\",\n",@@ -494,39 +486,20 @@" task_prompt=task_prompt,\n"," with_task_specify=False,\n",")"- ],- "metadata": {- "id": "m1BPtWgi33FJ"- },- "execution_count": 13,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Print the system message and task prompt"- ],"metadata": {"id": "Qp3WwE-r4WTZ"- }+ },+ "source": [+ "Print the system message and task prompt"+ ]},{"cell_type": "code",- "source": [- "print(\n",- " Fore.GREEN\n",- " + f\"AI Assistant sys message:\\n{role_play_session.assistant_sys_msg}\\n\"\n",- ")\n",- "print(Fore.BLUE + f\"AI User sys message:\\n{role_play_session.user_sys_msg}\\n\")\n",- "\n",- "print(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\n",- "print(\n",- " Fore.CYAN\n",- " + \"Specified task prompt:\"\n",- " + f\"\\n{role_play_session.specified_task_prompt}\\n\"\n",- ")\n",- "print(Fore.RED + f\"Final task prompt:\\n{role_play_session.task_prompt}\\n\")"- ],+ "execution_count": 14,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -534,11 +507,10 @@"id": "_xmNJtft4aZx","outputId": "a0e591c3-daac-4ffc-e5d4-e9d412cc9c78"},- "execution_count": 14,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[32mAI Assistant sys message:\n","BaseMessage(role_name='Searcher', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': 'Assume now is 2024 in the Gregorian calendar, estimate the current age of University of Oxford and then add 10 more years to this age, and get the current weather of the city where the University is located.', '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: Assume now is 2024 in the Gregorian calendar, estimate the current age of University of Oxford and then add 10 more years to this age, and get the current weather of the city where the University is located.. 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.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n",@@ -557,65 +529,35 @@"\n"]}+ ],+ "source": [+ "print(\n",+ " Fore.GREEN\n",+ " + f\"AI Assistant sys message:\\n{role_play_session.assistant_sys_msg}\\n\"\n",+ ")\n",+ "print(Fore.BLUE + f\"AI User sys message:\\n{role_play_session.user_sys_msg}\\n\")\n",+ "\n",+ "print(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\n",+ "print(\n",+ " Fore.CYAN\n",+ " + \"Specified task prompt:\"\n",+ " + f\"\\n{role_play_session.specified_task_prompt}\\n\"\n",+ ")\n",+ "print(Fore.RED + f\"Final task prompt:\\n{role_play_session.task_prompt}\\n\")"]},{"cell_type": "markdown",- "source": [- "Set terminate rule and print the chat message"- ],"metadata": {"id": "d5JjlXhs4cJT"- }+ },+ "source": [+ "Set terminate rule and print the chat message"+ ]},{"cell_type": "code",- "source": [- "n = 0\n",- "input_msg = role_play_session.init_chat()\n",- "while n < 50:\n",- " n += 1\n",- " assistant_response, user_response = role_play_session.step(input_msg)\n",- "\n",- " if assistant_response.terminated:\n",- " print(\n",- " Fore.GREEN\n",- " + (\n",- " \"AI Assistant terminated. Reason: \"\n",- " f\"{assistant_response.info['termination_reasons']}.\"\n",- " )\n",- " )\n",- " break\n",- " if user_response.terminated:\n",- " print(\n",- " Fore.GREEN\n",- " + (\n",- " \"AI User terminated. \"\n",- " f\"Reason: {user_response.info['termination_reasons']}.\"\n",- " )\n",- " )\n",- " break\n",- "\n",- " # Print output from the user\n",- " print_text_animated(\n",- " Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n",- " )\n",- "\n",- " # Print output from the assistant, including any function\n",- " # execution information\n",- " print_text_animated(Fore.GREEN + \"AI Assistant:\")\n",- " tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n",- " 'tool_calls'\n",- " ]\n",- " for func_record in tool_calls:\n",- " print_text_animated(f\"{func_record}\")\n",- " print_text_animated(f\"{assistant_response.msg.content}\\n\")\n",- "\n",- " if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n",- " break\n",- "\n",- " input_msg = assistant_response.msg"- ],+ "execution_count": 15,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -623,11 +565,10 @@"id": "z7bjGKlr4eVf","outputId": "e8a96451-f7c8-49f8-9930-01796a7866e9"},- "execution_count": 15,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[34mAI User:\n","\n",@@ -787,22 +728,66 @@"\n"]}+ ],+ "source": [+ "n = 0\n",+ "input_msg = role_play_session.init_chat()\n",+ "while n < 50:\n",+ " n += 1\n",+ " assistant_response, user_response = role_play_session.step(input_msg)\n",+ "\n",+ " if assistant_response.terminated:\n",+ " print(\n",+ " Fore.GREEN\n",+ " + (\n",+ " \"AI Assistant terminated. Reason: \"\n",+ " f\"{assistant_response.info['termination_reasons']}.\"\n",+ " )\n",+ " )\n",+ " break\n",+ " if user_response.terminated:\n",+ " print(\n",+ " Fore.GREEN\n",+ " + (\n",+ " \"AI User terminated. \"\n",+ " f\"Reason: {user_response.info['termination_reasons']}.\"\n",+ " )\n",+ " )\n",+ " break\n",+ "\n",+ " # Print output from the user\n",+ " print_text_animated(\n",+ " Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\"\n",+ " )\n",+ "\n",+ " # Print output from the assistant, including any function\n",+ " # execution information\n",+ " print_text_animated(Fore.GREEN + \"AI Assistant:\")\n",+ " tool_calls: List[FunctionCallingRecord] = assistant_response.info[\n",+ " 'tool_calls'\n",+ " ]\n",+ " for func_record in tool_calls:\n",+ " print_text_animated(f\"{func_record}\")\n",+ " print_text_animated(f\"{assistant_response.msg.content}\\n\")\n",+ "\n",+ " if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n",+ " break\n",+ "\n",+ " input_msg = assistant_response.msg"]},{"cell_type": "markdown",- "source": [- "End the AgentOps session"- ],"metadata": {"id": "pYZAD7-H4hhQ"- }+ },+ "source": [+ "End the AgentOps session"+ ]},{"cell_type": "code",- "source": [- "agentops.end_session(\"Success\")"- ],+ "execution_count": 16,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -810,35 +795,51 @@"id": "c8YKJgu94k35","outputId": "6b8a2de9-e3fb-45bd-f916-febc12d14d8b"},- "execution_count": 16,"outputs": [{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: This run's cost $0.004198\n","🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=6c46dfa1-662b-40e1-8343-b40934c5659c\u001b[0m\u001b[0m\n"]}+ ],+ "source": [+ "agentops.end_session(\"Success\")"]},{"cell_type": "markdown",- "source": [- "### 🎉 Go to the AgentOps link shown above, you will be able to see the detailed record for the multi-agent running like below."- ],"metadata": {"id": "kf1i_sXw2LZ7"- }+ },+ "source": [+ "### 🎉 Go to the AgentOps link shown above, you will be able to see the detailed record for the multi-agent running like below."+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "Q2wNxipj13fa"- }+ },+ "source": [+ ""+ ]}- ]-}\ No newline at end of file+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/agents_with_memory.ipynb b/docs/cookbooks/agents_with_memory.ipynbindex 6841585d9..36ff02aa0 100644--- a/docs/cookbooks/agents_with_memory.ipynb+++ b/docs/cookbooks/agents_with_memory.ipynb@@ -1,81 +1,68 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 CAMEL Memory Cookbook"- ],"metadata": {"id": "w5_pa5kKPzAE"- }+ },+ "source": [+ "# Memory Cookbook"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1ixGItEqQGkp09_TuV_8SGmz65WHBr5r5?usp=sharing)"- ],"metadata": {"id": "zgqKzSB-PXzi"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1ixGItEqQGkp09_TuV_8SGmz65WHBr5r5?usp=sharing)"+ ]},{"cell_type": "markdown",- "source": [- "## Overview"- ],"metadata": {"id": "lSXa_rQQQzBd"- }+ },+ "source": [+ "## Overview"+ ]},{"cell_type": "markdown",- "source": [- "The Memory module in CAMEL provides a flexible and powerful system for storing, retrieving, and managing information for AI agents. It enables agents to maintain context across conversations and retrieve relevant information from past interactions, enhancing the coherence and relevance of AI responses."- ],"metadata": {"id": "OnmoAw2vQG8I"- }+ },+ "source": [+ "The Memory module in CAMEL provides a flexible and powerful system for storing, retrieving, and managing information for AI agents. It enables agents to maintain context across conversations and retrieve relevant information from past interactions, enhancing the coherence and relevance of AI responses."+ ]},{"cell_type": "markdown",- "source": [- "## Getting Started\n"- ],"metadata": {"id": "l4MP9uUNQ2kr"- }+ },+ "source": [+ "## Getting Started\n"+ ]},{"cell_type": "markdown",- "source": [- "### Installation"- ],"metadata": {"id": "kETDiaP2Rrdb"- }+ },+ "source": [+ "### Installation"+ ]},{"cell_type": "markdown",- "source": [- "Ensure you have CAMEL AI installed in your Python environment:"- ],"metadata": {"id": "Cg96MkbcRtQR"- }+ },+ "source": [+ "Ensure you have CAMEL AI installed in your Python environment:"+ ]},{"cell_type": "code",@@ -91,32 +78,25 @@},{"cell_type": "markdown",- "source": [- "### 🔑 Setting Up API Keys"- ],"metadata": {"id": "MyTTCe3IR_Lr"- }+ },+ "source": [+ "### 🔑 Setting Up API Keys"+ ]},{"cell_type": "markdown",- "source": [- "You'll need to set up your API keys for OpenAI."- ],"metadata": {"id": "REqzgGL9SEaD"- }+ },+ "source": [+ "You'll need to set up your API keys for OpenAI."+ ]},{"cell_type": "code",- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"- ],+ "execution_count": 2,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -124,7 +104,6 @@"id": "PNBFEXc-R-0s","outputId": "50989fca-73bf-4062-cc1f-124bd6abadc1"},- "execution_count": 2,"outputs": [{"name": "stdout",@@ -133,19 +112,30 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{"cell_type": "markdown",- "source": [- "## Usage"- ],"metadata": {"id": "LRojeqp7dP1m"- }+ },+ "source": [+ "## Usage"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "_sJV9GFldTBh"+ },"source": ["To use the Memory module in your agent:\n","\n",@@ -154,31 +144,33 @@"3. Use `write_records()` to add new information to the memory.\n","4. Use `retrieve()` to get relevant context for the agent's next action.\n","5. Use `get_context()` to obtain the formatted context for the agent."- ],- "metadata": {- "id": "_sJV9GFldTBh"- }+ ]},{"cell_type": "markdown",- "source": [- "### Setting `LongtermAgentMemory`:"- ],"metadata": {"id": "aiypnpqJoZ4G"- }+ },+ "source": [+ "### Setting `LongtermAgentMemory`:"+ ]},{"cell_type": "markdown",- "source": [- "Import required modules"- ],"metadata": {"id": "C2kVCRA7dD4A"- }+ },+ "source": [+ "Import required modules"+ ]},{"cell_type": "code",+ "execution_count": 3,+ "metadata": {+ "id": "UOKw2hCSdCXm"+ },+ "outputs": [],"source": ["from camel.memories import (\n"," ChatHistoryBlock,\n",@@ -190,15 +182,27 @@"from camel.messages import BaseMessage\n","from camel.types import ModelType, OpenAIBackendRole\n","from camel.utils import OpenAITokenCounter"- ],- "metadata": {- "id": "UOKw2hCSdCXm"- },- "execution_count": 3,- "outputs": []+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "pAdDeN7DdUgr",+ "outputId": "75a8c69d-8e2b-4af5-e7a7-c4205718ee10"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "[{'role': 'user', 'content': 'What is CAMEL AI?'}, {'role': 'assistant', 'content': 'CAMEL-AI.org is the 1st LLM multi-agent framework and an open-source community dedicated to finding the scaling law of agents.'}]\n"+ ]+ }+ ],"source": ["# Initialize the memory\n","memory = LongtermAgentMemory(\n",@@ -235,30 +239,11 @@"context, token_count = memory.get_context()\n","\n","print(context)"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "pAdDeN7DdUgr",- "outputId": "75a8c69d-8e2b-4af5-e7a7-c4205718ee10"- },- "execution_count": 4,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "[{'role': 'user', 'content': 'What is CAMEL AI?'}, {'role': 'assistant', 'content': 'CAMEL-AI.org is the 1st LLM multi-agent framework and an open-source community dedicated to finding the scaling law of agents.'}]\n"- ]- }]},{"cell_type": "code",- "source": [- "print(token_count)"- ],+ "execution_count": 5,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -266,28 +251,47 @@"id": "pEiFYV-yez5j","outputId": "c72b113f-5f75-4a7e-8f23-379c954da66e"},- "execution_count": 5,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["49\n"]}+ ],+ "source": [+ "print(token_count)"]},{"cell_type": "markdown",- "source": [- "### Adding `LongtermAgentMemory` to your `ChatAgent`:"- ],"metadata": {"id": "K-P9rD6Foe5j"- }+ },+ "source": [+ "### Adding `LongtermAgentMemory` to your `ChatAgent`:"+ ]},{"cell_type": "code",+ "execution_count": 6,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "Mp-KXFdGpKZt",+ "outputId": "08ca25ef-2d14-4554-bcce-f031ef3dd740"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "CAMEL AI is recognized as the first LLM (Large Language Model) multi-agent framework. It is an open-source community initiative aimed at exploring and understanding the scaling laws of agents. The framework facilitates the development and deployment of multiple agents that can interact and collaborate, leveraging the capabilities of LLMs to enhance their performance and functionality.\n"+ ]+ }+ ],"source": ["from camel.agents import ChatAgent\n","\n",@@ -309,54 +313,42 @@"\n","# Check the response (just for illustrative purpose)\n","print(response.msgs[0].content)"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "Mp-KXFdGpKZt",- "outputId": "08ca25ef-2d14-4554-bcce-f031ef3dd740"- },- "execution_count": 6,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "CAMEL AI is recognized as the first LLM (Large Language Model) multi-agent framework. It is an open-source community initiative aimed at exploring and understanding the scaling laws of agents. The framework facilitates the development and deployment of multiple agents that can interact and collaborate, leveraging the capabilities of LLMs to enhance their performance and functionality.\n"- ]- }]},{"cell_type": "markdown",- "source": [- "## Advanced Topics"- ],"metadata": {"id": "w0ndTJske1mb"- }+ },+ "source": [+ "## Advanced Topics"+ ]},{"cell_type": "markdown",- "source": [- "### Customizing Context Creator"- ],"metadata": {"id": "9q8EXq2ge6Dq"- }+ },+ "source": [+ "### Customizing Context Creator"+ ]},{"cell_type": "markdown",- "source": [- "You can create custom context creators by subclassing `BaseContextCreator`:"- ],"metadata": {"id": "zUjztraTe7aw"- }+ },+ "source": [+ "You can create custom context creators by subclassing `BaseContextCreator`:"+ ]},{"cell_type": "code",+ "execution_count": 7,+ "metadata": {+ "id": "LX4fyovCe89R"+ },+ "outputs": [],"source": ["from camel.memories import BaseContextCreator\n","\n",@@ -373,33 +365,33 @@" def create_context(self, records):\n"," # Implement your context creation logic\n"," pass"- ],- "metadata": {- "id": "LX4fyovCe89R"- },- "execution_count": 7,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "### Customizing Vector Database Block"- ],"metadata": {"id": "N_HM5wyFfEtO"- }+ },+ "source": [+ "### Customizing Vector Database Block"+ ]},{"cell_type": "markdown",- "source": [- "For `VectorDBBlock`, you can customize it by adjusting the embedding models or vector storages:"- ],"metadata": {"id": "CxcjHzArfFYZ"- }+ },+ "source": [+ "For `VectorDBBlock`, you can customize it by adjusting the embedding models or vector storages:"+ ]},{"cell_type": "code",+ "execution_count": 8,+ "metadata": {+ "id": "iQlxwVM7fJEp"+ },+ "outputs": [],"source": ["from camel.embeddings import OpenAIEmbedding\n","from camel.memories import VectorDBBlock\n",@@ -409,32 +401,41 @@" embedding=OpenAIEmbedding(),\n"," storage=QdrantStorage(vector_dim=OpenAIEmbedding().get_output_dim()),\n",")"- ],- "metadata": {- "id": "iQlxwVM7fJEp"- },- "execution_count": 8,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "### Performance Considerations"- ],"metadata": {"id": "u_pkVP5Eg2vv"- }+ },+ "source": [+ "### Performance Considerations"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "_4C93qAng3SP"+ },"source": ["- For large-scale applications, consider using persistent storage backends instead of in-memory storage.\n","- Optimize your context creator to balance between context relevance and token limits.\n","- When using `VectorDBMemory`, be mindful of the trade-off between retrieval accuracy and speed as the database grows."- ],- "metadata": {- "id": "_4C93qAng3SP"- }+ ]+ }+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"}- ]-}\ No newline at end of file+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/agents_with_rag.ipynb b/docs/cookbooks/agents_with_rag.ipynbindex 01a2d0070..a5dbfda36 100644--- a/docs/cookbooks/agents_with_rag.ipynb+++ b/docs/cookbooks/agents_with_rag.ipynb@@ -1,48 +1,38 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 CAMEL RAG Cookbook\n"- ],"metadata": {"id": "SQMBlxsBv1cH"- }+ },+ "source": [+ "# RAG Cookbook\n"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1sTJ0x_MYRGA76KCg_3I00wj4RL3D2Twp?usp=sharing)"- ],"metadata": {"id": "XFyl4eJue3Sm"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1sTJ0x_MYRGA76KCg_3I00wj4RL3D2Twp?usp=sharing)"+ ]},{"cell_type": "markdown",- "source": [- "## Overview"- ],"metadata": {"id": "-nCRZU5sInDK"- }+ },+ "source": [+ "## Overview"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "AwnfLQvMvtXo"+ },"source": ["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`.\n","\n",@@ -54,54 +44,56 @@"- Single Agent with Auto RAG\n","\n","- Role-playing with Auto RAG"- ],- "metadata": {- "id": "AwnfLQvMvtXo"- }+ ]},{"cell_type": "markdown",- "source": [- "### Installation"- ],"metadata": {"id": "XuZwbB1IIuUi"- }+ },+ "source": [+ "### Installation"+ ]},{"cell_type": "markdown",- "source": [- "Ensure you have CAMEL AI installed in your Python environment:"- ],"metadata": {"id": "gIJK4Lu5Iwm0"- }+ },+ "source": [+ "Ensure you have CAMEL AI installed in your Python environment:"+ ]},{"cell_type": "code",- "source": [- "!pip install \"camel-ai[all]==0.2.4\""- ],+ "execution_count": null,"metadata": {- "id": "HTKnWg9Xv_y4",- "collapsed": true+ "collapsed": true,+ "id": "HTKnWg9Xv_y4"},- "execution_count": null,- "outputs": []+ "outputs": [],+ "source": [+ "!pip install \"camel-ai[all]==0.2.4\""+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "LUpFBEB9vrIz"+ },"source": ["## Load Data\n","Let's first load the CAMEL paper from https://arxiv.org/pdf/2303.17760.pdf. This will be our local example data.\n","\n"- ],- "metadata": {- "id": "LUpFBEB9vrIz"- }+ ]},{"cell_type": "code",+ "execution_count": 2,+ "metadata": {+ "id": "dUVE7z9hwEV7"+ },+ "outputs": [],"source": ["import os\n","import requests\n",@@ -112,40 +104,29 @@"response = requests.get(url)\n","with open('local_data/camel_paper.pdf', 'wb') as file:\n"," file.write(response.content)"- ],- "metadata": {- "id": "dUVE7z9hwEV7"- },- "execution_count": 2,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "HCqghaGiwkdv"+ },"source": ["## 1. Customized RAG\n","In this section we will set our customized RAG pipeline, we will take `VectorRetriever` as an example.\n","Set embedding model, we will use `OpenAIEmbedding` as the embedding model, so we need to set the `OPENAI_API_KEY` in below."- ],- "metadata": {- "id": "HCqghaGiwkdv"- }+ ]},{"cell_type": "code",- "source": [- "from getpass import getpass\n",- "# Prompt for the OpenAI API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"- ],+ "execution_count": 3,"metadata": {- "id": "RxG99FkYwm_p","colab": {"base_uri": "https://localhost:8080/"},+ "id": "RxG99FkYwm_p","outputId": "8598a084-bf50-44d3-d8cb-14e745a6a749"},- "execution_count": 3,"outputs": [{"name": "stdout",@@ -154,42 +135,53 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "from getpass import getpass\n",+ "# Prompt for the OpenAI API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{"cell_type": "markdown",- "source": [- "Import and set the embedding instance:"- ],"metadata": {"id": "NACsmaa0wple"- }+ },+ "source": [+ "Import and set the embedding instance:"+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "id": "NCT5ygT-wrku"+ },+ "outputs": [],"source": ["from camel.embeddings import OpenAIEmbedding\n","from camel.types import EmbeddingModelType\n","\n","embedding_instance = OpenAIEmbedding(model_type=EmbeddingModelType.TEXT_EMBEDDING_3_LARGE)"- ],- "metadata": {- "id": "NCT5ygT-wrku"- },- "execution_count": 4,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Import and set the vector storage instance:"- ],"metadata": {"id": "q4nVmsm0w5lH"- }+ },+ "source": [+ "Import and set the vector storage instance:"+ ]},{"cell_type": "code",+ "execution_count": 5,+ "metadata": {+ "id": "IQ30ih1_w6p3"+ },+ "outputs": [],"source": ["from camel.storages import QdrantStorage\n","\n",@@ -198,60 +190,58 @@" path=\"local_data\",\n"," collection_name=\"camel_paper\",\n",")"- ],- "metadata": {- "id": "IQ30ih1_w6p3"- },- "execution_count": 5,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Import and set the retriever instance:"- ],"metadata": {"id": "W9KccfRDw9F4"- }+ },+ "source": [+ "Import and set the retriever instance:"+ ]},{"cell_type": "code",+ "execution_count": 6,+ "metadata": {+ "id": "d8S6VjAQHnai"+ },+ "outputs": [],"source": ["from camel.retrievers import VectorRetriever\n","\n","vector_retriever = VectorRetriever(embedding_model=embedding_instance,\n"," storage=storage_instance)"- ],- "metadata": {- "id": "d8S6VjAQHnai"- },- "execution_count": 6,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "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.."- ],"metadata": {"id": "PdezllM6Hp83"- }+ },+ "source": [+ "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.."+ ]},{"cell_type": "code",+ "execution_count": 7,+ "metadata": {+ "id": "QTFvD3_SHv3m"+ },+ "outputs": [],"source": ["vector_retriever.process(\n"," content=\"local_data/camel_paper.pdf\",\n",")"- ],- "metadata": {- "id": "QTFvD3_SHv3m"- },- "execution_count": 7,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "0nhIo1wUHyvl"+ },"source": ["\n","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.\n",@@ -261,20 +251,11 @@"- content path\n","- metadata\n","- text"- ],- "metadata": {- "id": "0nhIo1wUHyvl"- }+ ]},{"cell_type": "code",- "source": [- "retrieved_info = vector_retriever.query(\n",- " query=\"To address the challenges of achieving autonomous cooperation, we propose a novel communicative agent framework named role-playing .\",\n",- " top_k=1\n",- ")\n",- "print(retrieved_info)"- ],+ "execution_count": 8,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -282,36 +263,35 @@"id": "uDu43Hb3GVrs","outputId": "55d44e47-fc6c-4c28-8820-613016a11830"},- "execution_count": 8,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["[{'similarity score': '0.8732195101415544', 'content path': 'local_data/camel_paper.pdf', 'metadata': {'filetype': 'application/pdf', 'languages': ['eng'], 'page_number': 10, 'orig_elements': 'eJx1VMtu5DYQ/JWGzuPJvDxj5xYssMBekgDZm7EwWmJrRJgiGT5mPFjsv6dasmIDyd7EYj+rSnz63oiTUXx5tqb5lZrTvt+Z7WHfbbp9//hwlPZ06h83B+n7rRzMqVlRM0phw4UR/73pQkjGei6Sp7PjW6jleRB7HgqQ0+MOKW/o1ZoyADxuFYzB+qJZT0/bzWl9XNH95mG9+7ai5Xw87Ofz/eZ+vfvveY4H0ORbLjLqBn/aV3F/Re6k+YGL3joptyh6xTE623Gxwf8STd9Mg/lz5fM0/FMj/txotQjk2dexlQR8u5mg9M7Sgfv+eGgP+81x89Cbdnt46Dre7A/70+5xf7+ZOhd5VQKaI30KvnM1oy198VQGmylylLSiq5C8RheSABaKoaCJZUehJ64l+DCGmgkkI3wanHgM/gxkHKuflrkIYVwwSewNxRRiyIDIh4u499QljPrEo1xDeiGPD0MpOLmLUMii7pr+qIlAVArcDSSeWyf5/9uVANw5bgPqy4d53Q13V05G8yL418qF80um6wA9KMnf1SZFR+vtiH2HOrIn+EHSRSkIfkVO2EyZgVopuKEcXNU7rArGsBcFTFuGkEI9Y9oLuzqxlNf0dZhBjWDP7pZtngjPQ7gihwthQysXbfETriFUN7Bz8IVGmSo6jM25ghNnXwTR/iIpz+EGxXieXUml3tkYkbialMECo/4oGok0Y98GVcLfNQl9j3qQL3fslPx3MfoABko1k1Bql4/atjLwxYY0u6DjyK11aIFB4aWxumLvZv3nX+Vft1ysQUwuquFZw7UNG5Mk57dGsNNCg2DgzzUBTCNcu5roxRT+LuOrg52cbROnG7SE57W0VQvoEzMro+NcOFnlejbSivQ1IXwvvEcbxVkvy9WiH9gPLs90qvWkK+ioIVm0DsTJNcaQCiyWhRNYm9j+yc/Syg1CzBJAkpJsW5chIQNNflINrM/6nmV1aJi472up8CCWcZzOQstDAmcW29tOf2K1s3MW/TqhMRhxb+p80O23L4sga32Plqfqd05zwFd9RX58+wcj7AKm'}, 'text': '6 Conclusion In this paper, we explore the potential of autonomous cooperation among communicative agents and propose a novel cooperative agent framework named role-playing . Our approach enables communicative agents to collaborate autonomously toward completing tasks while requiring minimal human intervention, leading to better solutions are per our thorough evaluations. Through our analysis, we show that achieving autonomous cooperation is challenging due to issues like conversation deviation,'}]\n"]}+ ],+ "source": [+ "retrieved_info = vector_retriever.query(\n",+ " query=\"To address the challenges of achieving autonomous cooperation, we propose a novel communicative agent framework named role-playing .\",\n",+ " top_k=1\n",+ ")\n",+ "print(retrieved_info)"]},{"cell_type": "markdown",- "source": [- "Let's try an irrelevant query:"- ],"metadata": {"id": "48G3USMzH6Hd"- }+ },+ "source": [+ "Let's try an irrelevant query:"+ ]},{"cell_type": "code",- "source": [- "retrieved_info_irrevelant = vector_retriever.query(\n",- " query=\"Compared with dumpling and rice, which should I take for dinner?\",\n",- " top_k=1,\n",- ")\n",- "\n",- "print(retrieved_info_irrevelant)"- ],+ "execution_count": 9,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -319,19 +299,29 @@"id": "UNh3tjCOH7d0","outputId": "d0fcb435-8e88-4e21-bd11-800f5efde934"},- "execution_count": 9,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["[{'text': 'No suitable information retrieved from local_data/camel_paper.pdf with similarity_threshold = 0.7.'}]\n"]}+ ],+ "source": [+ "retrieved_info_irrevelant = vector_retriever.query(\n",+ " query=\"Compared with dumpling and rice, which should I take for dinner?\",\n",+ " top_k=1,\n",+ ")\n",+ "\n",+ "print(retrieved_info_irrevelant)"]},{"cell_type": "markdown",+ "metadata": {+ "id": "mHdEsIzSH_AD"+ },"source": ["## 2. Auto RAG\n","In this section we will run the `AutoRetriever` with default settings. It uses `OpenAIEmbedding` as default embedding model and `Milvus` as default vector storage.\n",@@ -342,13 +332,27 @@"- Give a query\n","\n","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."- ],- "metadata": {- "id": "mHdEsIzSH_AD"- }+ ]},{"cell_type": "code",+ "execution_count": 10,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "D_-zAOJ7GjVm",+ "outputId": "ce154f6d-85bd-44df-9b3a-247c71d22029"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "{'Original Query': \"If I'm interest in contributing to the CAMEL projec, what should I do?\", 'Retrieved Context': [{'similarity score': '0.7025470476009851', 'content path': 'https://github.com/camel-ai/camel/wiki/Contributing-Guidlines', 'metadata': {'filetype': 'text/html', 'languages': ['eng'], 'link_texts': ['slack'], 'link_urls': ['https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA'], 'url': 'https://github.com/camel-ai/camel/wiki/Contributing-Guidlines', 'orig_elements': 'eJxNU9tu2zAM/RXOL3uJ4ybOtW9BUQzDugFDBxRbVxS0RMVqbMnQJU5W9N9H2WvXF0sQycNzDun754waasmERy2zS8hIiXKtcLtelZvljOblVlTVSi4289VsTptZNoGspYASA3L+c6Z0Q+HcUSoOdApFHdomZTVo9hH35Dlyn5HZZw/pVZvDow/ouKGRdBrDi+3FWzCBjDW+QXH4XxVdM77XIXT+siierDbTIWkqbFuEQmBLTX7o3aycLQpfoyPJbY46UPEn5LPjeRO3TWXzX9/b+vPufHd7rW77m6tm7ub0ZTe06rjozY01XSzXVC5Lsa7m5UpsK7WcqVJcLOe4XAuVdDKtlPpKaq9DHauB0EgH9Xgpen3QxZU1wekqBm32+aeoJUtjD14mo3sJ6UeN5gBnG0FZl04H2gRy5ANfQLxDgGAh1ARXu6/XN9A5+0QifIDfUW5KwV+12cIdfXQEdBLsgkwFNR5phPWx66wLU9h5QAO2I5N7DgjiRjpoDPqYroDgsGOuZ6CjbY6pMxo5FhCPUYLS1MgJ9AR9bRuqiSdMqaCnhr2gd7St8WAVYNPAgXfAT+GuJlYxaIUeTUgsWbKzMjIVQz0owhDZgQmQYXv4NcnWRjn0wUWRghPQLVvAjKUVMe00pmYTQH9IjLX3MSGglNDawRNsuyY96XSmCuDVDJRblTN+zhqAm7IWUYOWhJzKI1H6BFXc+0Eudp0jwVb985RB6ug1+nawiBQPMbDGYSaSv7QQAD9ZKS/amzssOG0zDFNJGz3MfmSplBY6cePMNhotBlnvEAWKtIivf+E3dG6Y3I+0UC8PfwFbuVpV'}, 'text': \"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 for\"}]}\n"+ ]+ }+ ],"source": ["from camel.retrievers import AutoRetriever\n","from camel.types import StorageType\n",@@ -370,39 +374,39 @@")\n","\n","print(retrieved_info)"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "D_-zAOJ7GjVm",- "outputId": "ce154f6d-85bd-44df-9b3a-247c71d22029"- },- "execution_count": 10,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "{'Original Query': \"If I'm interest in contributing to the CAMEL projec, what should I do?\", 'Retrieved Context': [{'similarity score': '0.7025470476009851', 'content path': 'https://github.com/camel-ai/camel/wiki/Contributing-Guidlines', 'metadata': {'filetype': 'text/html', 'languages': ['eng'], 'link_texts': ['slack'], 'link_urls': ['https://join.slack.com/t/camel-kwr1314/shared_invite/zt-1vy8u9lbo-ZQmhIAyWSEfSwLCl2r2eKA'], 'url': 'https://github.com/camel-ai/camel/wiki/Contributing-Guidlines', 'orig_elements': 'eJxNU9tu2zAM/RXOL3uJ4ybOtW9BUQzDugFDBxRbVxS0RMVqbMnQJU5W9N9H2WvXF0sQycNzDun754waasmERy2zS8hIiXKtcLtelZvljOblVlTVSi4289VsTptZNoGspYASA3L+c6Z0Q+HcUSoOdApFHdomZTVo9hH35Dlyn5HZZw/pVZvDow/ouKGRdBrDi+3FWzCBjDW+QXH4XxVdM77XIXT+siierDbTIWkqbFuEQmBLTX7o3aycLQpfoyPJbY46UPEn5LPjeRO3TWXzX9/b+vPufHd7rW77m6tm7ub0ZTe06rjozY01XSzXVC5Lsa7m5UpsK7WcqVJcLOe4XAuVdDKtlPpKaq9DHauB0EgH9Xgpen3QxZU1wekqBm32+aeoJUtjD14mo3sJ6UeN5gBnG0FZl04H2gRy5ANfQLxDgGAh1ARXu6/XN9A5+0QifIDfUW5KwV+12cIdfXQEdBLsgkwFNR5phPWx66wLU9h5QAO2I5N7DgjiRjpoDPqYroDgsGOuZ6CjbY6pMxo5FhCPUYLS1MgJ9AR9bRuqiSdMqaCnhr2gd7St8WAVYNPAgXfAT+GuJlYxaIUeTUgsWbKzMjIVQz0owhDZgQmQYXv4NcnWRjn0wUWRghPQLVvAjKUVMe00pmYTQH9IjLX3MSGglNDawRNsuyY96XSmCuDVDJRblTN+zhqAm7IWUYOWhJzKI1H6BFXc+0Eudp0jwVb985RB6ug1+nawiBQPMbDGYSaSv7QQAD9ZKS/amzssOG0zDFNJGz3MfmSplBY6cePMNhotBlnvEAWKtIivf+E3dG6Y3I+0UC8PfwFbuVpV'}, 'text': \"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 for\"}]}\n"- ]- }]},{"cell_type": "markdown",+ "metadata": {+ "id": "hMgCWKG4IQYF"+ },"source": ["## 3. Single Agent with Auto RAG\n","In this section we will show how to combine the `AutoRetriever` with one `ChatAgent`.\n","\n","Let's set an agent function, in this function we can get the response by providing a query to this agent."- ],- "metadata": {- "id": "hMgCWKG4IQYF"- }+ ]},{"cell_type": "code",+ "execution_count": 11,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "YTE_mUwGIok-",+ "outputId": "012ae011-a032-4568-c9cc-48b8ec9946db"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "If you're interested in contributing to the CAMEL project, you can introduce new features, enhance the infrastructure, improve documentation, address issues, add more examples, implement state-of-the-art research ideas, or fix bugs. Additionally, you are welcome to join their Slack for further engagement and collaboration.\n"+ ]+ }+ ],"source": ["from camel.agents import ChatAgent\n","from camel.messages import BaseMessage\n",@@ -443,37 +447,25 @@" return assistant_response.msg.content\n","\n","print(single_agent(\"If I'm interest in contributing to the CAMEL projec, what should I do?\"))"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "YTE_mUwGIok-",- "outputId": "012ae011-a032-4568-c9cc-48b8ec9946db"- },- "execution_count": 11,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "If you're interested in contributing to the CAMEL project, you can introduce new features, enhance the infrastructure, improve documentation, address issues, add more examples, implement state-of-the-art research ideas, or fix bugs. Additionally, you are welcome to join their Slack for further engagement and collaboration.\n"- ]- }]},{"cell_type": "markdown",+ "metadata": {+ "id": "Cvh6e3KpI0rf"+ },"source": ["## 4. Role-playing with Auto RAG\n","In this section we will show how to combine the `RETRIEVAL_FUNCS` with `RolePlaying` by applying `Function Calling`.\n"- ],- "metadata": {- "id": "Cvh6e3KpI0rf"- }+ ]},{"cell_type": "code",+ "execution_count": 12,+ "metadata": {+ "id": "z3tX4EJVI1hb"+ },+ "outputs": [],"source": ["from typing import List\n","from colorama import Fore\n",@@ -584,27 +576,20 @@" break\n","\n"," input_msg = assistant_response.msg"- ],- "metadata": {- "id": "z3tX4EJVI1hb"- },- "execution_count": 12,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Run the role-playing with defined retriever function:"- ],"metadata": {"id": "w4-0lswwI5Gb"- }+ },+ "source": [+ "Run the role-playing with defined retriever function:"+ ]},{"cell_type": "code",- "source": [- "role_playing_with_rag(task_prompt = \"\"\"If I'm interest in contributing to the CAMEL projec and I encounter some challenges during the setup process, what should I do? You should refer to the content in url https://github.com/camel-ai/camel/wiki/Contributing-Guidlines to answer my question, don't generate the answer by yourself, adjust the similarity threshold to lower value is necessary\"\"\")"- ],+ "execution_count": 14,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -612,11 +597,10 @@"id": "5agjiXHeI64q","outputId": "8227a0d8-a3e2-41f3-9954-0e3fc8b32e2d"},- "execution_count": 14,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[32mAI Assistant sys message:\n","BaseMessage(role_name='Searcher', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': \"If I'm interest in contributing to the CAMEL projec and I encounter some challenges during the setup process, what should I do? You should refer to the content in url https://github.com/camel-ai/camel/wiki/Contributing-Guidlines to answer my question, don't generate the answer by yourself, adjust the similarity threshold to lower value is necessary\", '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: If I'm interest in contributing to the CAMEL projec and I encounter some challenges during the setup process, what should I do? You should refer to the content in url https://github.com/camel-ai/camel/wiki/Contributing-Guidlines to answer my question, don't generate the answer by yourself, adjust the similarity threshold to lower value is necessary. 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.\", video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n",@@ -726,7 +710,24 @@"\n"]}+ ],+ "source": [+ "role_playing_with_rag(task_prompt = \"\"\"If I'm interest in contributing to the CAMEL projec and I encounter some challenges during the setup process, what should I do? You should refer to the content in url https://github.com/camel-ai/camel/wiki/Contributing-Guidlines to answer my question, don't generate the answer by yourself, adjust the similarity threshold to lower value is necessary\"\"\")"]}- ]-}\ No newline at end of file+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/agents_with_tools.ipynb b/docs/cookbooks/agents_with_tools.ipynbindex 24edcd09b..27eccee0a 100644--- a/docs/cookbooks/agents_with_tools.ipynb+++ b/docs/cookbooks/agents_with_tools.ipynb@@ -1,22 +1,23 @@{"cells": [{+ "attachments": {},"cell_type": "markdown","metadata": {"id": "ssX_map8c6mx"},"source": [- "# 🐫 CAMEL Tools Cookbook"+ "# Tools Cookbook"]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1f1jYwDy6pB8QB6c_UdoBvFx6wr6kA5xq?usp=sharing)"- ],"metadata": {"id": "9S0pePjZkwUz"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1f1jYwDy6pB8QB6c_UdoBvFx6wr6kA5xq?usp=sharing)"+ ]},{"cell_type": "markdown",@@ -321,8 +322,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["[FunctionCallingRecord(func_name='search_wiki', args={'entity': 'University of Oxford'}, result=\"The University of Oxford is a collegiate research university in Oxford, England. There is evidence of teaching as early as 1096, making it the oldest university in the English-speaking world and the world's second-oldest university in continuous operation. It grew rapidly from 1167, when Henry II banned English students from attending the University of Paris. After disputes between students and Oxford townsfolk, some Oxford academics fled northeast to Cambridge, where, in 1209, they established the University of Cambridge. The two English ancient universities share many common features and are jointly referred to as Oxbridge.\")]\n"]@@ -344,8 +345,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["[FunctionCallingRecord(func_name='sub', args={'a': 2024, 'b': 1096}, result=928)]\n"]@@ -391,8 +392,8 @@},"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[32mAI Assistant sys message:\n","BaseMessage(role_name='Searcher', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': 'Assume now is 2024 in the Gregorian calendar, estimate the current age of University of Oxford and then add 10 more years to this age.', '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: Assume now is 2024 in the Gregorian calendar, estimate the current age of University of Oxford and then add 10 more years to this age.. 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.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n",@@ -598,4 +599,4 @@},"nbformat": 4,"nbformat_minor": 0-}\ No newline at end of file+}diff --git a/docs/cookbooks/create_your_first_agents_society.ipynb b/docs/cookbooks/create_your_first_agents_society.ipynbindex 05ed13904..465494d52 100644--- a/docs/cookbooks/create_your_first_agents_society.ipynb+++ b/docs/cookbooks/create_your_first_agents_society.ipynb@@ -1,13 +1,27 @@{+ "nbformat": 4,+ "nbformat_minor": 0,+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "name": "python3",+ "display_name": "Python 3"+ },+ "language_info": {+ "name": "python"+ }+ },"cells": [{"cell_type": "markdown",- "metadata": {- "id": "_nTMiZtBfNJs"- },"source": ["# Creating Your First Agent Society"- ]+ ],+ "metadata": {+ "id": "_nTMiZtBfNJs"+ }},{"cell_type": "markdown",@@ -20,9 +34,6 @@},{"cell_type": "markdown",- "metadata": {- "id": "wFlfaGrjVAUy"- },"source": ["## Philosophical Bits\n","\n",@@ -33,62 +44,75 @@"> -- Marvin Minsky, The Society of Mind, p. 308\n","\n","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:\n",+ "\n","- **Task**: a task can be as simple as an idea, initialized by an inception prompt.\n",+ "\n","- **AI User**: the agent who is expected to provide instructions.\n",+ "\n","- **AI Assistant**: the agent who is expected to respond with solutions that fulfills the instructions."- ]+ ],+ "metadata": {+ "id": "wFlfaGrjVAUy"+ }},{"cell_type": "markdown",- "metadata": {- "id": "VUaGurDIVJBg"- },"source": ["## Quick Start\n","Let's first play with a `ChatAgent` instance by simply initialize it with a system message and interact with user messages."- ]+ ],+ "metadata": {+ "id": "VUaGurDIVJBg"+ }},{"cell_type": "markdown",- "metadata": {- "id": "u9NVFz-HVLXb"- },"source": ["### 🕹 Step 0: Prepartions"- ]+ ],+ "metadata": {+ "id": "u9NVFz-HVLXb"+ }},{"cell_type": "code",- "execution_count": null,+ "source": [+ "!pip install \"camel-ai==0.2.4\""+ ],"metadata": {"id": "RiwfwyyLYYxo"},- "outputs": [],- "source": [- "!pip install \"camel-ai==0.2.4\""- ]+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "MyTTCe3IR_Lr"- },"source": ["### Setting Up API Keys"- ]+ ],+ "metadata": {+ "id": "MyTTCe3IR_Lr"+ }},{"cell_type": "markdown",- "metadata": {- "id": "REqzgGL9SEaD"- },"source": ["You'll need to set up your API keys for OpenAI."- ]+ ],+ "metadata": {+ "id": "REqzgGL9SEaD"+ }},{"cell_type": "code",- "execution_count": 4,+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "openai_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"+ ],"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -96,6 +120,7 @@"id": "PNBFEXc-R-0s","outputId": "421b4396-dd5f-49e6-fe7f-2b6d404e1990"},+ "execution_count": null,"outputs": [{"name": "stdout",@@ -104,23 +129,10 @@"Enter your API key: ··········\n"]}- ],- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "openai_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"OPENAI_API_KEY\"] = openai_api_key"]},{"cell_type": "code",- "execution_count": 5,- "metadata": {- "id": "CmgKGeCxVON-"- },- "outputs": [],"source": ["# Import necessary classes\n","from camel.societies import RolePlaying\n",@@ -133,131 +145,131 @@" model_type=ModelType.GPT_4O_MINI,\n"," model_config_dict=ChatGPTConfig(temperature=0.0).as_dict(), # [Optional] the config for model\n",")"- ]+ ],+ "metadata": {+ "id": "CmgKGeCxVON-"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "Lef5LTRdVSsm"- },"source": ["### 🕹 Step 1: Configure the Role-Playing Session\n"- ]+ ],+ "metadata": {+ "id": "Lef5LTRdVSsm"+ }},{"cell_type": "markdown",- "metadata": {- "id": "WXibf_JkYdn0"- },"source": ["#### Set the `Task` Arguments"- ]+ ],+ "metadata": {+ "id": "WXibf_JkYdn0"+ }},{"cell_type": "code",- "execution_count": 6,- "metadata": {- "id": "aX9wCqeTVXDh"- },- "outputs": [],"source": ["task_kwargs = {\n"," 'task_prompt': 'Develop a plan to TRAVEL TO THE PAST and make changes.',\n"," 'with_task_specify': True,\n"," 'task_specify_agent_kwargs': {'model': model}\n","}"- ]+ ],+ "metadata": {+ "id": "aX9wCqeTVXDh"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "tXx13MmbYgFh"- },"source": ["#### Set the `User` Arguments\n","You may think the user as the `instruction sender`."- ]+ ],+ "metadata": {+ "id": "tXx13MmbYgFh"+ }},{"cell_type": "code",- "execution_count": 7,- "metadata": {- "id": "be-97ApoVdDf"- },- "outputs": [],"source": ["user_role_kwargs = {\n"," 'user_role_name': 'an ambitious aspiring TIME TRAVELER',\n"," 'user_agent_kwargs': {'model': model}\n","}"- ]+ ],+ "metadata": {+ "id": "be-97ApoVdDf"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "zLJzupaMYm11"- },"source": ["#### Set the `Assistant` Arguments\n","Again, you may think the assistant as the `instruction executor`."- ]+ ],+ "metadata": {+ "id": "zLJzupaMYm11"+ }},{"cell_type": "code",- "execution_count": 8,- "metadata": {- "id": "rfzyC54hYtVu"- },- "outputs": [],"source": ["assistant_role_kwargs = {\n"," 'assistant_role_name': 'the best-ever experimental physicist',\n"," 'assistant_agent_kwargs': {'model': model}\n","}"- ]+ ],+ "metadata": {+ "id": "rfzyC54hYtVu"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "j90-Y5ChV-iX"- },"source": ["### Step 2: Kickstart Your Society\n","Putting them altogether – your role-playing session is ready to go!"- ]+ ],+ "metadata": {+ "id": "j90-Y5ChV-iX"+ }},{"cell_type": "code",- "execution_count": 9,- "metadata": {- "id": "yDiLpZ7CY1N_"- },- "outputs": [],"source": ["society = RolePlaying(\n"," **task_kwargs, # The task arguments\n"," **user_role_kwargs, # The instruction sender's arguments\n"," **assistant_role_kwargs, # The instruction receiver's arguments\n",")"- ]+ ],+ "metadata": {+ "id": "yDiLpZ7CY1N_"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "kklmZh0iY6pY"- },"source": ["### Step 3: Solving Tasks with Your Society\n","Hold your bytes. Prior to our travel, let's define a small helper function."- ]+ ],+ "metadata": {+ "id": "kklmZh0iY6pY"+ }},{"cell_type": "code",- "execution_count": 10,- "metadata": {- "id": "VI6d62uVY6IZ"- },- "outputs": [],"source": ["def is_terminated(response):\n"," \"\"\"\n",@@ -269,24 +281,24 @@" print(f'AI {role} terminated due to {reason}')\n","\n"," return response.terminated"- ]+ ],+ "metadata": {+ "id": "VI6d62uVY6IZ"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "markdown",- "metadata": {- "id": "tTUlFZjVZCsz"- },"source": ["Time to chart our course – writing a simple loop for our society to proceed:"- ]+ ],+ "metadata": {+ "id": "tTUlFZjVZCsz"+ }},{"cell_type": "code",- "execution_count": 17,- "metadata": {- "id": "Bq8AiGEXZC9P"- },- "outputs": [],"source": ["def run(society, round_limit: int=10):\n","\n",@@ -316,22 +328,30 @@" input_msg = assistant_response.msg\n","\n"," return None"- ]+ ],+ "metadata": {+ "id": "Bq8AiGEXZC9P"+ },+ "execution_count": null,+ "outputs": []},{"cell_type": "code",- "execution_count": 18,+ "source": [+ "run(society)"+ ],"metadata": {+ "id": "DoJ2ZaWyZE57","colab": {"base_uri": "https://localhost:8080/"},- "id": "DoJ2ZaWyZE57","outputId": "55d8d45b-2a97-44b9-c819-30af254cb426"},+ "execution_count": null,"outputs": [{- "name": "stdout","output_type": "stream",+ "name": "stdout","text": ["[AI User] Instruction: Research the principles of quantum entanglement and wormhole theory to understand their potential applications in time travel. \n","Input: None.\n",@@ -699,24 +719,7 @@"\n"]}- ],- "source": [- "run(society)"]}- ],- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "display_name": "Python 3",- "name": "python3"- },- "language_info": {- "name": "python"- }- },- "nbformat": 4,- "nbformat_minor": 0-}+ ]+}\ No newline at end of filediff --git a/docs/cookbooks/knowledge_graph.ipynb b/docs/cookbooks/knowledge_graph.ipynbindex 70e485cd3..718cf890c 100644--- a/docs/cookbooks/knowledge_graph.ipynb+++ b/docs/cookbooks/knowledge_graph.ipynb@@ -1,81 +1,68 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 Using CAMEL to Do Graph RAG with Mistral Models"- ],"metadata": {"id": "DJeeABnkOsPK"- }+ },+ "source": [+ "# Graph RAG Cookbook"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1uZKQSuu0qW6ukkuSv9TukLB9bVaS1H0U?usp=sharing)"- ],"metadata": {"id": "9fHzgxYpmz2q"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1uZKQSuu0qW6ukkuSv9TukLB9bVaS1H0U?usp=sharing)"+ ]},{"cell_type": "markdown",- "source": [- "This cookbook walks you through the process of performing graph-based Retrieval-Augmented Generation (RAG) using **CAMEL**, powered by the advanced **Mistral** models. Specifically, we'll utilize the **Mistral Large 2** model to extract and structure knowledge from a given content source, and store this information in a **Neo4j** graph database. Subsequently, we can leverage a hybrid approach, combining vector retrieval and knowledge graph retrieval, to query and explore the stored knowledge."- ],"metadata": {"id": "l4VANToobUzu"- }+ },+ "source": [+ "This cookbook walks you through the process of performing graph-based Retrieval-Augmented Generation (RAG) using **CAMEL**, powered by the advanced **Mistral** models. Specifically, we'll utilize the **Mistral Large 2** model to extract and structure knowledge from a given content source, and store this information in a **Neo4j** graph database. Subsequently, we can leverage a hybrid approach, combining vector retrieval and knowledge graph retrieval, to query and explore the stored knowledge."+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "slaeSyWkbIzc"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "X5mWln9dCDzE"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- "## 📦 Installation"- ],"metadata": {"id": "8SV7XmyKbwdc"- }+ },+ "source": [+ "## 📦 Installation"+ ]},{"cell_type": "markdown",- "source": [- "First, install the CAMEL package with all its dependencies:"- ],"metadata": {"id": "-qAA1j0Sb2Ve"- }+ },+ "source": [+ "First, install the CAMEL package with all its dependencies:"+ ]},{"cell_type": "code",@@ -91,24 +78,29 @@},{"cell_type": "markdown",- "source": [- "## 🔧 Setup"- ],"metadata": {"id": "X5SDX1kPb6bz"- }+ },+ "source": [+ "## 🔧 Setup"+ ]},{"cell_type": "markdown",- "source": [- "Import the required modules from CAMEL-AI:"- ],"metadata": {"id": "StvpXTi7b7pF"- }+ },+ "source": [+ "Import the required modules from CAMEL-AI:"+ ]},{"cell_type": "code",+ "execution_count": 2,+ "metadata": {+ "id": "7PcVsBYvzfSI"+ },+ "outputs": [],"source": ["from camel.models import ModelFactory\n","from camel.types import ModelPlatformType, ModelType\n",@@ -120,41 +112,29 @@"from camel.types import StorageType\n","from camel.agents import ChatAgent, KnowledgeGraphAgent\n","from camel.messages import BaseMessage"- ],- "metadata": {- "id": "7PcVsBYvzfSI"- },- "execution_count": 2,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "## 🔑 Setting Up API Keys\n"- ],"metadata": {"id": "DahHkqSOb-T3"- }+ },+ "source": [+ "## 🔑 Setting Up API Keys\n"+ ]},{"cell_type": "markdown",- "source": [- "For secure access to Mistral AI's services, we'll prompt for the API key."- ],"metadata": {"id": "odHOpz0XcAjA"- }+ },+ "source": [+ "For secure access to Mistral AI's services, we'll prompt for the API key."+ ]},{"cell_type": "code",- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the API key securely\n",- "mistral_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"MISTRAL_API_KEY\"] = mistral_api_key"- ],+ "execution_count": 3,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -162,7 +142,6 @@"id": "B0v7xEFFoabv","outputId": "7cf90833-d7ab-49a0-fda9-46c99af7ccc6"},- "execution_count": 3,"outputs": [{"name": "stdout",@@ -171,28 +150,41 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the API key securely\n",+ "mistral_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"MISTRAL_API_KEY\"] = mistral_api_key"]},{"cell_type": "markdown",- "source": [- "## 🗄️ Configuring Neo4j Graph Database"- ],"metadata": {"id": "bPPZx6WwcDzG"- }+ },+ "source": [+ "## 🗄️ Configuring Neo4j Graph Database"+ ]},{"cell_type": "markdown",- "source": [- "Set up your Neo4j instance by providing the URL, username, and password, [here](https://neo4j.com/docs/aura/auradb/getting-started/create-database/) is the guidance, check your credentials in the downloaded .txt file. Note that you may need to wait up to 60 seconds if the instance has just been set up."- ],"metadata": {"id": "m4pJ-V2FcG6o"- }+ },+ "source": [+ "Set up your Neo4j instance by providing the URL, username, and password, [here](https://neo4j.com/docs/aura/auradb/getting-started/create-database/) is the guidance, check your credentials in the downloaded .txt file. Note that you may need to wait up to 60 seconds if the instance has just been set up."+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "id": "iH7NuLvq3p2o"+ },+ "outputs": [],"source": ["# Set Neo4j instance\n","n4j = Neo4jGraph(\n",@@ -200,33 +192,33 @@" username=\"Your_USERNAME\",\n"," password=\"Your_PASSWORD\",\n",")"- ],- "metadata": {- "id": "iH7NuLvq3p2o"- },- "execution_count": 4,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "## 🧠 Creating the Model"- ],"metadata": {"id": "vmzruZl1cJQD"- }+ },+ "source": [+ "## 🧠 Creating the Model"+ ]},{"cell_type": "markdown",- "source": [- "Set up Mistral Large 2 model using the CAMEL ModelFactory:"- ],"metadata": {"id": "flTRxefgcOxp"- }+ },+ "source": [+ "Set up Mistral Large 2 model using the CAMEL ModelFactory:"+ ]},{"cell_type": "code",+ "execution_count": 5,+ "metadata": {+ "id": "PDhfqzA2zYmm"+ },+ "outputs": [],"source": ["# Set up model\n","mistral_large_2 = ModelFactory.create(\n",@@ -234,15 +226,15 @@" model_type=ModelType.MISTRAL_LARGE,\n"," model_config_dict=MistralConfig(temperature=0.2).as_dict(),\n",")"- ],- "metadata": {- "id": "PDhfqzA2zYmm"- },- "execution_count": 5,- "outputs": []+ ]},{"cell_type": "code",+ "execution_count": null,+ "metadata": {+ "id": "PPyHfsGyraJf"+ },+ "outputs": [],"source": ["# You can also set up model locally by using ollama\n","mistral_large_2_local = ModelFactory.create(\n",@@ -250,55 +242,55 @@" model_type=\"mistral-large\",\n"," model_config_dict=OllamaConfig(temperature=0.2).as_dict(),\n",")"- ],- "metadata": {- "id": "PPyHfsGyraJf"- },- "execution_count": null,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "## 🤖 Generate a Knowledge Graph Using CAMEL's Agent"- ],"metadata": {"id": "61PwBl9XcWJ_"- }+ },+ "source": [+ "## 🤖 Generate a Knowledge Graph Using CAMEL's Agent"+ ]},{"cell_type": "markdown",- "source": [- "Set up instances for knowledge graph agent:"- ],"metadata": {"id": "nFl_Paah4OdP"- }+ },+ "source": [+ "Set up instances for knowledge graph agent:"+ ]},{"cell_type": "code",+ "execution_count": 7,+ "metadata": {+ "id": "LkUn3Ph0S1Z0"+ },+ "outputs": [],"source": ["# Set instance\n","uio = UnstructuredIO()\n","kg_agent = KnowledgeGraphAgent(model=mistral_large_2)"- ],- "metadata": {- "id": "LkUn3Ph0S1Z0"- },- "execution_count": 7,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Provide an example text input that the knowledge graph agent will process:"- ],"metadata": {"id": "L7EUMC-nck0d"- }+ },+ "source": [+ "Provide an example text input that the knowledge graph agent will process:"+ ]},{"cell_type": "code",+ "execution_count": 8,+ "metadata": {+ "id": "syY548PW4d2t"+ },+ "outputs": [],"source": ["# Set example text input\n","text_example = \"\"\"\n",@@ -307,55 +299,45 @@"of extracting entities and relationships from given content and create knowledge\n","graphs automaticlly.\n","\"\"\""- ],- "metadata": {- "id": "syY548PW4d2t"- },- "execution_count": 8,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Create an element from the text and use the knowledge graph agent to extract node and relationship information:"- ],"metadata": {"id": "bKSxhv0ucof9"- }+ },+ "source": [+ "Create an element from the text and use the knowledge graph agent to extract node and relationship information:"+ ]},{"cell_type": "code",+ "execution_count": 9,+ "metadata": {+ "id": "cDB_iDCl4h6F"+ },+ "outputs": [],"source": ["# Create an element from given text\n","element_example = uio.create_element_from_text(\n"," text=text_example, element_id=\"0\"\n",")"- ],- "metadata": {- "id": "cDB_iDCl4h6F"- },- "execution_count": 9,- "outputs": []+ ]},{"cell_type": "code",- "source": [- "# Let Knowledge Graph Agent extract node and relationship information\n",- "ans_element = kg_agent.run(element_example, parse_graph_elements=False)\n",- "print(ans_element)"- ],+ "execution_count": 10,"metadata": {- "id": "WlmeLofo4kDE","colab": {"base_uri": "https://localhost:8080/"},+ "id": "WlmeLofo4kDE","outputId": "1543028f-58cd-417c-b9f1-ee28b5ebdcd7"},- "execution_count": 10,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Sure, let's go through the process of extracting nodes and relationships from the given content and structuring them into Node and Relationship objects.\n","\n",@@ -418,92 +400,102 @@"This structured output captures the entities and their relationships as described in the content. Each node has a unique identifier and a type, and each relationship specifies the subject, object, and type of the relationship.\n"]}+ ],+ "source": [+ "# Let Knowledge Graph Agent extract node and relationship information\n",+ "ans_element = kg_agent.run(element_example, parse_graph_elements=False)\n",+ "print(ans_element)"]},{"cell_type": "code",- "source": [- "# Check graph element\n",- "graph_elements = kg_agent.run(element_example, parse_graph_elements=True)\n",- "print(graph_elements)"- ],+ "execution_count": 11,"metadata": {- "id": "J0JzGaFN4pRh","colab": {"base_uri": "https://localhost:8080/"},+ "id": "J0JzGaFN4pRh","outputId": "6e957343-1388-4e1b-eefa-8cdaa117eff4"},- "execution_count": 11,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["nodes=[Node(id='CAMEL', type='Organization', properties={'source': 'agent_created'}), Node(id='knowledge graph agent', type='Software', properties={'source': 'agent_created'}), Node(id='Mistral AI', type='Organization', properties={'source': 'agent_created'}), Node(id='Mistral Large 2', type='Model', properties={'source': 'agent_created'}), Node(id='entities and relationships', type='Concept', properties={'source': 'agent_created'}), Node(id='knowledge graphs', type='Concept', properties={'source': 'agent_created'})] relationships=[Relationship(subj=Node(id='CAMEL', type='Organization', properties={'source': 'agent_created'}), obj=Node(id='knowledge graph agent', type='Software', properties={'source': 'agent_created'}), type='Developed', properties={'source': 'agent_created'}), Relationship(subj=Node(id='knowledge graph agent', type='Software', properties={'source': 'agent_created'}), obj=Node(id='Mistral AI', type='Organization', properties={'source': 'agent_created'}), type='CanRunWith', properties={'source': 'agent_created'}), Relationship(subj=Node(id='Mistral AI', type='Organization', properties={'source': 'agent_created'}), obj=Node(id='Mistral Large 2', type='Model', properties={'source': 'agent_created'}), type='HasModel', properties={'source': 'agent_created'}), Relationship(subj=Node(id='knowledge graph agent', type='Software', properties={'source': 'agent_created'}), obj=Node(id='entities and relationships', type='Concept', properties={'source': 'agent_created'}), type='CanExtract', properties={'source': 'agent_created'}), Relationship(subj=Node(id='knowledge graph agent', type='Software', properties={'source': 'agent_created'}), obj=Node(id='knowledge graphs', type='Concept', properties={'source': 'agent_created'}), type='CanCreate', properties={'source': 'agent_created'})] source=<unstructured.documents.elements.Text object at 0x785a8686f6a0>\n"]}+ ],+ "source": [+ "# Check graph element\n",+ "graph_elements = kg_agent.run(element_example, parse_graph_elements=True)\n",+ "print(graph_elements)"]},{"cell_type": "markdown",- "source": [- "Add the extracted graph elements to the Neo4j database:"- ],"metadata": {"id": "sqEfkLI-c23g"- }+ },+ "source": [+ "Add the extracted graph elements to the Neo4j database:"+ ]},{"cell_type": "code",- "source": [- "# Add the element to neo4j database\n",- "n4j.add_graph_elements(graph_elements=[graph_elements])"- ],+ "execution_count": 12,"metadata": {"id": "89ZF99QSAaGJ"},- "execution_count": 12,- "outputs": []+ "outputs": [],+ "source": [+ "# Add the element to neo4j database\n",+ "n4j.add_graph_elements(graph_elements=[graph_elements])"+ ]},{"cell_type": "markdown",- "source": [- "### 🎉 Now you can go to [here](https://workspace-preview.neo4j.io/connection/connect) to check the knowledge graph built with CAMEL's Knowledge Graph Agent and Mistral AI's Mistral Large 2 model!"- ],"metadata": {"id": "B6C8wSo6x27Z"- }+ },+ "source": [+ "### 🎉 Now you can go to [here](https://workspace-preview.neo4j.io/connection/connect) to check the knowledge graph built with CAMEL's Knowledge Graph Agent and Mistral AI's Mistral Large 2 model!"+ ]},{"cell_type": "markdown",- "source": [- "## 🗃️ Running Graph RAG with CAMEL"- ],"metadata": {"id": "LckRFGpN6Za4"- }+ },+ "source": [+ "## 🗃️ Running Graph RAG with CAMEL"+ ]},{"cell_type": "markdown",- "source": [- "*Next we will showcase how to run RAG in a hybrid approach, combining vector retrieval and knowledge graph retrieval, to query and explore the stored knowledge.*"- ],"metadata": {"id": "vh4jrhPSyaZw"- }+ },+ "source": [+ "*Next we will showcase how to run RAG in a hybrid approach, combining vector retrieval and knowledge graph retrieval, to query and explore the stored knowledge.*"+ ]},{"cell_type": "markdown",- "source": [- "Set up a vector retriever with local storage and embedding model from Mistral AI:"- ],"metadata": {"id": "A_MiPGmOeDN3"- }+ },+ "source": [+ "Set up a vector retriever with local storage and embedding model from Mistral AI:"+ ]},{"cell_type": "code",+ "execution_count": 13,+ "metadata": {+ "id": "AwpMPpvtr6O7"+ },+ "outputs": [],"source": ["# Set retriever\n","camel_retriever = AutoRetriever(\n",@@ -511,84 +503,84 @@" storage_type=StorageType.QDRANT,\n"," embedding_model=MistralEmbedding(),\n",")"- ],- "metadata": {- "id": "AwpMPpvtr6O7"- },- "execution_count": 13,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Provide an example user query:"- ],"metadata": {"id": "BpAPOf7VeFjx"- }+ },+ "source": [+ "Provide an example user query:"+ ]},{"cell_type": "code",- "source": [- "# Set one user query\n",- "query=\"what's the relationship between Mistral Large 2 and Mistral AI? What kind of feature does Mistral Large 2 has?\""- ],+ "execution_count": 14,"metadata": {"id": "PTZ-8nX359bb"},- "execution_count": 14,- "outputs": []+ "outputs": [],+ "source": [+ "# Set one user query\n",+ "query=\"what's the relationship between Mistral Large 2 and Mistral AI? What kind of feature does Mistral Large 2 has?\""+ ]},{"cell_type": "markdown",- "source": [- "Retrieve related content using the vector retriever, here we take Mistral AI's news in the website as example conetent, you can also set the local file path here:"- ],"metadata": {"id": "Yq6kGaEJeI53"- }+ },+ "source": [+ "Retrieve related content using the vector retriever, here we take Mistral AI's news in the website as example conetent, you can also set the local file path here:"+ ]},{"cell_type": "code",- "source": [- "# Get related content by using vector retriever\n",- "vector_result = camel_retriever.run_vector_retriever(\n",- " query=query,\n",- " contents=\"https://mistral.ai/news/mistral-large-2407/\",\n",- ")\n",- "\n",- "# Show the result from vector search\n",- "print(vector_result)"- ],+ "execution_count": 15,"metadata": {- "id": "hLQGgp4DJAlu","colab": {"base_uri": "https://localhost:8080/"},+ "id": "hLQGgp4DJAlu","outputId": "03b8fa1a-ddcd-45ae-f3e7-6c06121504e0"},- "execution_count": 15,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["{'Original Query': \"what's the relationship between Mistral Large 2 and Mistral AI? What kind of feature does Mistral Large 2 has?\", 'Retrieved Context': ['Large Enough\\n\\nToday, we are announcing Mistral Large 2, the new generation of our flagship model. Compared to its predecessor, Mistral Large 2 is significantly more capable in code generation, mathematics, and reasoning. It also provides a much stronger multilingual support, and advanced function calling capabilities.\\n\\nJuly 24, 2024\\n\\nMistral AI team']}\n"]}+ ],+ "source": [+ "# Get related content by using vector retriever\n",+ "vector_result = camel_retriever.run_vector_retriever(\n",+ " query=query,\n",+ " contents=\"https://mistral.ai/news/mistral-large-2407/\",\n",+ ")\n",+ "\n",+ "# Show the result from vector search\n",+ "print(vector_result)"]},{"cell_type": "markdown",- "source": [- "Parse content from the specified URL and create knowledge graph data:"- ],"metadata": {"id": "w188PLzteMkw"- }+ },+ "source": [+ "Parse content from the specified URL and create knowledge graph data:"+ ]},{"cell_type": "code",+ "execution_count": 16,+ "metadata": {+ "id": "DyuusYoo5-Vw"+ },+ "outputs": [],"source": ["# Parse conetent from mistral website and create knowledge graph data by using\n","# the Knowledge Graph Agent, store the information into graph database.\n",@@ -605,24 +597,24 @@" graph_element = kg_agent.run(chunk, parse_graph_elements=True)\n"," n4j.add_graph_elements(graph_elements=[graph_element])\n"," graph_elements.append(graph_element)"- ],- "metadata": {- "id": "DyuusYoo5-Vw"- },- "execution_count": 16,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Create an element from the user query:"- ],"metadata": {"id": "1UgtR5UWeSD0"- }+ },+ "source": [+ "Create an element from the user query:"+ ]},{"cell_type": "code",+ "execution_count": 17,+ "metadata": {+ "id": "ZDYCLClxeT68"+ },+ "outputs": [],"source": ["# Create an element from user query\n","query_element = uio.create_element_from_text(\n",@@ -631,24 +623,36 @@"\n","# Let Knowledge Graph Agent extract node and relationship information from the qyery\n","ans_element = kg_agent.run(query_element, parse_graph_elements=True)"- ],- "metadata": {- "id": "ZDYCLClxeT68"- },- "execution_count": 17,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Match entities from the query in the knowledge graph storage content:"- ],"metadata": {"id": "zD9hH7QAeVNT"- }+ },+ "source": [+ "Match entities from the query in the knowledge graph storage content:"+ ]},{"cell_type": "code",+ "execution_count": 18,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "ttL5pnye66Wl",+ "outputId": "d7714d35-ca22-4cc9-ab4a-92b67fbc1ecf"+ },+ "outputs": [+ {+ "name": "stdout",+ "output_type": "stream",+ "text": [+ "['Node Mistral Large 2 (label: Model) has relationship SUCCESSOROF with Node Mistral Large (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship ANNOUNCEDBY with Node Mistral AI team (label: Organization)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node code generation (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node mathematics (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node reasoning (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node Instruction-following capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node Conversational capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship PROVIDES with Node multilingual support (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship PROVIDES with Node advanced function calling capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship ANNOUNCEDON with Node July 24, 2024 (label: Date)', 'Node Mistral Large 2 (label: Model) has relationship HASFEATURE with Node 128k context window (label: Feature)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node French (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node German (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Spanish (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Italian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Portuguese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Arabic (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Hindi (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Russian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Chinese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Japanese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Korean (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Python (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Java (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node C (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node C++ (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node JavaScript (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Bash (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship DESIGNEDFOR with Node Single-node inference (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship DESIGNEDFOR with Node Long-context applications (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship HAS with Node 123 billion parameters (label: Attribute)', 'Node Mistral Large 2 (label: Model) has relationship ALLOWS with Node Large throughput (label: Attribute)', 'Node Mistral Large 2 (label: Model) has relationship RELEASEDUNDER with Node Mistral Research License (label: License)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERIN with Node Performance (label: Metric)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERIN with Node Cost of serving (label: Metric)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERON with Node Evaluation metrics (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship SETSNEWPOINTON with Node Performance/cost Pareto front (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship RELATEDTO with Node Open models (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISBETTERAT with Node Precise instructions (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISBETTERAT with Node Long multi-turn conversations (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node MT-Bench (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node Wild Bench (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node Arena Hard benchmarks (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node General alignment benchmarks (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship TRAINEDON with Node Multilingual Data (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node French (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node German (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Spanish (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Italian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Portuguese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Arabic (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Hindi (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Russian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Chinese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Japanese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Korean (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node English (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Dutch (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship HASPERFORMANCERESULTSON with Node MMLU Benchmark (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship COMPAREDTO with Node Mistral Large (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship COMPAREDTO with Node Llama (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship EQUIPPEDWITH with Node enhanced function calling and retrieval skills (label: Skill)', 'Node Mistral Large 2 (label: Model) has relationship TRAINEDTOEXECUTE with Node parallel and sequential function calls (label: Functionality)', 'Node Mistral Large 2 (label: Model) has relationship SERVESASPOWERENGINE with Node complex business applications (label: Application)', 'Node Mistral Large 2 (label: Technology) has relationship EXPOSEDON with Node la Plateforme (label: Platform)', 'Node Mistral Large 2 (label: Technology) has relationship ENRICHEDWITH with Node new features (label: Feature)', 'Node Mistral AI (label: Organization) has relationship PROVIDES with Node Mistral Large 2 (label: Model)', 'Node Mistral AI (label: Organization) has relationship HAS with Node Legal notice (label: Document)', 'Node Mistral AI (label: Organization) has relationship PARTNERSWITH with Node Google Cloud Platform (label: Cloud Service Provider)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Vertex AI (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Azure AI Studio (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Amazon Bedrock (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node IBM watsonx.ai (label: Platform)']\n"+ ]+ }+ ],"source": ["# Match the enetity got from query in the knowledge graph storage content\n","kg_result = []\n",@@ -667,96 +671,52 @@"\n","# Show the result from knowledge graph database\n","print(kg_result)"- ],- "metadata": {- "id": "ttL5pnye66Wl",- "colab": {- "base_uri": "https://localhost:8080/"- },- "outputId": "d7714d35-ca22-4cc9-ab4a-92b67fbc1ecf"- },- "execution_count": 18,- "outputs": [- {- "output_type": "stream",- "name": "stdout",- "text": [- "['Node Mistral Large 2 (label: Model) has relationship SUCCESSOROF with Node Mistral Large (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship ANNOUNCEDBY with Node Mistral AI team (label: Organization)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node code generation (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node mathematics (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node reasoning (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node Instruction-following capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship HASCAPABILITY with Node Conversational capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship PROVIDES with Node multilingual support (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship PROVIDES with Node advanced function calling capabilities (label: Capability)', 'Node Mistral Large 2 (label: Model) has relationship ANNOUNCEDON with Node July 24, 2024 (label: Date)', 'Node Mistral Large 2 (label: Model) has relationship HASFEATURE with Node 128k context window (label: Feature)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node French (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node German (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Spanish (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Italian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Portuguese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Arabic (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Hindi (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Russian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Chinese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Japanese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSLANGUAGE with Node Korean (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Python (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Java (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node C (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node C++ (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node JavaScript (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship SUPPORTSCODINGLANGUAGE with Node Bash (label: CodingLanguage)', 'Node Mistral Large 2 (label: Model) has relationship DESIGNEDFOR with Node Single-node inference (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship DESIGNEDFOR with Node Long-context applications (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship HAS with Node 123 billion parameters (label: Attribute)', 'Node Mistral Large 2 (label: Model) has relationship ALLOWS with Node Large throughput (label: Attribute)', 'Node Mistral Large 2 (label: Model) has relationship RELEASEDUNDER with Node Mistral Research License (label: License)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERIN with Node Performance (label: Metric)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERIN with Node Cost of serving (label: Metric)', 'Node Mistral Large 2 (label: Model) has relationship SETSFRONTIERON with Node Evaluation metrics (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship SETSNEWPOINTON with Node Performance/cost Pareto front (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship RELATEDTO with Node Open models (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISBETTERAT with Node Precise instructions (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISBETTERAT with Node Long multi-turn conversations (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node MT-Bench (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node Wild Bench (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node Arena Hard benchmarks (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship ISEVALUATEDON with Node General alignment benchmarks (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship TRAINEDON with Node Multilingual Data (label: Concept)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node French (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node German (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Spanish (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Italian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Portuguese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Arabic (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Hindi (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Russian (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Chinese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Japanese (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Korean (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node English (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship EXCELSIN with Node Dutch (label: Language)', 'Node Mistral Large 2 (label: Model) has relationship HASPERFORMANCERESULTSON with Node MMLU Benchmark (label: Benchmark)', 'Node Mistral Large 2 (label: Model) has relationship COMPAREDTO with Node Mistral Large (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship COMPAREDTO with Node Llama (label: Model)', 'Node Mistral Large 2 (label: Model) has relationship EQUIPPEDWITH with Node enhanced function calling and retrieval skills (label: Skill)', 'Node Mistral Large 2 (label: Model) has relationship TRAINEDTOEXECUTE with Node parallel and sequential function calls (label: Functionality)', 'Node Mistral Large 2 (label: Model) has relationship SERVESASPOWERENGINE with Node complex business applications (label: Application)', 'Node Mistral Large 2 (label: Technology) has relationship EXPOSEDON with Node la Plateforme (label: Platform)', 'Node Mistral Large 2 (label: Technology) has relationship ENRICHEDWITH with Node new features (label: Feature)', 'Node Mistral AI (label: Organization) has relationship PROVIDES with Node Mistral Large 2 (label: Model)', 'Node Mistral AI (label: Organization) has relationship HAS with Node Legal notice (label: Document)', 'Node Mistral AI (label: Organization) has relationship PARTNERSWITH with Node Google Cloud Platform (label: Cloud Service Provider)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Vertex AI (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Azure AI Studio (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node Amazon Bedrock (label: Platform)', 'Node Mistral AI (label: Organization) has relationship PROVIDESMODELSON with Node IBM watsonx.ai (label: Platform)']\n"- ]- }]},{"cell_type": "markdown",- "source": [- "Combine results from the vector search and knowledge graph entity search:"- ],"metadata": {"id": "sjKr29w8eZ4n"- }+ },+ "source": [+ "Combine results from the vector search and knowledge graph entity search:"+ ]},{"cell_type": "code",- "source": [- "# combine result from vector seach and knowledge graph entity search\n",- "comined_results = str(vector_result) + \"\\n\".join(kg_result)"- ],+ "execution_count": 19,"metadata": {"id": "P9ne7UoB6GY5"},- "execution_count": 19,- "outputs": []+ "outputs": [],+ "source": [+ "# combine result from vector seach and knowledge graph entity search\n",+ "comined_results = str(vector_result) + \"\\n\".join(kg_result)"+ ]},{"cell_type": "markdown",- "source": [- "Set up an assistant agent to answer questions based on the retrieved context:"- ],"metadata": {"id": "q-NaDHypebKZ"- }+ },+ "source": [+ "Set up an assistant agent to answer questions based on the retrieved context:"+ ]},{"cell_type": "code",- "source": [- "# Set agent\n",- "sys_msg = BaseMessage.make_assistant_message(\n",- " role_name=\"CAMEL Agent\",\n",- " content=\"\"\"You are a helpful assistant to answer question,\n",- " I will give you the Original Query and Retrieved Context,\n",- " answer the Original Query based on the Retrieved Context.\"\"\",\n",- ")\n",- "\n",- "camel_agent = ChatAgent(system_message=sys_msg,\n",- " model=mistral_large_2)\n",- "\n",- "# Pass the retrieved infomation to agent\n",- "user_prompt=f\"\"\"\n",- "The Original Query is {query}\n",- "The Retrieved Context is {comined_results}\n",- "\"\"\"\n",- "\n",- "user_msg = BaseMessage.make_user_message(\n",- " role_name=\"CAMEL User\", content=user_prompt\n",- ")\n",- "\n",- "# Get response\n",- "agent_response = camel_agent.step(user_msg)\n",- "\n",- "print(agent_response.msg.content)"- ],+ "execution_count": 20,"metadata": {- "id": "LxEUi36F7kq1","colab": {"base_uri": "https://localhost:8080/"},+ "id": "LxEUi36F7kq1","outputId": "1387ff6d-52f3-4f23-d1b7-4a66b0806264"},- "execution_count": 20,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Mistral Large 2 is a model developed and provided by Mistral AI. It is the successor to the original Mistral Large model. Mistral Large 2 has several notable features and capabilities, including:\n","\n",@@ -810,19 +770,49 @@"Mistral AI, the organization, provides Mistral Large 2 and partners with various cloud service providers like Google Cloud Platform, Vertex AI, Azure AI Studio, Amazon Bedrock, and IBM watsonx.ai to offer their models.\n"]}+ ],+ "source": [+ "# Set agent\n",+ "sys_msg = BaseMessage.make_assistant_message(\n",+ " role_name=\"CAMEL Agent\",\n",+ " content=\"\"\"You are a helpful assistant to answer question,\n",+ " I will give you the Original Query and Retrieved Context,\n",+ " answer the Original Query based on the Retrieved Context.\"\"\",\n",+ ")\n",+ "\n",+ "camel_agent = ChatAgent(system_message=sys_msg,\n",+ " model=mistral_large_2)\n",+ "\n",+ "# Pass the retrieved infomation to agent\n",+ "user_prompt=f\"\"\"\n",+ "The Original Query is {query}\n",+ "The Retrieved Context is {comined_results}\n",+ "\"\"\"\n",+ "\n",+ "user_msg = BaseMessage.make_user_message(\n",+ " role_name=\"CAMEL User\", content=user_prompt\n",+ ")\n",+ "\n",+ "# Get response\n",+ "agent_response = camel_agent.step(user_msg)\n",+ "\n",+ "print(agent_response.msg.content)"]},{"cell_type": "markdown",- "source": [- "## 🌟 Highlights"- ],"metadata": {"id": "ZMWitnLdlYCT"- }+ },+ "source": [+ "## 🌟 Highlights"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "w2OwDpJ0lg8o"+ },"source": ["* Automated Knowledge Extraction: The Knowledge Graph Agent automates the extraction of entities and relationships, making the process efficient and effective.\n","\n",@@ -830,19 +820,30 @@"\n","\n","* Secure and Scalable: Using CAMEL-AI's robust architecture and Neo4j for graph storage ensures that the solution is both secure and scalable."- ],- "metadata": {- "id": "w2OwDpJ0lg8o"- }+ ]},{"cell_type": "markdown",- "source": [- "By following this cookbook, you can leverage the cutting-edge capabilities of **CAMEL AI** and **Mistral AI** to build sophisticated knowledge graphs, facilitating advanced data analysis and retrieval tasks."- ],"metadata": {"id": "tlTJulaQlbyW"- }+ },+ "source": [+ "By following this cookbook, you can leverage the cutting-edge capabilities of **CAMEL AI** and **Mistral AI** to build sophisticated knowledge graphs, facilitating advanced data analysis and retrieval tasks."+ ]}- ]-}\ No newline at end of file+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/model_speed_comparison.ipynb b/docs/cookbooks/model_speed_comparison.ipynbindex 50a457f14..3b3aafbb3 100644--- a/docs/cookbooks/model_speed_comparison.ipynb+++ b/docs/cookbooks/model_speed_comparison.ipynb@@ -109,7 +109,7 @@"id": "PNBFEXc-R-0s","outputId": "1c9ad95d-50c5-4d8e-e83a-8ed24d44b2f7"},- "execution_count": 3,+ "execution_count": null,"outputs": [{"name": "stdout",@@ -137,6 +137,7 @@" model_configs = [\n"," (ModelPlatformType.OPENAI, ModelType.GPT_4O_MINI, ChatGPTConfig(temperature=0.0, max_tokens=2000), \"OpenAI GPT-4O Mini\"),\n"," (ModelPlatformType.OPENAI, ModelType.GPT_4O, ChatGPTConfig(temperature=0.0, max_tokens=2000), \"OpenAI GPT-4O\"),\n",+ " # NOTE: OpenAI O1 model requires additional additional credentials\n"," (ModelPlatformType.OPENAI, ModelType.O1_PREVIEW, ChatGPTConfig(temperature=0.0), \"OpenAI O1 Preview\"),\n"," (ModelPlatformType.SAMBA, \"Meta-Llama-3.1-8B-Instruct\", SambaCloudAPIConfig(temperature=0.0, max_tokens=2000), \"SambaNova Llama 8B\"),\n"," (ModelPlatformType.SAMBA, \"Meta-Llama-3.1-70B-Instruct\", SambaCloudAPIConfig(temperature=0.0, max_tokens=2000), \"SambaNova Llama 70B\"),\n",@@ -198,7 +199,7 @@"id": "ZT2tYqYh6EDj","outputId": "93440028-f9a0-47e0-aafb-1055601f37ce"},- "execution_count": 4,+ "execution_count": null,"outputs": [{"output_type": "stream",diff --git a/docs/cookbooks/roleplaying_scraper.ipynb b/docs/cookbooks/roleplaying_scraper.ipynbindex fdc8d0a0f..d524a8983 100644--- a/docs/cookbooks/roleplaying_scraper.ipynb+++ b/docs/cookbooks/roleplaying_scraper.ipynb@@ -1,39 +1,29 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",- "source": [- "# 🐫 CAMEL Role-Playing **Scraper** for **Report** & **Knowledge Graph** Generation\n"- ],"metadata": {"id": "ymsq1Lw0VEqT"- }+ },+ "source": [+ "# Role-Playing Scraper for Report & Knowledge Graph Generation\n"+ ]},{"cell_type": "markdown",- "source": [- "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1XN18zb5ay97ju8LvL7WikEDqQBws-t0U?usp=sharing)"- ],"metadata": {"id": "7V3aV16AmY0K"- }+ },+ "source": [+ "You can also check this cookbook in colab [here](https://colab.research.google.com/drive/1XN18zb5ay97ju8LvL7WikEDqQBws-t0U?usp=sharing)"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "G5gE04UuPUWj"+ },"source": ["This notebook demonstrates how to set up and leverage CAMEL's Retrieval-Augmented Generation (RAG) combined with Firecrawl for efficient web scraping, multi-agent role-playing tasks, and knowledge graph construction. We will walk through an example of conducting a comprehensive study of the Turkish shooter in the 2024 Paris Olympics by using Mistral's models.\n","\n",@@ -50,48 +40,45 @@"\n","\n","This setup not only demonstrates a practical application but also serves as a flexible framework that can be adapted for various scenarios requiring advanced web information retrieval, AI collaboration, and multi-source data aggregation."- ],- "metadata": {- "id": "G5gE04UuPUWj"- }+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "soIw38pJLv2f"+ },"source": ["⭐ **Star the Repo**\n","\n","If you find CAMEL useful or interesting, please consider giving it a star on our [CAMEL GitHub Repo](https://github.com/camel-ai/camel)! Your stars help others find this project and motivate us to continue improving it."- ],- "metadata": {- "id": "soIw38pJLv2f"- }+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "vq-HTbJyN4wn"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- "## 📦 Installation"- ],"metadata": {"id": "0J0_iW-YVcq2"- }+ },+ "source": [+ "## 📦 Installation"+ ]},{"cell_type": "markdown",- "source": [- "First, install the CAMEL package with all its dependencies:"- ],"metadata": {"id": "7p-JjpyNVcCT"- }+ },+ "source": [+ "First, install the CAMEL package with all its dependencies:"+ ]},{"cell_type": "code",@@ -107,49 +94,41 @@},{"cell_type": "markdown",- "source": [- "## 🔑 Setting Up API Keys"- ],"metadata": {"id": "lfNvFbhD6o8B"- }+ },+ "source": [+ "## 🔑 Setting Up API Keys"+ ]},{"cell_type": "markdown",- "source": [- "You'll need to set up your API keys for Mistral AI, Firecrawl and AgentOps. This ensures that the tools can interact with external services securely."- ],"metadata": {"id": "jqV12oQfQTyl"- }+ },+ "source": [+ "You'll need to set up your API keys for Mistral AI, Firecrawl and AgentOps. This ensures that the tools can interact with external services securely."+ ]},{"cell_type": "markdown",- "source": [- "You can go to [here](https://app.agentops.ai/signin) to get **free** API Key from AgentOps\n"- ],"metadata": {"id": "Sc3MAQwiH9Pd"- }+ },+ "source": [+ "You can go to [here](https://app.agentops.ai/signin) to get **free** API Key from AgentOps\n"+ ]},{"cell_type": "code",- "source": [- "import os\n",- "from getpass import getpass\n",- "\n",- "# Prompt for the AgentOps API key securely\n",- "agentops_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key"- ],+ "execution_count": 2,"metadata": {- "id": "HQ_yOT5_Hyt4","colab": {"base_uri": "https://localhost:8080/"},+ "id": "HQ_yOT5_Hyt4","outputId": "8e82dbad-55f1-4adb-a06d-73570f356766"},- "execution_count": 2,"outputs": [{"name": "stdout",@@ -158,32 +137,35 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "import os\n",+ "from getpass import getpass\n",+ "\n",+ "# Prompt for the AgentOps API key securely\n",+ "agentops_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"AGENTOPS_API_KEY\"] = agentops_api_key"]},{"cell_type": "markdown",- "source": [- "Your can go to [here](https://console.mistral.ai/api-keys/) to get API Key from Mistral AI with **free** credits."- ],"metadata": {"id": "czxWvnvnAimt"- }+ },+ "source": [+ "Your can go to [here](https://console.mistral.ai/api-keys/) to get API Key from Mistral AI with **free** credits."+ ]},{"cell_type": "code",- "source": [- "# Prompt for the API key securely\n",- "mistral_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"MISTRAL_API_KEY\"] = mistral_api_key"- ],+ "execution_count": 3,"metadata": {- "id": "T0FBl1WF6jFs","colab": {"base_uri": "https://localhost:8080/"},+ "id": "T0FBl1WF6jFs","outputId": "05502406-c889-46bd-a104-f0a1fe25f763"},- "execution_count": 3,"outputs": [{"name": "stdout",@@ -192,19 +174,29 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "# Prompt for the API key securely\n",+ "mistral_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"MISTRAL_API_KEY\"] = mistral_api_key"]},{"cell_type": "markdown",- "source": [- "Set up the Mistral Large 2 model using the CAMEL ModelFactory. You can also configure other models as needed."- ],"metadata": {"id": "qdG7LbDgDNe7"- }+ },+ "source": [+ "Set up the Mistral Large 2 model using the CAMEL ModelFactory. You can also configure other models as needed."+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "id": "ojjHCTsUDK6s"+ },+ "outputs": [],"source": ["from camel.models import ModelFactory\n","from camel.types import ModelPlatformType, ModelType\n",@@ -216,37 +208,27 @@" model_type=ModelType.MISTRAL_LARGE,\n"," model_config_dict=MistralConfig(temperature=0.2).as_dict(),\n",")"- ],- "metadata": {- "id": "ojjHCTsUDK6s"- },- "execution_count": 4,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Your can go to [here](https://www.firecrawl.dev/) to get API Key from Firecrawl with **free** credits."- ],"metadata": {"id": "akkwlXcjTLcH"- }+ },+ "source": [+ "Your can go to [here](https://www.firecrawl.dev/) to get API Key from Firecrawl with **free** credits."+ ]},{"cell_type": "code",- "source": [- "# Prompt for the Firecrawl API key securely\n",- "firecrawl_api_key = getpass('Enter your API key: ')\n",- "os.environ[\"FIRECRAWL_API_KEY\"] = firecrawl_api_key"- ],+ "execution_count": 5,"metadata": {- "id": "0byeytnFWiaG","colab": {"base_uri": "https://localhost:8080/"},+ "id": "0byeytnFWiaG","outputId": "64433b9f-b9a3-4ef2-c680-d489442e05a5"},- "execution_count": 5,"outputs": [{"name": "stdout",@@ -255,52 +237,45 @@"Enter your API key: ··········\n"]}+ ],+ "source": [+ "# Prompt for the Firecrawl API key securely\n",+ "firecrawl_api_key = getpass('Enter your API key: ')\n",+ "os.environ[\"FIRECRAWL_API_KEY\"] = firecrawl_api_key"]},{"cell_type": "markdown",- "source": [- "## 🌐 Web Scraping with Firecrawl"- ],"metadata": {"id": "kiyIq4I3pSE2"- }+ },+ "source": [+ "## 🌐 Web Scraping with Firecrawl"+ ]},{"cell_type": "markdown",- "source": [- "Firecrawl is a powerful tool that simplifies web scraping and cleaning content from web pages. In this section, we will scrape content from a specific post on the CAMEL AI website as an example."- ],"metadata": {"id": "qgx3GS9LNaVe"- }+ },+ "source": [+ "Firecrawl is a powerful tool that simplifies web scraping and cleaning content from web pages. In this section, we will scrape content from a specific post on the CAMEL AI website as an example."+ ]},{"cell_type": "code",- "source": [- "from camel.loaders import Firecrawl\n",- "\n",- "firecrawl = Firecrawl()\n",- "\n",- "# Scrape and clean content from a specified URL\n",- "response = firecrawl.scrape(\n",- " url=\"https://www.camel-ai.org/post/crab\"\n",- ")\n",- "\n",- "print(response[\"markdown\"])"- ],+ "execution_count": 6,"metadata": {- "id": "i1jiXAdopRNH","colab": {"base_uri": "https://localhost:8080/"},+ "id": "i1jiXAdopRNH","outputId": "7a6d8530-e45e-4037-b532-a0a26718aee9"},- "execution_count": 6,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["Aug 9\n","\n",@@ -538,69 +513,86 @@"Copyright © 2024 Eigent AI - All Rights Reserved.\n"]}+ ],+ "source": [+ "from camel.loaders import Firecrawl\n",+ "\n",+ "firecrawl = Firecrawl()\n",+ "\n",+ "# Scrape and clean content from a specified URL\n",+ "response = firecrawl.scrape(\n",+ " url=\"https://www.camel-ai.org/post/crab\"\n",+ ")\n",+ "\n",+ "print(response[\"markdown\"])"]},{"cell_type": "markdown",- "source": [- "**🎉 Firecrawl makes obtaining clean, LLM-friendly content from URL effortless!**"- ],"metadata": {"id": "q5NJlRL1N5vu"- }+ },+ "source": [+ "**🎉 Firecrawl makes obtaining clean, LLM-friendly content from URL effortless!**"+ ]},{"cell_type": "markdown",- "source": [- "## 🛠️ Web Information Retrieval using CAMEL's RAG and Firecrawl"- ],"metadata": {"id": "NEUciNquON9_"- }+ },+ "source": [+ "## 🛠️ Web Information Retrieval using CAMEL's RAG and Firecrawl"+ ]},{"cell_type": "markdown",- "source": [- "*In this section, we'll demonstrate how to retrieve relevant information from a list of URLs using CAMEL's RAG model. This is particularly useful for aggregating and analyzing data from multiple sources.*"- ],"metadata": {"id": "6f64VOMMP93d"- }+ },+ "source": [+ "*In this section, we'll demonstrate how to retrieve relevant information from a list of URLs using CAMEL's RAG model. This is particularly useful for aggregating and analyzing data from multiple sources.*"+ ]},{"cell_type": "markdown",- "source": [- "### Setting Up Firecrawl with CAMEL's RAG"- ],"metadata": {"id": "46Irp_SurLaV"- }+ },+ "source": [+ "### Setting Up Firecrawl with CAMEL's RAG"+ ]},{"cell_type": "markdown",- "source": [- "The following function retrieves relevant information from a list of URLs based on a given query. It combines web scraping with Firecrawl and CAMEL's AutoRetriever for a seamless information retrieval process."- ],"metadata": {"id": "QVB-Xra8QIU1"- }+ },+ "source": [+ "The following function retrieves relevant information from a list of URLs based on a given query. It combines web scraping with Firecrawl and CAMEL's AutoRetriever for a seamless information retrieval process."+ ]},{"cell_type": "code",+ "execution_count": 16,+ "metadata": {+ "id": "gE_qBFCVveBR"+ },+ "outputs": [],"source": ["from camel.retrievers import AutoRetriever\n","from camel.toolkits import FunctionTool, SearchToolkit\n","from camel.types import ModelPlatformType, ModelType, StorageType\n","from camel.embeddings import MistralEmbedding"- ],- "metadata": {- "id": "gE_qBFCVveBR"- },- "execution_count": 16,- "outputs": []+ ]},{"cell_type": "code",+ "execution_count": 8,+ "metadata": {+ "id": "A75lxSmLsLSr"+ },+ "outputs": [],"source": ["def retrieve_information_from_urls(urls: list[str], query: str) -> str:\n"," r\"\"\"Retrieves relevant information from a list of URLs based on a given\n",@@ -647,35 +639,21 @@" )\n","\n"," return retrieved_info"- ],- "metadata": {- "id": "A75lxSmLsLSr"- },- "execution_count": 8,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "nLh5nU7uUeo-"+ },"source": ["Let's put the retrieval function to the test by gathering some information about the 2024 Olympics.\n","The first run may take about 50 seconds as it needs to build a local vector database."- ],- "metadata": {- "id": "nLh5nU7uUeo-"- }+ ]},{"cell_type": "code",- "source": [- "retrieved_info = retrieve_information_from_urls(\n",- " query=\"Which country won the most golden prize in 2024 Olympics?\",\n",- " urls=[\n",- " \"https://www.nbcnews.com/sports/olympics/united-states-china-gold-medals-rcna166013\",\n",- " ],\n",- ")\n",- "\n",- "print(retrieved_info)"- ],+ "execution_count": 9,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -683,41 +661,47 @@"id": "z4z00v9yWvFw","outputId": "79eb717b-8dcf-4806-da19-bbb97f462c78"},- "execution_count": 9,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["{'Original Query': 'Which country won the most golden prize in 2024 Olympics?', 'Retrieved Context': [', when the “Unified Team,”\\xa0athletes from the former Soviet Union republics, won 112 medals, including 45 golds. The Americans made 108 podium visits in Barcelona, with 37 of them on the top step.\\n\\n', '* China’s Li Wenwen won gold in [women’s heavyweight weightlifting](https://olympics.com/en/news/paris-2024-weightlifting-results-li-wenwen-81kg-gold)\\n in what could have been a death knell for American hopes to capture overall gold.\\n* U.S. hopes were dimmed further when [Chicago native](https://www.nbcchicago.com/paris-2024-summer-olympics/chicagos-kennedy-blades-scores-medal-in-her-first-ever-olympic-games/3519220/)', 'While there had been no gold medal ties in Summer Games history, there have been three draws in the Winter Olympics.\\n\\nThe most recent draw was between Norway and Germany, each [winning 14\\xa0golds in PyeongChang 2018](https://olympics.com/en/olympic-games/pyeongchang-2018/medals)\\n.\\n\\nThe U.S. still came out with the most overall medals, taking home 126 from Paris this year.\\n\\nThe U.S. hasn’t failed to win [the most medals since 1992](https://olympics.com/en/olympic-games/barcelona-1992/medals)']}\n"]}+ ],+ "source": [+ "retrieved_info = retrieve_information_from_urls(\n",+ " query=\"Which country won the most golden prize in 2024 Olympics?\",\n",+ " urls=[\n",+ " \"https://www.nbcnews.com/sports/olympics/united-states-china-gold-medals-rcna166013\",\n",+ " ],\n",+ ")\n",+ "\n",+ "print(retrieved_info)"]},{"cell_type": "markdown",- "source": [- "**🎉 Thanks to CAMEL's RAG pipeline and Firecrawl's tidy scraping capabilities, this function effectively retrieves relevant information from the specified URLs! You can now integrate this function into CAMEL's Agents to automate the retrieval process further.**"- ],"metadata": {"id": "r8QpOBNLX-R_"- }+ },+ "source": [+ "**🎉 Thanks to CAMEL's RAG pipeline and Firecrawl's tidy scraping capabilities, this function effectively retrieves relevant information from the specified URLs! You can now integrate this function into CAMEL's Agents to automate the retrieval process further.**"+ ]},{"cell_type": "markdown",- "source": [- "## 📹 Monitoring AI Agents with AgentOps"- ],"metadata": {"id": "b7jyteu-2SFc"- }+ },+ "source": [+ "## 📹 Monitoring AI Agents with AgentOps"+ ]},{"cell_type": "code",- "source": [- "import agentops\n",- "agentops.init(default_tags=[\"CAMEL cookbook\"])"- ],+ "execution_count": 10,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -725,56 +709,64 @@"id": "mHSfqXyhIK0N","outputId": "52d5c876-e7cf-480f-8355-495c6ff0e061"},- "execution_count": 10,"outputs": [{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=85d13cd7-2417-448c-aac7-d8c360091e2d\u001b[0m\u001b[0m\n"]},{- "output_type": "execute_result","data": {"text/plain": ["<agentops.session.Session at 0x7dafe4b91b40>"]},+ "execution_count": 10,"metadata": {},- "execution_count": 10+ "output_type": "execute_result"}+ ],+ "source": [+ "import agentops\n",+ "agentops.init(default_tags=[\"CAMEL cookbook\"])"]},{"cell_type": "markdown",- "source": [- "## 🧠 Knowledge Graph Construction"- ],"metadata": {"id": "n1Q8IKWUrAkr"- }+ },+ "source": [+ "## 🧠 Knowledge Graph Construction"+ ]},{"cell_type": "markdown",- "source": [- "*A powerful feature of CAMEL is its ability to build and store knowledge graphs from text data. This allows for advanced analysis and visualization of relationships within the data.*"- ],"metadata": {"id": "dD7p_9CkyUmK"- }+ },+ "source": [+ "*A powerful feature of CAMEL is its ability to build and store knowledge graphs from text data. This allows for advanced analysis and visualization of relationships within the data.*"+ ]},{"cell_type": "markdown",- "source": [- "Set up your Neo4j instance by providing the URL, username, and password, [here](https://neo4j.com/docs/aura/auradb/getting-started/create-database/) is the guidance, check your credentials in the downloaded .txt file. Note that you may need to wait up to 60 seconds if the instance has just been set up."- ],"metadata": {"id": "k_fZhcgnrUX1"- }+ },+ "source": [+ "Set up your Neo4j instance by providing the URL, username, and password, [here](https://neo4j.com/docs/aura/auradb/getting-started/create-database/) is the guidance, check your credentials in the downloaded .txt file. Note that you may need to wait up to 60 seconds if the instance has just been set up."+ ]},{"cell_type": "code",+ "execution_count": 12,+ "metadata": {+ "id": "raMV4BwhrhNK"+ },+ "outputs": [],"source": ["from camel.storages import Neo4jGraph\n","from camel.loaders import UnstructuredIO\n",@@ -814,33 +806,33 @@" n4j.add_graph_elements(graph_elements=[graph_elements])\n","\n"," return graph_elements\n"- ],- "metadata": {- "id": "raMV4BwhrhNK"- },- "execution_count": 12,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "## 🤖🤖 Multi-Agent Role-Playing with CAMEL"- ],"metadata": {"id": "uiDkPPrBshW4"- }+ },+ "source": [+ "## 🤖🤖 Multi-Agent Role-Playing with CAMEL"+ ]},{"cell_type": "markdown",- "source": [- "*This section sets up a role-playing session where AI agents interact to accomplish a task using various tools. We will guide the assistant agent to perform a comprehensive study of the Turkish shooter in the 2024 Paris Olympics.*"- ],"metadata": {"id": "6MZVoQI7OltM"- }+ },+ "source": [+ "*This section sets up a role-playing session where AI agents interact to accomplish a task using various tools. We will guide the assistant agent to perform a comprehensive study of the Turkish shooter in the 2024 Paris Olympics.*"+ ]},{"cell_type": "code",+ "execution_count": 13,+ "metadata": {+ "id": "JTWQ4i6tt6mh"+ },+ "outputs": [],"source": ["from typing import List\n","\n",@@ -849,24 +841,24 @@"from camel.agents.chat_agent import FunctionCallingRecord\n","from camel.societies import RolePlaying\n","from camel.utils import print_text_animated"- ],- "metadata": {- "id": "JTWQ4i6tt6mh"- },- "execution_count": 13,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Defining the Task Prompt"- ],"metadata": {"id": "ggqh3_t9tURm"- }+ },+ "source": [+ "Defining the Task Prompt"+ ]},{"cell_type": "code",+ "execution_count": 14,+ "metadata": {+ "id": "rtwuPLI_ssrX"+ },+ "outputs": [],"source": ["task_prompt = \"\"\"Do a comprehensive study of the Turkish shooter in 2024 paris\n","olympics, write a report for me, then create a knowledge graph for the report.\n",@@ -874,24 +866,24 @@"to get the retrieved content back by providing the list of URLs, finially\n","use tool to build the knowledge graph to finish the task.\n","No more other actions needed\"\"\""- ],- "metadata": {- "id": "rtwuPLI_ssrX"- },- "execution_count": 14,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "We will configure the assistant agent with tools for mathematical calculations, web information retrieval, and knowledge graph building."- ],"metadata": {"id": "KI0k6XJZtaN5"- }+ },+ "source": [+ "We will configure the assistant agent with tools for mathematical calculations, web information retrieval, and knowledge graph building."+ ]},{"cell_type": "code",+ "execution_count": 17,+ "metadata": {+ "id": "Bw3_LyXiteVT"+ },+ "outputs": [],"source": ["retrieval_tool = FunctionTool(retrieve_information_from_urls)\n","search_tool = FunctionTool(SearchToolkit().search_duckduckgo)\n",@@ -907,24 +899,24 @@" tools=tool_list,\n"," temperature=0.0,\n",")"- ],- "metadata": {- "id": "Bw3_LyXiteVT"- },- "execution_count": 17,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Setting Up the Role-Playing Session"- ],"metadata": {"id": "Yc80X_ZItyvi"- }+ },+ "source": [+ "Setting Up the Role-Playing Session"+ ]},{"cell_type": "code",+ "execution_count": 18,+ "metadata": {+ "id": "insV1gSyt0b3"+ },+ "outputs": [],"source": ["# Initialize the role-playing session\n","role_play_session = RolePlaying(\n",@@ -942,52 +934,31 @@" task_prompt=task_prompt,\n"," with_task_specify=False,\n",")"- ],- "metadata": {- "id": "insV1gSyt0b3"- },- "execution_count": 18,- "outputs": []+ ]},{"cell_type": "markdown",- "source": [- "Print the system message and task prompt"- ],"metadata": {"id": "o7vfyJMdt8R1"- }+ },+ "source": [+ "Print the system message and task prompt"+ ]},{"cell_type": "code",- "source": [- "# Print system and task messages\n",- "print(\n",- " Fore.GREEN\n",- " + f\"AI Assistant sys message:\\n{role_play_session.assistant_sys_msg}\\n\"\n",- ")\n",- "print(Fore.BLUE + f\"AI User sys message:\\n{role_play_session.user_sys_msg}\\n\")\n",- "\n",- "print(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\n",- "print(\n",- " Fore.CYAN\n",- " + \"Specified task prompt:\"\n",- " + f\"\\n{role_play_session.specified_task_prompt}\\n\"\n",- ")\n",- "print(Fore.RED + f\"Final task prompt:\\n{role_play_session.task_prompt}\\n\")"- ],+ "execution_count": 19,"metadata": {- "id": "9xMDZxBmt-Ms","colab": {"base_uri": "https://localhost:8080/"},+ "id": "9xMDZxBmt-Ms","outputId": "cf73c34a-326f-40fa-f690-6347ca7ad600"},- "execution_count": 19,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[32mAI Assistant sys message:\n","BaseMessage(role_name='CAMEL Assistant', role_type=<RoleType.ASSISTANT: 'assistant'>, meta_dict={'task': 'Do a comprehensive study of the Turkish shooter in 2024 paris\\nolympics, write a report for me, then create a knowledge graph for the report.\\nYou should use search tool to get related URLs first, then use retrieval tool\\nto get the retrieved content back by providing the list of URLs, finially\\nuse tool to build the knowledge graph to finish the task.\\nNo more other actions needed', 'assistant_role': 'CAMEL Assistant', 'user_role': 'CAMEL User'}, content='===== RULES OF ASSISTANT =====\\nNever forget you are a CAMEL Assistant and I am a CAMEL User. 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: Do a comprehensive study of the Turkish shooter in 2024 paris\\nolympics, write a report for me, then create a knowledge graph for the report.\\nYou should use search tool to get related URLs first, then use retrieval tool\\nto get the retrieved content back by providing the list of URLs, finially\\nuse tool to build the knowledge graph to finish the task.\\nNo more other actions needed. 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.', video_bytes=None, image_list=None, image_detail='auto', video_detail='low')\n",@@ -1016,80 +987,49 @@"\n"]}+ ],+ "source": [+ "# Print system and task messages\n",+ "print(\n",+ " Fore.GREEN\n",+ " + f\"AI Assistant sys message:\\n{role_play_session.assistant_sys_msg}\\n\"\n",+ ")\n",+ "print(Fore.BLUE + f\"AI User sys message:\\n{role_play_session.user_sys_msg}\\n\")\n",+ "\n",+ "print(Fore.YELLOW + f\"Original task prompt:\\n{task_prompt}\\n\")\n",+ "print(\n",+ " Fore.CYAN\n",+ " + \"Specified task prompt:\"\n",+ " + f\"\\n{role_play_session.specified_task_prompt}\\n\"\n",+ ")\n",+ "print(Fore.RED + f\"Final task prompt:\\n{role_play_session.task_prompt}\\n\")"]},{"cell_type": "markdown",+ "metadata": {+ "id": "1ibe4da9uB2H"+ },"source": ["Set the termination rule and start the interaction between agents\n","\n","**NOTE**: This session will take approximately 8 minutes and will consume around 60k tokens by using Mistral Large 2 Model."- ],- "metadata": {- "id": "1ibe4da9uB2H"- }+ ]},{"cell_type": "code",- "source": [- "n = 0\n",- "input_msg = role_play_session.init_chat()\n",- "while n < 20: # Limit the chat to 20 turns\n",- " n += 1\n",- " assistant_response, user_response = role_play_session.step(input_msg)\n",- "\n",- " if assistant_response.terminated:\n",- " print(\n",- " Fore.GREEN\n",- " + (\n",- " \"AI Assistant terminated. Reason: \"\n",- " f\"{assistant_response.info['termination_reasons']}.\"\n",- " )\n",- " )\n",- " break\n",- " if user_response.terminated:\n",- " print(\n",- " Fore.GREEN\n",- " + (\n",- " \"AI User terminated. \"\n",- " f\"Reason: {user_response.info['termination_reasons']}.\"\n",- " )\n",- " )\n",- " break\n",- " # Print output from the user\n",- " print_text_animated(\n",- " Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\",\n",- " 0.01\n",- " )\n",- "\n",- " if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n",- " break\n",- "\n",- " # Print output from the assistant, including any function\n",- " # execution information\n",- " print_text_animated(Fore.GREEN + \"AI Assistant:\", 0.01)\n",- " tool_calls: List[FunctionCallingRecord] = [\n",- " FunctionCallingRecord(**call.as_dict())\n",- " for call in assistant_response.info['tool_calls']\n",- " ]\n",- " for func_record in tool_calls:\n",- " print_text_animated(f\"{func_record}\", 0.01)\n",- " print_text_animated(f\"{assistant_response.msg.content}\\n\", 0.01)\n",- "\n",- " input_msg = assistant_response.msg"- ],+ "execution_count": null,"metadata": {- "id": "xOhdpjxuuH-2","colab": {"base_uri": "https://localhost:8080/"},+ "id": "xOhdpjxuuH-2","outputId": "3d8018da-3c23-46c2-c12e-d5360a6fd95c"},- "execution_count": null,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": ["\u001b[34mAI User:\n","\n",@@ -1308,84 +1248,134 @@"\n"]}+ ],+ "source": [+ "n = 0\n",+ "input_msg = role_play_session.init_chat()\n",+ "while n < 20: # Limit the chat to 20 turns\n",+ " n += 1\n",+ " assistant_response, user_response = role_play_session.step(input_msg)\n",+ "\n",+ " if assistant_response.terminated:\n",+ " print(\n",+ " Fore.GREEN\n",+ " + (\n",+ " \"AI Assistant terminated. Reason: \"\n",+ " f\"{assistant_response.info['termination_reasons']}.\"\n",+ " )\n",+ " )\n",+ " break\n",+ " if user_response.terminated:\n",+ " print(\n",+ " Fore.GREEN\n",+ " + (\n",+ " \"AI User terminated. \"\n",+ " f\"Reason: {user_response.info['termination_reasons']}.\"\n",+ " )\n",+ " )\n",+ " break\n",+ " # Print output from the user\n",+ " print_text_animated(\n",+ " Fore.BLUE + f\"AI User:\\n\\n{user_response.msg.content}\\n\",\n",+ " 0.01\n",+ " )\n",+ "\n",+ " if \"CAMEL_TASK_DONE\" in user_response.msg.content:\n",+ " break\n",+ "\n",+ " # Print output from the assistant, including any function\n",+ " # execution information\n",+ " print_text_animated(Fore.GREEN + \"AI Assistant:\", 0.01)\n",+ " tool_calls: List[FunctionCallingRecord] = [\n",+ " FunctionCallingRecord(**call.as_dict())\n",+ " for call in assistant_response.info['tool_calls']\n",+ " ]\n",+ " for func_record in tool_calls:\n",+ " print_text_animated(f\"{func_record}\", 0.01)\n",+ " print_text_animated(f\"{assistant_response.msg.content}\\n\", 0.01)\n",+ "\n",+ " input_msg = assistant_response.msg"]},{"cell_type": "code",- "source": [- "# End the AgentOps session\n",- "agentops.end_session(\"Success\")"- ],+ "execution_count": null,"metadata": {- "id": "t7zTkjDBIf_i","colab": {"base_uri": "https://localhost:8080/"},+ "id": "t7zTkjDBIf_i","outputId": "32f89a58-ca8f-46fc-b9aa-cd5d6f003ace"},- "execution_count": null,"outputs": [{- "output_type": "stream","name": "stderr",+ "output_type": "stream","text": ["🖇 AgentOps: This run's cost $0.00\n","🖇 AgentOps: \u001b[34m\u001b[34mSession Replay: https://app.agentops.ai/drilldown?session_id=ab0c011f-1928-4895-9747-ea882e9dfc38\u001b[0m\u001b[0m\n"]}+ ],+ "source": [+ "# End the AgentOps session\n",+ "agentops.end_session(\"Success\")"]},{"cell_type": "markdown",+ "metadata": {+ "id": "4au_S6ITIfnx"+ },"source": ["🎉 Go to the AgentOps link shown above, you will be able to see the detailed record for this running like below.\n","\n","**NOTE**: The AgentOps link is private and tied to the AgentOps account. To access the link, you’ll need to run the session using your own AgentOps API Key, which will then allow you to open the link with the session’s running information.\n","\n","Currently AgentOps can't get the running cost for Mistral AI directly."- ],- "metadata": {- "id": "4au_S6ITIfnx"- }+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "OTGVmZ2bouJv"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- "🎉 You can also go the the [Neo4j Aura](https://login.neo4j.com/u/login/identifier?state=hKFo2SBRTk8tVW5CU201cGtOMDdGYlp1bFJYRlVUZGlUY05SdqFur3VuaXZlcnNhbC1sb2dpbqN0aWTZIEFSYTFtMVJsekVnVy1vaHZjQzRNWDB4SXlYak9SOUw5o2NpZNkgV1NMczYwNDdrT2pwVVNXODNnRFo0SnlZaElrNXpZVG8) to check the knowledge graph generated by CAMEL's Agent like below."- ],"metadata": {"id": "yDriFSAr4QRw"- }+ },+ "source": [+ "🎉 You can also go the the [Neo4j Aura](https://login.neo4j.com/u/login/identifier?state=hKFo2SBRTk8tVW5CU201cGtOMDdGYlp1bFJYRlVUZGlUY05SdqFur3VuaXZlcnNhbC1sb2dpbqN0aWTZIEFSYTFtMVJsekVnVy1vaHZjQzRNWDB4SXlYak9SOUw5o2NpZNkgV1NMczYwNDdrT2pwVVNXODNnRFo0SnlZaElrNXpZVG8) to check the knowledge graph generated by CAMEL's Agent like below."+ ]},{"cell_type": "markdown",- "source": [- ""- ],"metadata": {"id": "Tq_wssFTYaKH"- }+ },+ "source": [+ ""+ ]},{"cell_type": "markdown",- "source": [- "## 🌟 Highlights"- ],"metadata": {"id": "flYNal6-R4yR"- }+ },+ "source": [+ "## 🌟 Highlights"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "SmkXhy4JR726"+ },"source": ["This notebook has guided you through setting up and running a CAMEL RAG workflow with Firecrawl for a complex, multi-agent role-playing task. You can adapt and expand this example for various other scenarios requiring advanced web information retrieval and AI collaboration.\n","\n",@@ -1403,21 +1393,32 @@"This comprehensive setup allows you to adapt and expand the example for various scenarios requiring advanced web information retrieval, AI collaboration, and multi-source data aggregation.\n","\n","**CAMEL also support advanced GraphRAG, for more information please check [here](https://colab.research.google.com/drive/1meBf9w8KzZvQdQU2I1bCyOg9ehoGDK1u?authuser=1)**"- ],- "metadata": {- "id": "SmkXhy4JR726"- }+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "s6Det-fcMb9A"+ },"source": ["⭐ **Star the Repo**\n","\n","If you find CAMEL useful or interesting, please consider giving it a star on [GitHub](https://github.com/camel-ai/camel)! Your stars help others find this project and motivate us to continue improving it."- ],- "metadata": {- "id": "s6Det-fcMb9A"- }+ ]+ }+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3",+ "name": "python3"+ },+ "language_info": {+ "name": "python"}- ]-}\ No newline at end of file+ },+ "nbformat": 4,+ "nbformat_minor": 0+}diff --git a/docs/cookbooks/task_generation.ipynb b/docs/cookbooks/task_generation.ipynbindex a8d9be1fd..cac0ea4ff 100644--- a/docs/cookbooks/task_generation.ipynb+++ b/docs/cookbooks/task_generation.ipynb@@ -1,12 +1,13 @@{"cells": [{+ "attachments": {},"cell_type": "markdown","metadata": {"id": "Fvdt_pMpf7EK"},"source": [- "# 🐫 CAMEL Task Generation Cookbook"+ "# Task Generation Cookbook"]},{diff --git a/docs/cookbooks/video_analysis.ipynb b/docs/cookbooks/video_analysis.ipynbindex 45b97ddc3..ee0548e5d 100644--- a/docs/cookbooks/video_analysis.ipynb+++ b/docs/cookbooks/video_analysis.ipynb@@ -28,7 +28,7 @@},"outputs": [],"source": [- "%pip install \"camel-ai[all]==0.2.1\""+ "%pip install \"camel-ai[all]==0.2.4\""]},{diff --git a/docs/cookbooks/workforce_judge_committee.ipynb b/docs/cookbooks/workforce_judge_committee.ipynbindex 7105e2179..f6c4f56bd 100644--- a/docs/cookbooks/workforce_judge_committee.ipynb+++ b/docs/cookbooks/workforce_judge_committee.ipynb@@ -1,22 +1,11 @@{- "nbformat": 4,- "nbformat_minor": 0,- "metadata": {- "colab": {- "provenance": []- },- "kernelspec": {- "name": "python3",- "display_name": "Python 3 (ipykernel)",- "language": "python"- },- "language_info": {- "name": "python"- }- },"cells": [{+ "attachments": {},"cell_type": "markdown",+ "metadata": {+ "id": "k-xIA7Qjuiwu"+ },"source": ["# Create A Hackathon Judge Committee with Workforce\n","\n",@@ -26,67 +15,79 @@"\n","## Dependency Installation\n","\n",- "To get started, make sure you have `camel-ai[all]==0.2.1` installed."- ],- "metadata": {- "id": "k-xIA7Qjuiwu"- }+ "To get started, make sure you have CAMEL installed."+ ]},{"cell_type": "code",- "source": "%pip install \"camel-ai[all]==0.2.1\"",+ "execution_count": null,"metadata": {"colab": {"base_uri": "https://localhost:8080/","height": 1000},+ "collapsed": true,"id": "kR2UeIHFUBMf",- "outputId": "8f30c9dd-6f69-4e01-9401-f38ecef2e0dc",- "collapsed": true+ "outputId": "8f30c9dd-6f69-4e01-9401-f38ecef2e0dc"},"outputs": [],- "execution_count": null+ "source": [+ "%pip install \"camel-ai[all]==0.2.4\""+ ]},{"cell_type": "markdown",- "source": [- "Workforce employs an asynchronous design with coroutines. However, since **coroutines cannot directly run in notebooks**, we need to do specific handlings in this demo. Note that, under most normal cases (not inside notebook environment), we don't need to do this."- ],"metadata": {"id": "mY3G7K9swEzz"- }+ },+ "source": [+ "Workforce employs an asynchronous design with coroutines. However, since **coroutines cannot directly run in notebooks**, we need to do specific handlings in this demo. Note that, under most normal cases (not inside notebook environment), we don't need to do this."+ ]},{"cell_type": "code",- "source": [- "%pip install nest_asyncio\n",- "import nest_asyncio\n",- "\n",- "nest_asyncio.apply()"- ],+ "execution_count": null,"metadata": {- "id": "smfCqcqNUJHX","colab": {"base_uri": "https://localhost:8080/"},+ "id": "smfCqcqNUJHX","outputId": "1e35a4ee-4f65-4d00-d5c2-39dea425dcfa"},"outputs": [],- "execution_count": null+ "source": [+ "%pip install nest_asyncio\n",+ "import nest_asyncio\n",+ "\n",+ "nest_asyncio.apply()"+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "FIz0b9O_wqkW"+ },"source": ["## Key Configuration\n","\n","In this demo, we will use tools related to web searching. Therefore, we need to configure the OpenAI API key, along with the Google API keys beforeheads."- ],- "metadata": {- "id": "FIz0b9O_wqkW"- }+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "ExecuteTime": {+ "end_time": "2024-09-20T18:42:59.047055Z",+ "start_time": "2024-09-20T18:42:51.287850Z"+ },+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "HGpgR_XitX_B",+ "outputId": "07739d65-7d76-4ce4-f6fd-babef9187119"+ },+ "outputs": [],"source": ["from getpass import getpass\n","import os\n",@@ -99,34 +100,26 @@"# https://cse.google.com/cse/all\n","search_engine_id = getpass(\"Please input your Search Egine ID: \")\n","os.environ[\"SEARCH_ENGINE_ID\"] = search_engine_id"- ],- "metadata": {- "id": "HGpgR_XitX_B",- "colab": {- "base_uri": "https://localhost:8080/"- },- "outputId": "07739d65-7d76-4ce4-f6fd-babef9187119",- "ExecuteTime": {- "end_time": "2024-09-20T18:42:59.047055Z",- "start_time": "2024-09-20T18:42:51.287850Z"- }- },- "outputs": [],- "execution_count": 4+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "PnMcEXo_xxGF"+ },"source": ["## Define a Function for Making Judge Agent\n","\n","In this demo, we will create multiple judge agents with different personas and scoring criterias. For reusability, we first create a function to make judge agents."- ],- "metadata": {- "id": "PnMcEXo_xxGF"- }+ ]},{"cell_type": "code",+ "execution_count": 3,+ "metadata": {+ "id": "vYz3PT3YyOUC"+ },+ "outputs": [],"source": ["import textwrap\n","\n",@@ -165,7 +158,6 @@" model = ModelFactory.create(\n"," model_platform=ModelPlatformType.OPENAI,\n"," model_type=ModelType.GPT_4O,\n",- " model_config_dict=ChatGPTConfig().as_dict(),\n"," )\n","\n"," agent = ChatAgent(\n",@@ -174,26 +166,26 @@" )\n","\n"," return agent"- ],- "metadata": {- "id": "vYz3PT3YyOUC"- },- "execution_count": 3,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "HtP_ej5CyUNT"+ },"source": ["## Make a Mocked Hackathon Project\n","\n","Then we will create a mocked hackathon project description, which will be later sent to the judges for scoring."- ],- "metadata": {- "id": "HtP_ej5CyUNT"- }+ ]},{"cell_type": "code",+ "execution_count": 4,+ "metadata": {+ "id": "ClqLd4HKypTI"+ },+ "outputs": [],"source": ["proj_content = textwrap.dedent(\n"," \"\"\"\\\n",@@ -208,25 +200,20 @@" Currently, we have successfully implemented the Learner Profile Analysis and Dynamic Content Generation modules. The Adaptive Feedback Loop is partially functional, while the Multi-Modal Integration and Progress Tracking features are still in development.\n"," \"\"\" # noqa: E501\n",")"- ],- "metadata": {- "id": "ClqLd4HKypTI"- },- "execution_count": 4,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "z35CIla3zBF4"+ },"source": ["## Create Agents\n","\n","Then we will create five unique agents that will later collaborate together. Among these five agents, one of them is the helper that will help collect information and summarize the final result. We add search functions to this agent so that it can obtain information from online searches.\n","\n","The other four agents, on the other hand, are judges with different personas and criterias. They will give scores to the project according to the description, along with the information collected by the helper."- ],- "metadata": {- "id": "z35CIla3zBF4"- }+ ]},{"cell_type": "code",@@ -246,7 +233,6 @@"researcher_model = ModelFactory.create(\n"," model_platform=ModelPlatformType.OPENAI,\n"," model_type=ModelType.GPT_4O,\n",- " model_config_dict=ChatGPTConfig().as_dict(),\n",")\n","\n","researcher_agent = ChatAgent(\n",@@ -391,19 +377,39 @@},{"cell_type": "markdown",+ "metadata": {+ "id": "GG3CR8hX0p5w"+ },"source": ["## Create Workforce\n","\n","Then we will do the most important part of the demo: create a workforce. Despite its importance, this is actually easy. First, we can simply instantiate a workforce by passing a description to it. Then, we just call `add_single_agent_workder()` to add agents into it, along with their descriptions.\n","\n","Note that, the description is very important in workforce, because it helps the coordinator agent in the workforce to do the task designation. Therefore, it's recommended to clearly mark the responsibility and capability of an agent when adding it to the workforce."- ],- "metadata": {- "id": "GG3CR8hX0p5w"- }+ ]},{"cell_type": "code",+ "execution_count": 6,+ "metadata": {+ "colab": {+ "base_uri": "https://localhost:8080/"+ },+ "id": "yGXWp4Lw0pEM",+ "outputId": "209ccf65-9cc5-49e1-9d52-7f66cf04764a"+ },+ "outputs": [+ {+ "data": {+ "text/plain": [+ "Workforce 137603052227312 (Hackathon Judges)"+ ]+ },+ "execution_count": 6,+ "metadata": {},+ "output_type": "execute_result"+ }+ ],"source": ["workforce = Workforce('Hackathon Judges')\n","\n",@@ -429,30 +435,13 @@" 'projects.',\n"," worker=researcher_agent,\n",")"- ],- "metadata": {- "colab": {- "base_uri": "https://localhost:8080/"- },- "id": "yGXWp4Lw0pEM",- "outputId": "209ccf65-9cc5-49e1-9d52-7f66cf04764a"- },- "execution_count": 6,- "outputs": [- {- "output_type": "execute_result",- "data": {- "text/plain": [- "Workforce 137603052227312 (Hackathon Judges)"- ]- },- "metadata": {},- "execution_count": 6- }]},{"cell_type": "markdown",+ "metadata": {+ "id": "-WXOG-Hr1ibN"+ },"source": ["## Create a Task\n","\n",@@ -461,13 +450,15 @@"The `additional_info` here is an optional field. It will come in handy when the task has important additional information, and you want it to be preserved during the whole process. Workforce will keep `additional_info` unchanged no matter how the task is decomposed and processed. It's perfect for keeping the project description under this scenario.\n","\n","> Also note that, the `id` of a task is not something important and you can fill in whatever value you like (we suggest `\"0\"` though). This is due to some legacy problems in the `Task` design and will be fixed later."- ],- "metadata": {- "id": "-WXOG-Hr1ibN"- }+ ]},{"cell_type": "code",+ "execution_count": 7,+ "metadata": {+ "id": "WnOXRacP1fbB"+ },+ "outputs": [],"source": ["task = Task(\n"," content=\"Evaluate the hackathon project. First, do some research on \"\n",@@ -478,31 +469,22 @@" additional_info=proj_content,\n"," id=\"0\",\n",")"- ],- "metadata": {- "id": "WnOXRacP1fbB"- },- "execution_count": 7,- "outputs": []+ ]},{"cell_type": "markdown",+ "metadata": {+ "id": "HQx4rRNu3CbA"+ },"source": ["## Run the Task\n","\n","Finally, run the task with `process_task()` function. You can see the whole process being shown in the console, and at last the final result of the task will be printed."- ],- "metadata": {- "id": "HQx4rRNu3CbA"- }+ ]},{"cell_type": "code",- "source": [- "task = workforce.process_task(task)\n",- "\n",- "print(task.result)"- ],+ "execution_count": 8,"metadata": {"colab": {"base_uri": "https://localhost:8080/"@@ -510,17 +492,16 @@"id": "DJOiPHFO1qeG","outputId": "e76d50c7-397f-48d0-c1f3-4e12a105fa63"},- "execution_count": 8,"outputs": [{- "output_type": "stream","name": "stdout",+ "output_type": "stream","text": [- "\u001B[33mWorker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.) get task 0.0: Research the latest innovations and trends related to AI and adaptive learning systems. This will be done by Researcher Rachel using online searches.\u001B[39m\n",+ "\u001b[33mWorker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.) get task 0.0: Research the latest innovations and trends related to AI and adaptive learning systems. This will be done by Researcher Rachel using online searches.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.):\u001b[39m\n","\n",- "\u001B[32mThe latest innovations and trends in AI and adaptive learning systems include several key developments:\n",+ "\u001b[32mThe latest innovations and trends in AI and adaptive learning systems include several key developments:\n","\n","1. **AI-Enabled Adaptive Learning Systems**: These systems leverage AI to create personalized learning experiences by tracking student progress, engagement, and performance. They use this data to adjust the learning material to meet individual needs. (Source: ScienceDirect)\n","\n",@@ -528,24 +509,24 @@"\n","3. **EdTech Innovations**: Over the past twenty years, the EdTech industry has seen significant advancements in AI applications. These include the development of individual adaptive learning systems and new educational platforms that integrate AI to enhance learning outcomes. (Source: ScienceDirect)\n","\n",- "These innovations are transforming the educational landscape by providing more personalized and effective learning experiences, addressing the diverse needs of students, and improving overall engagement and understanding.\u001B[39m\n",+ "These innovations are transforming the educational landscape by providing more personalized and effective learning experiences, addressing the diverse needs of students, and improving overall engagement and understanding.\u001b[39m\n","======\n","\n",- "\u001B[33mWorker node 137603052236144 (Visionary Veronica (Judge), a venture capitalist who is obsessed with how projects can be scaled into \"unicorn\" companies) get task 0.1: Evaluate the CAMEL-Powered Adaptive Learning Assistant project based on scalability and potential to become a \"unicorn\" company. This will be done by Visionary Veronica.\u001B[39m\n",+ "\u001b[33mWorker node 137603052236144 (Visionary Veronica (Judge), a venture capitalist who is obsessed with how projects can be scaled into \"unicorn\" companies) get task 0.1: Evaluate the CAMEL-Powered Adaptive Learning Assistant project based on scalability and potential to become a \"unicorn\" company. This will be done by Visionary Veronica.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137603052236144 (Visionary Veronica (Judge), a venture capitalist who is obsessed with how projects can be scaled into \"unicorn\" companies):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137603052236144 (Visionary Veronica (Judge), a venture capitalist who is obsessed with how projects can be scaled into \"unicorn\" companies):\u001b[39m\n","\n",- "\u001B[32mThe CAMEL-Powered Adaptive Learning Assistant project is a highly disruptive and synergistic solution in the EdTech space. It directly addresses the significant real-world problem of personalized education, which is crucial in today's diverse and fast-paced learning environment. By leveraging CAMEL-AI's advanced capabilities, the project has the potential to create a scalable and highly adaptive intelligent tutoring system. The project's focus on real-time adaptability and personalized learning experiences positions it well for substantial market penetration and growth. Given the current progress and the clear roadmap for further development, this project shows strong potential to become a unicorn company.\n",+ "\u001b[32mThe CAMEL-Powered Adaptive Learning Assistant project is a highly disruptive and synergistic solution in the EdTech space. It directly addresses the significant real-world problem of personalized education, which is crucial in today's diverse and fast-paced learning environment. By leveraging CAMEL-AI's advanced capabilities, the project has the potential to create a scalable and highly adaptive intelligent tutoring system. The project's focus on real-time adaptability and personalized learning experiences positions it well for substantial market penetration and growth. Given the current progress and the clear roadmap for further development, this project shows strong potential to become a unicorn company.\n","\n","### Applicability to Real-World Usage: 4/4\n",- "The project directly addresses a significant real-world problem with a clear, scalable application.\u001B[39m\n",+ "The project directly addresses a significant real-world problem with a clear, scalable application.\u001b[39m\n","======\n","\n",- "\u001B[33mWorker node 137602953811072 (Critical John (Judge), an experienced engineer and a perfectionist.) get task 0.2: Assess the technical aspects of the project, focusing on the implementation of the Learner Profile Analysis and Dynamic Content Generation modules. This will be done by Critical John.\u001B[39m\n",+ "\u001b[33mWorker node 137602953811072 (Critical John (Judge), an experienced engineer and a perfectionist.) get task 0.2: Assess the technical aspects of the project, focusing on the implementation of the Learner Profile Analysis and Dynamic Content Generation modules. This will be done by Critical John.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137602953811072 (Critical John (Judge), an experienced engineer and a perfectionist.):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137602953811072 (Critical John (Judge), an experienced engineer and a perfectionist.):\u001b[39m\n","\n",- "\u001B[32mUpon evaluating the technical aspects of the CAMEL-Powered Adaptive Learning Assistant project, specifically the Learner Profile Analysis and Dynamic Content Generation modules, several observations can be made:\n",+ "\u001b[32mUpon evaluating the technical aspects of the CAMEL-Powered Adaptive Learning Assistant project, specifically the Learner Profile Analysis and Dynamic Content Generation modules, several observations can be made:\n","\n","1. **Learner Profile Analysis**: This module employs natural language processing (NLP) to assess the student's current knowledge, learning preferences, and goals. While the concept is sound, the implementation details are crucial. The effectiveness of this module hinges on the accuracy and efficiency of the NLP algorithms used. Any inefficiencies or inaccuracies in parsing and understanding student input could lead to suboptimal personalization. Additionally, the system's ability to handle diverse linguistic inputs and learning styles must be rigorously tested. As it stands, without detailed performance metrics and stress test results, it's challenging to fully endorse its robustness.\n","\n",@@ -554,14 +535,14 @@"### **Technical Implementation (2/4)**\n","- The project demonstrates a working implementation of the Learner Profile Analysis and Dynamic Content Generation modules. However, there are notable concerns regarding the efficiency, accuracy, and robustness of these components. Detailed performance metrics, stress test results, and further validation are necessary to ensure the system's reliability and scalability.\n","\n",- "In summary, while the project shows promise, it requires significant refinement and validation to meet the high standards expected for deployment in a mission-critical educational environment.\u001B[39m\n",+ "In summary, while the project shows promise, it requires significant refinement and validation to meet the high standards expected for deployment in a mission-critical educational environment.\u001b[39m\n","======\n","\n",- "\u001B[33mWorker node 137602953811936 (Innovator Iris (Judge), a well-known AI startup founder who is always looking for the \"next big thing\" in AI.) get task 0.3: Provide insights on the innovative aspects of the project and its potential impact on the AI landscape. This will be done by Innovator Iris.\u001B[39m\n",+ "\u001b[33mWorker node 137602953811936 (Innovator Iris (Judge), a well-known AI startup founder who is always looking for the \"next big thing\" in AI.) get task 0.3: Provide insights on the innovative aspects of the project and its potential impact on the AI landscape. This will be done by Innovator Iris.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137602953811936 (Innovator Iris (Judge), a well-known AI startup founder who is always looking for the \"next big thing\" in AI.):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137602953811936 (Innovator Iris (Judge), a well-known AI startup founder who is always looking for the \"next big thing\" in AI.):\u001b[39m\n","\n",- "\u001B[32mThe CAMEL-Powered Adaptive Learning Assistant project stands out in the AI landscape due to its innovative approach to personalized education. Here are the key innovative aspects and their potential impact:\n",+ "\u001b[32mThe CAMEL-Powered Adaptive Learning Assistant project stands out in the AI landscape due to its innovative approach to personalized education. Here are the key innovative aspects and their potential impact:\n","\n","1. **Real-Time Adaptability**: The project leverages CAMEL-AI's advanced capabilities to create a highly adaptive learning environment. This real-time adaptability ensures that the educational content is continuously tailored to meet the unique needs of each student. This is a significant departure from traditional static learning systems and has the potential to revolutionize personalized education.\n","\n",@@ -574,24 +555,24 @@"### **Innovation (4/4)**\n","The CAMEL-Powered Adaptive Learning Assistant project showcases a groundbreaking concept with its real-time adaptability, dynamic content generation, and multi-modal integration. These innovative aspects have the potential to significantly impact the AI landscape and set new standards in personalized education.\n","\n",- "In summary, the CAMEL-Powered Adaptive Learning Assistant project is a highly innovative solution that addresses the critical challenge of personalized education. Its unique approach and advanced capabilities position it as a potential game-changer in the EdTech industry.\u001B[39m\n",+ "In summary, the CAMEL-Powered Adaptive Learning Assistant project is a highly innovative solution that addresses the critical challenge of personalized education. Its unique approach and advanced capabilities position it as a potential game-changer in the EdTech industry.\u001b[39m\n","======\n","\n",- "\u001B[33mWorker node 137602953817504 (Friendly Frankie (Judge), a contributor to the CAMEL-AI project and is always excited to see how people are using it.) get task 0.4: Share feedback and opinions on the project from a contributor's perspective, highlighting the use of CAMEL-AI. This will be done by Friendly Frankie.\u001B[39m\n",+ "\u001b[33mWorker node 137602953817504 (Friendly Frankie (Judge), a contributor to the CAMEL-AI project and is always excited to see how people are using it.) get task 0.4: Share feedback and opinions on the project from a contributor's perspective, highlighting the use of CAMEL-AI. This will be done by Friendly Frankie.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137602953817504 (Friendly Frankie (Judge), a contributor to the CAMEL-AI project and is always excited to see how people are using it.):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137602953817504 (Friendly Frankie (Judge), a contributor to the CAMEL-AI project and is always excited to see how people are using it.):\u001b[39m\n","\n",- "\u001B[32mOh, I love how you have implemented CAMEL-AI here! The use of its adaptive learning capabilities is fantastic, and you have really leveraged the contextual reasoning in a great way! The CAMEL-Powered Adaptive Learning Assistant project is a brilliant example of how AI can transform personalized education. The Learner Profile Analysis and Dynamic Content Generation modules are particularly impressive, showcasing a thoughtful application of CAMEL-AI's natural language processing and real-time adaptability. The innovative aspects like the Adaptive Feedback Loop and Multi-Modal Integration, even in their developmental stages, highlight the project's potential to set new standards in the EdTech industry. Keep up the great work, and I can't wait to see how you continue to refine and expand this project! \n",+ "\u001b[32mOh, I love how you have implemented CAMEL-AI here! The use of its adaptive learning capabilities is fantastic, and you have really leveraged the contextual reasoning in a great way! The CAMEL-Powered Adaptive Learning Assistant project is a brilliant example of how AI can transform personalized education. The Learner Profile Analysis and Dynamic Content Generation modules are particularly impressive, showcasing a thoughtful application of CAMEL-AI's natural language processing and real-time adaptability. The innovative aspects like the Adaptive Feedback Loop and Multi-Modal Integration, even in their developmental stages, highlight the project's potential to set new standards in the EdTech industry. Keep up the great work, and I can't wait to see how you continue to refine and expand this project! \n","\n","### **Use of CAMEL-AI: 4/4**\n",- "- Excellent integration of CAMEL-AI, fully leveraging its advanced features like in-context learning, adaptability, and multi-domain applications.\u001B[39m\n",+ "- Excellent integration of CAMEL-AI, fully leveraging its advanced features like in-context learning, adaptability, and multi-domain applications.\u001b[39m\n","======\n","\n",- "\u001B[33mWorker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.) get task 0.5: Compile the scores and opinions from each judge, preserving their unique identities, and create a final summary of the evaluations. This will be done by a designated organizer or helper.\u001B[39m\n",+ "\u001b[33mWorker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.) get task 0.5: Compile the scores and opinions from each judge, preserving their unique identities, and create a final summary of the evaluations. This will be done by a designated organizer or helper.\u001b[39m\n","======\n",- "\u001B[32mReply from Worker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.):\u001B[39m\n",+ "\u001b[32mReply from Worker node 137602953814384 (Researcher Rachel (Helper), a researcher who does online searches tofind the latest innovations and trends on AI and Open Sourced projects.):\u001b[39m\n","\n",- "\u001B[32m### Final Summary of Evaluations for CAMEL-Powered Adaptive Learning Assistant\n",+ "\u001b[32m### Final Summary of Evaluations for CAMEL-Powered Adaptive Learning Assistant\n","\n","#### Visionary Veronica\n","- **Scalability and Unicorn Potential**: The project is highly disruptive and addresses a significant real-world problem. It has strong potential to become a unicorn company due to its focus on real-time adaptability and personalized learning experiences.\n",@@ -612,7 +593,7 @@"### Overall Summary\n","The CAMEL-Powered Adaptive Learning Assistant project is a highly promising and innovative solution in the EdTech space. While it shows strong potential for scalability and significant market impact, it requires further refinement in its technical implementation to ensure robustness and reliability. The project's innovative approach and excellent use of CAMEL-AI position it as a potential game-changer in personalized education.\n","\n",- "**Overall Score**: 3.5/4\u001B[39m\n",+ "**Overall Score**: 3.5/4\u001b[39m\n","======\n","\n","### Final Evaluation of the CAMEL-Powered Adaptive Learning Assistant\n",@@ -641,11 +622,16 @@"**Overall Score**: 3.5/4\n"]}+ ],+ "source": [+ "task = workforce.process_task(task)\n",+ "\n",+ "print(task.result)"]},{- "metadata": {},"cell_type": "markdown",+ "metadata": {},"source": ["## 🌟 Highlights\n","\n",@@ -663,5 +649,20 @@"this project and motivate us to continue improving it."]}- ]+ ],+ "metadata": {+ "colab": {+ "provenance": []+ },+ "kernelspec": {+ "display_name": "Python 3 (ipykernel)",+ "language": "python",+ "name": "python3"+ },+ "language_info": {+ "name": "python"+ }+ },+ "nbformat": 4,+ "nbformat_minor": 0}diff --git a/docs/key_modules/embeddings.md b/docs/key_modules/embeddings.mdindex 091258260..37b44fd7d 100644--- a/docs/key_modules/embeddings.md+++ b/docs/key_modules/embeddings.md@@ -14,7 +14,7 @@ Consider two sentences:Text embedding models would transform these sentences into two high-dimensional vector (*e.g.*, 1536 dimension if using `text-embedding-3-small`). Despite different wordings, the vectors will be similar, capturing the shared concept of a child playing a ball game outdoors. This transformation into vectors allows machines to understand and compare the semantic similarities between the context.-### 1.2. Image Embeddings (WIP)+### 1.2. Image EmbeddingsImage embeddings convert images into numerical vectors, capturing essential features like shapes, colors, textures, and spatial hierarchies. This transformation is typically performed by Convolutional Neural Networks (CNNs) or other advanced neural network architectures designed for image processing. The resulting embeddings can be used for tasks like image classification, similarity comparison, and retrieval.Suppose we have an image of a cat. An image embedding model would analyze the visual content (e.g., the shape of the ears, the pattern of the fur) and convert it into a vector. This vector encapsulates the essence of the image, allowing the model to recognize it as a cat and differentiate it from other images.@@ -23,15 +23,20 @@ Suppose we have an image of a cat. An image embedding model would analyze the vi## 2. Types### 2.1. `OpenAIEmbedding`-Utilizes OpenAI's models for generating text embeddings. This will requires OpenAI API Key.-### 2.2. `SentenceTransformerEncoder`+### 2.2. `MistralEmbedding`+Utilizes Mistral's models for generating text embeddings. This will requires Mistral API Key.++### 2.3. `SentenceTransformerEncoder`Utilizes open-source models from the Sentence Transformers library for generating text embeddings.+### 2.4. `VisionLanguageEmbedding`+Utilizes OpenAI's models for generating image embeddings. This will requires OpenAI API Key.+## 3. Get Started-To use the embedding functionalities, you need to import the necessary classes. There are two embedding classes available: `OpenAIEmbedding` and `SentenceTransformerEncoder`.+To use the embedding functionalities, you need to import the necessary classes.### 3.1. Using `OpenAIEmbedding````python@@ -45,7 +50,19 @@ openai_embedding = OpenAIEmbedding(model_type=EmbeddingModelType.TEXT_EMBEDDING_embeddings = openai_embedding.embed_list(["Hello, world!", "Another example"])```-### 3.2. Using `SentenceTransformerEncoder`+### 3.2. Using `MistralEmbedding`+```python+from camel.embeddings import MistralEmbedding+from camel.types import EmbeddingModelType++# Initialize the OpenAI embedding with a specific model+mistral_embedding = MistralEmbedding(model_type=EmbeddingModelType.MISTRAL_EMBED)++# Generate embeddings for a list of texts+embeddings = mistral_embedding.embed_list(["Hello, world!", "Another example"])+```++### 3.3. Using `SentenceTransformerEncoder````pythonfrom camel.embeddings import SentenceTransformerEncoder@@ -55,3 +72,16 @@ sentence_encoder = SentenceTransformerEncoder(model_name='intfloat/e5-large-v2')# Generate embeddings for a list of textsembeddings = sentence_encoder.embed_list(["Hello, world!", "Another example"])```++### 3.4. Using `VisionLanguageEmbedding`+```python+from camel.embeddings import VisionLanguageEmbedding++vlm_embedding = VisionLanguageEmbedding()++url = "http://images.cocodataset.org/val2017/000000039769.jpg"+image = Image.open(requests.get(url, stream=True).raw)+test_images = [image, image]++embeddings = vlm_embedding.embed_list(test_images)+```diff --git a/docs/key_modules/messages.md b/docs/key_modules/messages.mdindex 8024df39d..dddbadb1c 100644--- a/docs/key_modules/messages.md+++ b/docs/key_modules/messages.md@@ -4,6 +4,8 @@The `BaseMessage` class is the base class for message objects used in the CAMEL chat system. It is designed to provide a consistent structure for the messages in the system and allow for easy conversion between different message types.+All the codes are also available on colab notebook [here](https://colab.research.google.com/drive/1qyi4bnAbnYink-FKaAlJG9OipyEWXEsT?usp=sharing).+## 2. Get Started### 2.1 Creating a `BaseMessage` Instance@@ -15,6 +17,13 @@ To create a `BaseMessage` instance, you need to provide the following arguments:- `meta_dict`: An optional metadata dictionary for the message.- `content`: The content of the message.+Below are optional arguments you can pass:++- `video_bytes`: Optional bytes of a video associated with the message.+- `image_list`: Optional list of PIL Image objects associated with the message.+- `image_detail`: Detail level of the images associated with the message. Default is "auto".+- `video_detail`: Detail level of the videos associated with the message. Default is "low".+Here's an example of creating a `BaseMessage` instance:```python@@ -111,5 +120,39 @@ The `BaseMessage` class offers several methods:These methods allow you to convert a `BaseMessage` instance into different message types depending on your needs.-## 3. Conclusion+## 3. Give `BaseMessage` to `ChatAgent`+```python+from io import BytesIO++import requests+from PIL import Image++from camel.agents import ChatAgent+from camel.messages import BaseMessage+# URL of the image+url = "https://raw.githubusercontent.com/camel-ai/camel/master/misc/logo_light.png"+response = requests.get(url)+img = Image.open(BytesIO(response.content))++# Define system message+sys_msg = BaseMessage.make_assistant_message(+ role_name="Assistant",+ content="You are a helpful assistant.",+)++# Set agent+camel_agent = ChatAgent(system_message=sys_msg)++# Set user message+user_msg = BaseMessage.make_user_message(+ role_name="User", content="""what's in the image?""", image_list=[img]+)++# Get response information+response = camel_agent.step(user_msg)+print(response.msgs[0].content)+>>> The image features a logo for "CAMEL-AI." It includes a stylized purple camel graphic alongside the text "CAMEL-AI," which is also in purple. The design appears modern and is likely related to artificial intelligence.+```++## 4. ConclusionIn this session, we introduced the `BaseMessage` class and its conversion to different types of messages. These components play essential roles in the CAMEL chat system, facilitating the creation, management, and interpretation of messages with clarity.\ No newline at end of filediff --git a/docs/key_modules/models.md b/docs/key_modules/models.mdindex 148c3aa03..c2cdef988 100644--- a/docs/key_modules/models.md+++ b/docs/key_modules/models.md@@ -1,7 +1,9 @@# Models## 1. Concept-The model is the brain of the intelligent agent, responsible for processing all input and output data. By calling different models, the agent can execute operations such as text analysis, image recognition, or complex reasoning according to task requirements. CAMEL offers a range of standard and customizable interfaces, as well as seamless integrations with various components, to facilitate the development of applications with Large Language Models (LLMs). In this part, we will introduce models currently supported by CAMEL and the working principles and interaction methods with models. All the codes are also available on colab notebook [here](https://colab.research.google.com/drive/18hQLpte6WW2Ja3Yfj09NRiVY-6S2MFu7?usp=sharing).+The model is the brain of the intelligent agent, responsible for processing all input and output data. By calling different models, the agent can execute operations such as text analysis, image recognition, or complex reasoning according to task requirements. CAMEL offers a range of standard and customizable interfaces, as well as seamless integrations with various components, to facilitate the development of applications with Large Language Models (LLMs). In this part, we will introduce models currently supported by CAMEL and the working principles and interaction methods with models.++All the codes are also available on colab notebook [here](https://colab.research.google.com/drive/18hQLpte6WW2Ja3Yfj09NRiVY-6S2MFu7?usp=sharing).## 2. Supported Model Platforms@@ -72,10 +74,7 @@ model = ModelFactory.create()# Define an assitant message-system_msg = BaseMessage.make_assistant_message(- role_name="Assistant",- content="You are a helpful assistant.",-)+system_msg = "You are a helpful assistant."# Initialize the agentChatAgent(system_msg, model=model)@@ -105,7 +104,7 @@ In the current landscape, for those seeking highly stable content generation, Opollama pull llama3```-3. Create a `ModelFile` similar the one below in your project directory.+3. Create a `ModelFile` similar the one below in your project directory. (Optional)```FROM llama3@@ -120,7 +119,7 @@ PARAMETER stop ResultSYSTEM """ """```-4. Create a script to get the base model (llama3) and create a custom model using the `ModelFile` above. Save this as a `.sh` file:+4. Create a script to get the base model (llama3) and create a custom model using the `ModelFile` above. Save this as a `.sh` file: (Optional)```#!/bin/zsh@@ -147,19 +146,16 @@ from camel.types import ModelPlatformTypeollama_model = ModelFactory.create(model_platform=ModelPlatformType.OLLAMA,model_type="llama3",- url="http://localhost:11434/v1",+ url="http://localhost:11434/v1", # Optionalmodel_config_dict={"temperature": 0.4},)-assistant_sys_msg = BaseMessage.make_assistant_message(- role_name="Assistant",- content="You are a helpful assistant.",-)-agent = ChatAgent(assistant_sys_msg, model=ollama_model, token_limit=4096)+agent_sys_msg = "You are a helpful assistant."++agent = ChatAgent(agent_sys_msg, model=ollama_model, token_limit=4096)++user_msg = "Say hi to CAMEL"-user_msg = BaseMessage.make_user_message(- role_name="User", content="Say hi to CAMEL"-)assistant_response = agent.step(user_msg)print(assistant_response.msg.content)```@@ -185,21 +181,16 @@ from camel.types import ModelPlatformTypevllm_model = ModelFactory.create(model_platform=ModelPlatformType.VLLM,model_type="microsoft/Phi-3-mini-4k-instruct",- url="http://localhost:8000/v1",- model_config_dict={"temperature": 0.0},- api_key="vllm",+ url="http://localhost:8000/v1", # Optional+ model_config_dict={"temperature": 0.0}, # Optional)-assistant_sys_msg = BaseMessage.make_assistant_message(- role_name="Assistant",- content="You are a helpful assistant.",-)-agent = ChatAgent(assistant_sys_msg, model=vllm_model, token_limit=4096)+agent_sys_msg = "You are a helpful assistant."++agent = ChatAgent(agent_sys_msg, model=vllm_model, token_limit=4096)++user_msg = "Say hi to CAMEL AI"-user_msg = BaseMessage.make_user_message(- role_name="User",- content="Say hi to CAMEL AI",-)assistant_response = agent.step(user_msg)print(assistant_response.msg.content)```diff --git a/docs/key_modules/retrievers.md b/docs/key_modules/retrievers.mdindex 04e17b8d8..d3ca3be3c 100644--- a/docs/key_modules/retrievers.md+++ b/docs/key_modules/retrievers.md@@ -13,11 +13,11 @@ Vector Retriever typically refers to a method or system used in information retrHere's a brief overview of how it works:-- Embedding Model: First, it uses an [embedding model](https://github.com/camel-ai/camel/wiki/Embeddings). This model turns text into a mathematical form (vectors).+- Embedding Model: First, it uses an embedding model. This model turns text into a mathematical form (vectors).-- 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).+- 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.-- 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.+- Retrieving Information: When we ask a question or make a query, the embedding model translates our question into vector and then searches in this vector storage for the closest matching vector. The closest matches are likely the most relevant pieces of information we are looking for.### 2.2. Keyword Retrieverdiff --git a/docs/key_modules/society.md b/docs/key_modules/society.mdindex c5db7f85a..92af01798 100644--- a/docs/key_modules/society.md+++ b/docs/key_modules/society.md@@ -62,7 +62,7 @@ When using `RolePlaying` framework in CAMEL, predefined prompts are used to crea| output_language | str | The language to be output by the agents. |## 2.2 `BabyAGI`-Babyagi is framework from "Task-driven Autonomous Agent" <https://github.com/yoheinakajima/babyagi>`+Babyagi is framework from "Task-driven Autonomous Agent" <https://github.com/yoheinakajima/babyagi>## 3. Get Starteddiff --git a/docs/key_modules/storages.md b/docs/key_modules/storages.mdindex bf202f30f..363e355ee 100644--- a/docs/key_modules/storages.md+++ b/docs/key_modules/storages.md@@ -4,7 +4,7 @@ The Storage module is a comprehensive framework designed for handling various ty## 2. Types-### 2.1. Key Value Storages+### 2.1 Key Value Storages**`BaseKeyValueStorage`**:- Purpose: Serves as the foundational abstract class for creating various key-value storage systems.@@ -29,7 +29,7 @@ The Storage module is a comprehensive framework designed for handling various ty- Functionality: Includes methods for saving data in JSON format, loading, and clearing data.-### 2.2. VectorDB Storages+### 2.2 VectorDB Storages**`BaseVectorStorage`**:- Purpose: An abstract base class designed to be extended for specific vector storage implementations.@@ -50,6 +50,25 @@ Reference: [Milvus](https://milvus.io/docs/overview.md/)Reference: [Qdrant](https://qdrant.tech/)+### 2.3 Graph Storages+**`BaseGraphStorage`**:++- Purpose: An abstract base class designed to be extended for specific graph storage implementations.++- Features: Supports various operations like `get_client`, `get_schema`, `get_structured_schema`, `refresh_schema`, `add_triplet`, `delete_triplet`, and `query`.++**`NebulaGraph`**:++- Description: A concrete implementation of `BaseGraphStorage`, tailored for interacting with NebulaGraph, an open source, distributed, scalable, lightning fast graph database.++Reference: [NebulaGraph](https://www.nebula-graph.io/)++**`Neo4jGraph`**:++- Description: A concrete implementation of `BaseGraphStorage`, tailored for interacting with Neo4jGraph, one of the most trusted graph databse.++Reference: [Neo4jGraph](https://neo4j.com/)+## 3. Get StartedTo get started with the storage module you've provided, you'll need to understand the basic usage of the key classes and their methods. The module includes an abstract base class `BaseKeyValueStorage` and its concrete implementations `InMemoryKeyValueStorage` and `JsonStorage`, as well as a vector storage system through `BaseVectorStorage` and its implementation `MilvusStorage` or `QdrantStorage`.@@ -164,3 +183,30 @@ qdrant_storage.clear()```markdown>>> {'key2': 'value2'} 0.5669467095138407```++### 3.5. Using `NebulaGraph`++```python+from camel.storages.graph_storages import NebulaGraph++nebula_graph = NebulaGraph("your_host", "your_username", "your_password", "your_space")++# Show existing tags+query = 'SHOW TAGS;'+print(nebula_graph.query(query))+```++### 3.5. Using `Neo4jGraph`++```python+from camel.storages import Neo4jGraph++neo4j_graph = Neo4jGraph(+ url="your_url",+ username="your_username",+ password="your_password",+)++query = "MATCH (n) DETACH DELETE n"+print(neo4j_graph.query(query))+```\ No newline at end of filediff --git a/docs/key_modules/tasks.md b/docs/key_modules/tasks.mdindex d4faecc12..a489f6099 100644--- a/docs/key_modules/tasks.md+++ b/docs/key_modules/tasks.md@@ -153,11 +153,9 @@ from camel.tasks import (Task,TaskManager,)-from camel.messages import BaseMessage-sys_msg = BaseMessage.make_assistant_message(- role_name="Assistant", content="You're a helpful assistant"-)+sys_msg = "You're a helpful assistant"+# Set up an agentagent = ChatAgent(system_message=sys_msg)diff --git a/docs/key_modules/tools.md b/docs/key_modules/tools.mdindex 264289b29..63daa7845 100644--- a/docs/key_modules/tools.md+++ b/docs/key_modules/tools.md@@ -124,6 +124,13 @@ Here is a list of the available CAMEL tools and their descriptions:| TwitterToolkit | A Twitter operation toolkit for creating a tweet, deleting a tweet, and getting the authenticated user's profile information. || WeatherToolkit | A weather data toolkit which provides methods for fetching weather data for a given city using the OpenWeatherMap API. || RetrievalToolkit | A information retrieval toolkit for retrieving information from a local vector storage system based on a specified query. |+| ArxivToolkit | A toolkit for interacting with the arXiv API to search and download academic papers. |+| AskNewsToolkit | A class representing a toolkit for interacting with the AskNews API. |+| DalleToolkit | A class representing a toolkit for image generation using OpenAI's DALL-E model. |+| GoogleScholarToolkit | A toolkit for retrieving information about authors and their publications from Google Scholar. |+| LinkedInToolkit | A class representing a toolkit for LinkedIn operations. |+| RedditToolkit | A class representing a toolkit for Reddit operations. |+| WhatsAppToolkit | A class representing a toolkit for WhatsApp operations. |## 3. Conclusiondiff --git a/misc/logo_dark.png b/misc/logo_dark.pngdeleted file mode 100644index bd162532e..000000000Binary files a/misc/logo_dark.png and /dev/null differ