mirror of
https://github.com/camel-ai/owl.git
synced 2026-03-22 05:57:17 +08:00
support gemini 2.5 pro and add example
This commit is contained in:
@@ -126,6 +126,7 @@ Our vision is to revolutionize how AI agents collaborate to solve real-world tas
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
- **[2025.03.26]**: Supported Gemini 2.5 Pro, added example run code
|
||||||
- **[2025.03.21]**: Integrated OpenRouter model platform, fix bug with Gemini tool calling
|
- **[2025.03.21]**: Integrated OpenRouter model platform, fix bug with Gemini tool calling
|
||||||
- **[2025.03.20]**: Accept header in MCP Toolkit, support automatic playwright installation
|
- **[2025.03.20]**: Accept header in MCP Toolkit, support automatic playwright installation
|
||||||
- **[2025.03.16]**: Support Bing search, Baidu search
|
- **[2025.03.16]**: Support Bing search, Baidu search
|
||||||
@@ -383,6 +384,9 @@ python examples/run_deepseek_zh.py
|
|||||||
# Run with other OpenAI-compatible models
|
# Run with other OpenAI-compatible models
|
||||||
python examples/run_openai_compatible_model.py
|
python examples/run_openai_compatible_model.py
|
||||||
|
|
||||||
|
# Run with Gemini model
|
||||||
|
python examples/run_gemini.py
|
||||||
|
|
||||||
# Run with Azure OpenAI
|
# Run with Azure OpenAI
|
||||||
python examples/run_azure_openai.py
|
python examples/run_azure_openai.py
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
- **[2025.03.26]**: 支持Gemini 2.5 Pro模型,添加示例运行代码
|
||||||
- **[2025.03.21]**: 集成OpenRouter模型平台,修复Gemini工具调用的bug
|
- **[2025.03.21]**: 集成OpenRouter模型平台,修复Gemini工具调用的bug
|
||||||
- **[2025.03.20]**: 在MCP工具包中添加Accept头部,支持自动安装playwright
|
- **[2025.03.20]**: 在MCP工具包中添加Accept头部,支持自动安装playwright
|
||||||
- **[2025.03.16]**: 支持必应搜索、百度搜索
|
- **[2025.03.16]**: 支持必应搜索、百度搜索
|
||||||
@@ -379,6 +380,9 @@ python examples/run_qwen_zh.py
|
|||||||
# 使用 Deepseek 模型运行
|
# 使用 Deepseek 模型运行
|
||||||
python examples/run_deepseek_zh.py
|
python examples/run_deepseek_zh.py
|
||||||
|
|
||||||
|
# 使用 Gemini 模型运行
|
||||||
|
python examples/run_gemini.py
|
||||||
|
|
||||||
# 使用其他 OpenAI 兼容模型运行
|
# 使用其他 OpenAI 兼容模型运行
|
||||||
python examples/run_openai_compatible_model.py
|
python examples/run_openai_compatible_model.py
|
||||||
|
|
||||||
|
|||||||
146
examples/run_gemini.py
Normal file
146
examples/run_gemini.py
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from camel.models import ModelFactory
|
||||||
|
from camel.toolkits import (
|
||||||
|
AudioAnalysisToolkit,
|
||||||
|
CodeExecutionToolkit,
|
||||||
|
ExcelToolkit,
|
||||||
|
ImageAnalysisToolkit,
|
||||||
|
SearchToolkit,
|
||||||
|
VideoAnalysisToolkit,
|
||||||
|
BrowserToolkit,
|
||||||
|
FileWriteToolkit,
|
||||||
|
)
|
||||||
|
from camel.types import ModelPlatformType, ModelType
|
||||||
|
from camel.logger import set_log_level
|
||||||
|
from camel.societies import RolePlaying
|
||||||
|
|
||||||
|
from owl.utils import run_society, DocumentProcessingToolkit
|
||||||
|
|
||||||
|
base_dir = pathlib.Path(__file__).parent.parent
|
||||||
|
env_path = base_dir / "owl" / ".env"
|
||||||
|
load_dotenv(dotenv_path=str(env_path))
|
||||||
|
|
||||||
|
set_log_level(level="DEBUG")
|
||||||
|
|
||||||
|
|
||||||
|
def construct_society(question: str) -> RolePlaying:
|
||||||
|
r"""Construct a society of agents based on the given question.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
question (str): The task or question to be addressed by the society.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
RolePlaying: A configured society of agents ready to address the question.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Create models for different components
|
||||||
|
models = {
|
||||||
|
"user": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"assistant": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"browsing": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"planning": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"video": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"image": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
"document": ModelFactory.create(
|
||||||
|
model_platform=ModelPlatformType.GEMINI,
|
||||||
|
model_type=ModelType.GEMINI_2_5_PRO_EXP,
|
||||||
|
model_config_dict={"temperature": 0},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Configure toolkits
|
||||||
|
tools = [
|
||||||
|
*BrowserToolkit(
|
||||||
|
headless=False, # Set to True for headless mode (e.g., on remote servers)
|
||||||
|
web_agent_model=models["browsing"],
|
||||||
|
planning_agent_model=models["planning"],
|
||||||
|
).get_tools(),
|
||||||
|
*CodeExecutionToolkit(sandbox="subprocess", verbose=True).get_tools(),
|
||||||
|
*ImageAnalysisToolkit(model=models["image"]).get_tools(),
|
||||||
|
SearchToolkit().search_duckduckgo,
|
||||||
|
SearchToolkit().search_google, # Comment this out if you don't have google search
|
||||||
|
SearchToolkit().search_wiki,
|
||||||
|
*ExcelToolkit().get_tools(),
|
||||||
|
*DocumentProcessingToolkit(model=models["document"]).get_tools(),
|
||||||
|
*FileWriteToolkit(output_dir="./").get_tools(),
|
||||||
|
]
|
||||||
|
|
||||||
|
# Configure agent roles and parameters
|
||||||
|
user_agent_kwargs = {"model": models["user"]}
|
||||||
|
assistant_agent_kwargs = {"model": models["assistant"], "tools": tools}
|
||||||
|
|
||||||
|
# Configure task parameters
|
||||||
|
task_kwargs = {
|
||||||
|
"task_prompt": question,
|
||||||
|
"with_task_specify": False,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create and return the society
|
||||||
|
society = RolePlaying(
|
||||||
|
**task_kwargs,
|
||||||
|
user_role_name="user",
|
||||||
|
user_agent_kwargs=user_agent_kwargs,
|
||||||
|
assistant_role_name="assistant",
|
||||||
|
assistant_agent_kwargs=assistant_agent_kwargs,
|
||||||
|
)
|
||||||
|
|
||||||
|
return society
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
r"""Main function to run the OWL system with an example question."""
|
||||||
|
# Default research question
|
||||||
|
default_task = "Navigate to Amazon.com and identify one product that is attractive to coders. Please provide me with the product name and price. No need to verify your answer."
|
||||||
|
|
||||||
|
# Override default task if command line argument is provided
|
||||||
|
task = sys.argv[1] if len(sys.argv) > 1 else default_task
|
||||||
|
|
||||||
|
# Construct and run the society
|
||||||
|
society = construct_society(task)
|
||||||
|
answer, chat_history, token_count = run_society(society)
|
||||||
|
|
||||||
|
# Output the result
|
||||||
|
print(f"\033[94mAnswer: {answer}\033[0m")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -244,6 +244,7 @@ def get_latest_logs(max_lines=100, queue_source=None):
|
|||||||
MODULE_DESCRIPTIONS = {
|
MODULE_DESCRIPTIONS = {
|
||||||
"run": "Default mode: Using OpenAI model's default agent collaboration mode, suitable for most tasks.",
|
"run": "Default mode: Using OpenAI model's default agent collaboration mode, suitable for most tasks.",
|
||||||
"run_mini": "Using OpenAI model with minimal configuration to process tasks",
|
"run_mini": "Using OpenAI model with minimal configuration to process tasks",
|
||||||
|
"run_gemini": "Using Gemini model to process tasks",
|
||||||
"run_deepseek_zh": "Using deepseek model to process Chinese tasks",
|
"run_deepseek_zh": "Using deepseek model to process Chinese tasks",
|
||||||
"run_openai_compatible_model": "Using openai compatible model to process tasks",
|
"run_openai_compatible_model": "Using openai compatible model to process tasks",
|
||||||
"run_ollama": "Using local ollama model to process tasks",
|
"run_ollama": "Using local ollama model to process tasks",
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ def get_latest_logs(max_lines=100, queue_source=None):
|
|||||||
MODULE_DESCRIPTIONS = {
|
MODULE_DESCRIPTIONS = {
|
||||||
"run": "默认模式:使用OpenAI模型的默认的智能体协作模式,适合大多数任务。",
|
"run": "默认模式:使用OpenAI模型的默认的智能体协作模式,适合大多数任务。",
|
||||||
"run_mini": "使用使用OpenAI模型最小化配置处理任务",
|
"run_mini": "使用使用OpenAI模型最小化配置处理任务",
|
||||||
|
"run_gemini": "使用 Gemini模型处理任务",
|
||||||
"run_deepseek_zh": "使用deepseek模型处理中文任务",
|
"run_deepseek_zh": "使用deepseek模型处理中文任务",
|
||||||
"run_openai_compatible_model": "使用openai兼容模型处理任务",
|
"run_openai_compatible_model": "使用openai兼容模型处理任务",
|
||||||
"run_ollama": "使用本地ollama模型处理任务",
|
"run_ollama": "使用本地ollama模型处理任务",
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ keywords = [
|
|||||||
"learning-systems"
|
"learning-systems"
|
||||||
]
|
]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"camel-ai[all]==0.2.36",
|
"camel-ai[all]==0.2.37",
|
||||||
"chunkr-ai>=0.0.41",
|
"chunkr-ai>=0.0.41",
|
||||||
"docx2markdown>=0.1.1",
|
"docx2markdown>=0.1.1",
|
||||||
"gradio>=3.50.2",
|
"gradio>=3.50.2",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
camel-ai[all]==0.2.36
|
camel-ai[all]==0.2.37
|
||||||
chunkr-ai>=0.0.41
|
chunkr-ai>=0.0.41
|
||||||
docx2markdown>=0.1.1
|
docx2markdown>=0.1.1
|
||||||
gradio>=3.50.2
|
gradio>=3.50.2
|
||||||
|
|||||||
8
uv.lock
generated
8
uv.lock
generated
@@ -506,7 +506,7 @@ wheels = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "camel-ai"
|
name = "camel-ai"
|
||||||
version = "0.2.36"
|
version = "0.2.37"
|
||||||
source = { registry = "https://pypi.org/simple" }
|
source = { registry = "https://pypi.org/simple" }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "colorama" },
|
{ name = "colorama" },
|
||||||
@@ -520,9 +520,9 @@ dependencies = [
|
|||||||
{ name = "pyyaml" },
|
{ name = "pyyaml" },
|
||||||
{ name = "tiktoken" },
|
{ name = "tiktoken" },
|
||||||
]
|
]
|
||||||
sdist = { url = "https://files.pythonhosted.org/packages/d8/f3/8aa260535ed202a153553fab715b4640b261577eaf82b0e6b693db5258d6/camel_ai-0.2.36.tar.gz", hash = "sha256:4de90328a6e5128efde2a50d58bc04d33e6206ba0e4628aac0ec0412dec8ddc3", size = 454587 }
|
sdist = { url = "https://files.pythonhosted.org/packages/c0/05/1158464a89c0fde62fd916385a6f245c0864036fc575967f0eb8c97ef409/camel_ai-0.2.37.tar.gz", hash = "sha256:4196228846182dc5f0848e7db932f617a744ffeeee939251a1b09cb7d4f9c24a", size = 463910 }
|
||||||
wheels = [
|
wheels = [
|
||||||
{ url = "https://files.pythonhosted.org/packages/94/56/7a774ecdf52e590d97c229daf367f3223ef58bbbabfcfe29df8559f6bace/camel_ai-0.2.36-py3-none-any.whl", hash = "sha256:94a8c419608e3d12653c7ecafb99f1c60430ba37cdf4d0fae970bdd99f392557", size = 774724 },
|
{ url = "https://files.pythonhosted.org/packages/d0/36/926b8b826faf694695b46e0c257f1b33f743802dea77fb5a33b78050f4d0/camel_ai-0.2.37-py3-none-any.whl", hash = "sha256:d1e7bb5ec992baa84a0fa825814e61d67e795ce547058b50eb5c4090300f09df", size = 785083 },
|
||||||
]
|
]
|
||||||
|
|
||||||
[package.optional-dependencies]
|
[package.optional-dependencies]
|
||||||
@@ -3654,7 +3654,7 @@ dependencies = [
|
|||||||
|
|
||||||
[package.metadata]
|
[package.metadata]
|
||||||
requires-dist = [
|
requires-dist = [
|
||||||
{ name = "camel-ai", extras = ["all"], specifier = "==0.2.36" },
|
{ name = "camel-ai", extras = ["all"], specifier = "==0.2.37" },
|
||||||
{ name = "chunkr-ai", specifier = ">=0.0.41" },
|
{ name = "chunkr-ai", specifier = ">=0.0.41" },
|
||||||
{ name = "docx2markdown", specifier = ">=0.1.1" },
|
{ name = "docx2markdown", specifier = ">=0.1.1" },
|
||||||
{ name = "gradio", specifier = ">=3.50.2" },
|
{ name = "gradio", specifier = ">=3.50.2" },
|
||||||
|
|||||||
Reference in New Issue
Block a user