Merge branch 'main' into docker_en

This commit is contained in:
yifeng.wang
2025-03-09 13:34:19 +08:00
17 changed files with 147 additions and 20 deletions

View File

@@ -64,7 +64,7 @@ Our vision is to revolutionize how AI agents collaborate to solve real-world tas
- [📋 Table of Contents](#-table-of-contents)
- [🔥 News](#-news)
- [🎬 Demo Video](#-demo-video)
- [✨️ Core Features](#-code-features)
- [✨️ Core Features](#-core-features)
- [🛠️ Installation](#-installation)
- [**Clone the Github repository**](#clone-the-github-repository)
- [**Set up Environment**](#set-up-environment)
@@ -139,7 +139,10 @@ playwright install
In the `owl/.env_template` 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
@@ -171,11 +174,18 @@ For more detailed Docker usage instructions, including cross-platform support, o
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
@@ -188,6 +198,21 @@ answer, chat_history, token_count = run_society(society)
logger.success(f"Answer: {answer}")
```
For uploading files, simply provide the file path along with your question:
```python
# Task with a local file (e.g., file path: `tmp/example.docx`)
question = "What is in the given DOCX file? Here is the file path: tmp/example.docx"
society = construct_society(question)
answer, chat_history, token_count = run_society(society)
logger.success(f"Answer: {answer}")
```
OWL will then automatically invoke document-related tools to process the file and extract the answer.
Example tasks you can try:
- "Find the latest stock price for Apple Inc."
- "Analyze the sentiment of recent tweets about climate change"

View File

@@ -165,13 +165,19 @@ docker-compose exec owl bash -c "xvfb-python run.py"
# 🚀 快速开始
运行以下最小示例:
运行以下示例:
```bash
python owl/run.py
```
你可以通过修改 `run.py` 来运行自定义任务的 OWL 智能体
我们还提供了一个最小化示例只需配置LLM的API密钥即可运行
```bash
python owl/run_mini.py
```
你可以通过修改 `run.py` 脚本来运行自己的任务:
```python
# Define your own task
@@ -183,11 +189,29 @@ answer, chat_history, token_count = run_society(society)
logger.success(f"Answer: {answer}")
```
上传文件时,只需提供文件路径和问题:
```python
# 处理本地文件(例如,文件路径为 `tmp/example.docx`
question = "给定的 DOCX 文件中有什么内容文件路径如下tmp/example.docx"
society = construct_society(question)
answer, chat_history, token_count = run_society(society)
logger.success(f"答案:{answer}")
```
OWL 将自动调用与文档相关的工具来处理文件并提取答案。
OWL 将自动调用与文档相关的工具来处理文件并提取答案。
你可以尝试以下示例任务:
- "查询苹果公司的最新股票价格"
- "分析关于气候变化的最新推文情绪"
- "帮我调试这段 Python 代码:[在此粘贴你的代码]"
- "总结这篇研究论文的主要观点:[论文URL]"
-
# 🧪 实验
我们提供了一个脚本用于复现 GAIA 上的实验结果。

View File

@@ -2,17 +2,23 @@ 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 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
@@ -25,13 +31,13 @@ def construct_society(question: str) -> OwlRolePlaying:
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
# 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
# model_config_dict=ChatGPTConfig(temperature=0, top_p=1).as_dict(), # [Optional] the config for model
)
tools_list = [

View File

@@ -3,13 +3,10 @@ from camel.toolkits import *
from camel.types import ModelPlatformType, ModelType
from camel.configs import DeepSeekConfig
from typing import List, Dict
from dotenv import load_dotenv
from retry import retry
from loguru import logger
from utils import OwlRolePlaying, run_society
import os
load_dotenv()

View File

@@ -5,11 +5,9 @@ from camel.configs import ChatGPTConfig
from utils import GAIABenchmark
from dotenv import load_dotenv
from retry import retry
from loguru import logger
import os
import shutil
load_dotenv()

77
owl/run_mini.py Normal file
View File

@@ -0,0 +1,77 @@
from dotenv import load_dotenv
load_dotenv()
from camel.models import ModelFactory
from camel.toolkits import (
WebToolkit,
SearchToolkit,
FunctionTool
)
from camel.types import ModelPlatformType, ModelType
from loguru import logger
from utils import OwlRolePlaying, run_society
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,
)
assistant_model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI,
model_type=ModelType.GPT_4O,
)
tools_list = [
*WebToolkit(
headless=False,
web_agent_model=assistant_model,
planning_agent_model=assistant_model
).get_tools(),
FunctionTool(SearchToolkit(model=assistant_model).search_duckduckgo),
]
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 Dragons Diet?` "
society = construct_society(question)
answer, chat_history, token_count = run_society(society)
logger.success(f"Answer: {answer}")

View File

@@ -26,7 +26,7 @@ def construct_society(question: str) -> OwlRolePlaying:
user_model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
model_type="qwq-32b",
model_type="qwen-max",
api_key=os.getenv("QWEN_API_KEY"),
url="https://dashscope.aliyuncs.com/compatible-mode/v1",
model_config_dict={"temperature": 0.4, "max_tokens": 4096},
@@ -34,7 +34,7 @@ def construct_society(question: str) -> OwlRolePlaying:
assistant_model = ModelFactory.create(
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
model_type="qwq-32b",
model_type="qwen-max",
api_key=os.getenv("QWEN_API_KEY"),
url="https://dashscope.aliyuncs.com/compatible-mode/v1",
model_config_dict={"temperature": 0.4, "max_tokens": 4096},
@@ -79,7 +79,7 @@ def construct_society(question: str) -> OwlRolePlaying:
# 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 Dragons Diet?` "
question = "what is the weather in beijing today?"
society = construct_society(question)
answer, chat_history, token_count = run_society(society)