From 22361b31847dfe20b534c6b899a78d265868bf87 Mon Sep 17 00:00:00 2001 From: lazychih114 <55657767+Aaron617@users.noreply.github.com> Date: Sat, 8 Mar 2025 23:52:52 +0800 Subject: [PATCH 1/3] remove * --- owl/run.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/owl/run.py b/owl/run.py index 9455c1a..6aea767 100644 --- a/owl/run.py +++ b/owl/run.py @@ -2,7 +2,16 @@ from dotenv import load_dotenv load_dotenv() from camel.models import ModelFactory -from camel.toolkits import * +from camel.toolkits import ( + WebToolkit, + DocumentProcessingToolkit, + VideoAnalysisToolkit, + AudioAnalysisToolkit, + CodeExecutionToolkit, + ImageAnalysisToolkit, + SearchToolkit, + ExcelToolkit + ) from camel.types import ModelPlatformType, ModelType from camel.configs import ChatGPTConfig From 9723cb799b34170c1e6781ce3520c25fb1352f37 Mon Sep 17 00:00:00 2001 From: lazychih114 <55657767+Aaron617@users.noreply.github.com> Date: Sun, 9 Mar 2025 00:33:45 +0800 Subject: [PATCH 2/3] Create run_mini.py --- owl/run_mini.py | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 owl/run_mini.py diff --git a/owl/run_mini.py b/owl/run_mini.py new file mode 100644 index 0000000..5045682 --- /dev/null +++ b/owl/run_mini.py @@ -0,0 +1,96 @@ +from dotenv import load_dotenv +load_dotenv() + +from camel.models import ModelFactory +from camel.toolkits import ( + WebToolkit, + DocumentProcessingToolkit, + VideoAnalysisToolkit, + AudioAnalysisToolkit, + CodeExecutionToolkit, + ImageAnalysisToolkit, + SearchToolkit, + ExcelToolkit, + FunctionTool + ) +from camel.types import ModelPlatformType, ModelType +from camel.configs import ChatGPTConfig + +from typing import List, Dict + +from retry import retry +from loguru import logger + +from utils import OwlRolePlaying, run_society +import os + + + + +def construct_society(question: str) -> OwlRolePlaying: + r"""Construct the society based on the question.""" + + user_role_name = "user" + assistant_role_name = "assistant" + + user_model = ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=ModelType.GPT_4O, + model_config_dict=ChatGPTConfig(temperature=0, top_p=1).as_dict(), # [Optional] the config for model + ) + + assistant_model = ModelFactory.create( + model_platform=ModelPlatformType.OPENAI, + model_type=ModelType.GPT_4O, + model_config_dict=ChatGPTConfig(temperature=0, top_p=1).as_dict(), # [Optional] the config for model + ) + + tools_list = [ + *WebToolkit( + headless=False, + web_agent_model=assistant_model, + planning_agent_model=assistant_model + ).get_tools(), + # *DocumentProcessingToolkit().get_tools(), + # *VideoAnalysisToolkit(model=assistant_model).get_tools(), # This requires OpenAI Key + # *AudioAnalysisToolkit().get_tools(), # This requires OpenAI Key + # *CodeExecutionToolkit().get_tools(), + # *ImageAnalysisToolkit(model=assistant_model).get_tools(), + FunctionTool(SearchToolkit(model=assistant_model).search_duckduckgo), + # *ExcelToolkit().get_tools() + ] + + user_role_name = 'user' + user_agent_kwargs = dict(model=user_model) + assistant_role_name = 'assistant' + assistant_agent_kwargs = dict(model=assistant_model, + tools=tools_list) + + task_kwargs = { + 'task_prompt': question, + 'with_task_specify': False, + } + + society = OwlRolePlaying( + **task_kwargs, + user_role_name=user_role_name, + user_agent_kwargs=user_agent_kwargs, + assistant_role_name=assistant_role_name, + assistant_agent_kwargs=assistant_agent_kwargs, + ) + + return society + + +# Example case +question = "What was the volume in m^3 of the fish bag that was calculated in the University of Leicester paper `Can Hiccup Supply Enough Fish to Maintain a Dragon’s Diet?` " + +society = construct_society(question) +answer, chat_history, token_count = run_society(society) + +logger.success(f"Answer: {answer}") + + + + + From b0d6d27d53e9d6fddc61ae8f7856ff29538da7c9 Mon Sep 17 00:00:00 2001 From: lazychih114 <55657767+Aaron617@users.noreply.github.com> Date: Sun, 9 Mar 2025 00:38:27 +0800 Subject: [PATCH 3/3] update readme --- README.md | 14 ++++++++++++-- README_zh.md | 10 ++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5ef257e..eaf87a1 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,10 @@ playwright install In the `owl/.env_example` file, you will find all the necessary API keys along with the websites where you can register for each service. To use these API services, follow these steps: 1. *Copy and Rename*: Duplicate the `.env_example` file and rename the copy to `.env`. -2. *Fill in Your Keys*: Open the `.env` file and insert your API keys in the corresponding fields. +```bash +cp owl/.env_template .env +``` +2. *Fill in Your Keys*: Open the `.env` file and insert your API keys in the corresponding fields. (For the minimal example (`run_mini.py`), you only need to configure the LLM API key (e.g., OPENAI_API_KEY).) 3. *For using more other models*: please refer to our CAMEL models docs:https://docs.camel-ai.org/key_modules/models.html#supported-model-platforms-in-camel @@ -137,11 +140,18 @@ In the `owl/.env_example` file, you will find all the necessary API keys along w # 🚀 Quick Start -Run the following minimal example: +Run the following demo case: ```bash python owl/run.py ``` + +For a simpler version that only requires an LLM API key, you can try our minimal example: + +```bash +python owl/run_mini.py +``` + You can run OWL agent with your own task by modifying the `run.py` script: ```python diff --git a/README_zh.md b/README_zh.md index 76dffae..cbb5ff2 100644 --- a/README_zh.md +++ b/README_zh.md @@ -133,13 +133,19 @@ python -m pip install -r requirements.txt # 🚀 快速开始 -运行以下最小示例: +运行以下示例: ```bash python owl/run.py ``` -你可以通过修改 `run.py` 来运行自定义任务的 OWL 智能体: +我们还提供了一个最小化示例,只需配置LLM的API密钥即可运行: + +```bash +python owl/run_mini.py +``` + +你可以通过修改 `run.py` 脚本来运行自己的任务: ```python # Define your own task