From e1c661b5f80856ba4f4c8dc30be030418328e6dc Mon Sep 17 00:00:00 2001 From: Wendong Date: Tue, 11 Mar 2025 16:34:49 +0800 Subject: [PATCH] update run_ollama --- README.md | 2 +- README_zh.md | 2 +- owl/.env_template | 5 +---- owl/app.py | 7 ------- owl/run_ollama.py | 36 ++++++++++++++++-------------------- 5 files changed, 19 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index bb7b4c0..bf16d66 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ python owl/run_deepseek_zh.py # Run with other OpenAI-compatible models python owl/run_openai_compatiable_model.py -# Run with Ollama API +# Run with Ollama python owl/run_ollama.py ``` diff --git a/README_zh.md b/README_zh.md index 35c6af4..390dcbf 100644 --- a/README_zh.md +++ b/README_zh.md @@ -247,7 +247,7 @@ python owl/run_deepseek_zh.py # 使用其他 OpenAI 兼容模型运行 python owl/run_openai_compatiable_model.py -# 使用 Ollama API 运行 +# 使用 Ollama 运行 python owl/run_ollama.py ``` diff --git a/owl/.env_template b/owl/.env_template index 0d4cc01..6d2fe7a 100644 --- a/owl/.env_template +++ b/owl/.env_template @@ -1,7 +1,4 @@ -# MODEL & API (See https://github.com/camel-ai/camel/blob/master/camel/types/enums.py) - -# Ollama API -OLLAMA_API_KEY="" +# MODEL & API (See https://docs.camel-ai.org/key_modules/models.html#) # OPENAI API OPENAI_API_KEY= "" diff --git a/owl/app.py b/owl/app.py index 7c8d31e..5b582a6 100644 --- a/owl/app.py +++ b/owl/app.py @@ -86,13 +86,6 @@ ENV_GROUPS = { "required": False, "help": "DeepSeek API密钥,用于访问DeepSeek模型。获取方式:https://platform.deepseek.com/api_keys", }, - { - "name": "OLLAMA_API_KEY", - "label": "Ollama API秘钥", - "type": "password", - "required": False, - "help": "Ollama API秘钥,没啥用的", - }, ], "搜索工具": [ { diff --git a/owl/run_ollama.py b/owl/run_ollama.py index ca0977c..5f45090 100644 --- a/owl/run_ollama.py +++ b/owl/run_ollama.py @@ -12,7 +12,6 @@ # limitations under the License. # ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. ========= # run_ollama.py by tj-scripts(https://github.com/tj-scripts) -import os from dotenv import load_dotenv from camel.models import ModelFactory @@ -22,6 +21,7 @@ from camel.toolkits import ( ImageAnalysisToolkit, SearchToolkit, WebToolkit, + FileWriteToolkit, ) from camel.types import ModelPlatformType @@ -47,39 +47,34 @@ def construct_society(question: str) -> OwlRolePlaying: # Create models for different components models = { "user": ModelFactory.create( - model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type="qwen2.5:3b", - api_key=os.getenv("OLLAMA_API_KEY"), + model_platform=ModelPlatformType.OLLAMA, + model_type="qwen2.5:72b", url="http://localhost:11434/v1", - model_config_dict={"temperature": 0.8, "max_tokens": 4096}, + model_config_dict={"temperature": 0.8, "max_tokens": 1000000}, ), "assistant": ModelFactory.create( - model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type="qwen2.5:3b", - api_key=os.getenv("OLLAMA_API_KEY"), + model_platform=ModelPlatformType.OLLAMA, + model_type="qwen2.5:72b", url="http://localhost:11434/v1", - model_config_dict={"temperature": 0.2, "max_tokens": 4096}, + model_config_dict={"temperature": 0.2, "max_tokens": 1000000}, ), "web": ModelFactory.create( - model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, + model_platform=ModelPlatformType.OLLAMA, model_type="llava:latest", - api_key=os.getenv("QWEN_API_KEY"), url="http://localhost:11434/v1", - model_config_dict={"temperature": 0.4, "max_tokens": 4096}, + model_config_dict={"temperature": 0.4, "max_tokens": 1000000}, ), "planning": ModelFactory.create( - model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type="qwen2.5:3b", - api_key=os.getenv("ollama"), + model_platform=ModelPlatformType.OLLAMA, + model_type="qwen2.5:72b", url="http://localhost:11434/v1", - model_config_dict={"temperature": 0.4, "max_tokens": 4096}, + model_config_dict={"temperature": 0.4, "max_tokens": 1000000}, ), "image": ModelFactory.create( - model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, + model_platform=ModelPlatformType.OLLAMA, model_type="llava:latest", - api_key=os.getenv("QWEN_API_KEY"), url="http://localhost:11434/v1", - model_config_dict={"temperature": 0.4, "max_tokens": 4096}, + model_config_dict={"temperature": 0.4, "max_tokens": 1000000}, ), } @@ -93,9 +88,10 @@ def construct_society(question: str) -> OwlRolePlaying: *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_google, # Comment this out if you don't have google search SearchToolkit().search_wiki, *ExcelToolkit().get_tools(), + *FileWriteToolkit(output_dir="./").get_tools(), ] # Configure agent roles and parameters