diff --git a/.gitignore b/.gitignore index 65999de..1496b4d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ venv/ env/ ENV/ .env -.venv # IDE .idea/ @@ -59,4 +58,3 @@ coverage.xml owl/camel/types/__pycache__/ owl/camel/__pycache__/ owl/camel/utils/__pycache_/ -tmp/ diff --git a/README.md b/README.md index cc94473..ed139c7 100644 --- a/README.md +++ b/README.md @@ -364,10 +364,8 @@ python examples/run_qwen_zh.py # Run with Deepseek model python examples/run_deepseek_zh.py -# Run with other OpenAI-compatible models, supporting different models for different roles +# Run with other OpenAI-compatible models python examples/run_openai_compatiable_model.py -# Example with question -python examples/run_openai_compatiable_model.py "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." # Run with Azure OpenAI python examples/run_azure_openai.py diff --git a/README_zh.md b/README_zh.md index 02005a1..7814e2f 100644 --- a/README_zh.md +++ b/README_zh.md @@ -363,10 +363,8 @@ python examples/run_qwen_zh.py # 使用 Deepseek 模型运行 python examples/run_deepseek_zh.py -# 使用其他 OpenAI 兼容模型运行,支持不同的 role 使用不同的模型 +# 使用其他 OpenAI 兼容模型运行 python examples/run_openai_compatiable_model.py -# 带问题的示例 -python examples/run_openai_compatiable_model.py "浏览京东并找出一款对程序员有吸引力的产品。请提供产品名称和价格。" # 使用 Azure OpenAI模型运行 python examples/run_azure_openai.py diff --git a/examples/run_openai_compatiable_model.py b/examples/run_openai_compatiable_model.py index cad8fbb..6a51449 100644 --- a/examples/run_openai_compatiable_model.py +++ b/examples/run_openai_compatiable_model.py @@ -53,56 +53,38 @@ def construct_society(question: str) -> RolePlaying: models = { "user": ModelFactory.create( model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - - model_type=os.getenv("USER_ROLE_API_MODEL_TYPE", os.getenv("LLM_ROLE_API_MODEL_TYPE", "qwen-max")), - api_key=os.getenv("USER_ROLE_API_KEY", os.getenv("LLM_ROLE_API_KEY", os.getenv("QWEN_API_KEY", "Your_Key"))), - url=os.getenv("USER_ROLE_API_BASE_URL", os.getenv("LLM_ROLE_API_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")), - model_config_dict={ - "temperature": float(os.getenv("USER_ROLE_API_MODEL_TEMPERATURE", os.getenv("LLM_ROLE_API_MODEL_TEMPERATURE", "0.4"))), - "max_tokens": int(os.getenv("USER_ROLE_API_MODEL_MAX_TOKENS", os.getenv("LLM_ROLE_API_MODEL_MAX_TOKENS", "4096"))) - }, + 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": 128000}, ), "assistant": ModelFactory.create( model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type=os.getenv("ASSISTANT_ROLE_API_MODEL_TYPE", os.getenv("LLM_ROLE_API_MODEL_TYPE", "qwen-max")), - api_key=os.getenv("ASSISTANT_ROLE_API_KEY", os.getenv("LLM_ROLE_API_KEY", os.getenv("QWEN_API_KEY", "Your_Key"))), - url=os.getenv("ASSISTANT_ROLE_API_BASE_URL", os.getenv("LLM_ROLE_API_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")), - model_config_dict={ - "temperature": float(os.getenv("ASSISTANT_ROLE_API_MODEL_TEMPERATURE", os.getenv("LLM_ROLE_API_MODEL_TEMPERATURE", "0.4"))), - "max_tokens": int(os.getenv("ASSISTANT_ROLE_API_MODEL_MAX_TOKENS", os.getenv("LLM_ROLE_API_MODEL_MAX_TOKENS", "4096"))) - }, - + 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": 128000}, ), "browsing": ModelFactory.create( model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - - model_type=os.getenv("WEB_ROLE_API_BASE_URL", os.getenv("VLLM_ROLE_API_MODEL_TYPE", "qwen-vl-max")), - api_key=os.getenv("WEB_ROLE_API_KEY", os.getenv("VLLM_ROLE_API_KEY", os.getenv("QWEN_API_KEY", "Your_Key"))), - url=os.getenv("USER_ROLE_API_BASE_URL", os.getenv("VLLM_ROLE_API_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")), - model_config_dict={ - "temperature": float(os.getenv("WEB_ROLE_API_MODEL_TEMPERATURE", os.getenv("VLLM_ROLE_API_MODEL_TEMPERATURE", "0.4"))), - "max_tokens": int(os.getenv("WEB_ROLE_API_MODEL_MAX_TOKENS", os.getenv("VLLM_ROLE_API_MODEL_MAX_TOKENS", "4096"))) - }, + model_type="qwen-vl-max", + api_key=os.getenv("QWEN_API_KEY"), + url="https://dashscope.aliyuncs.com/compatible-mode/v1", + model_config_dict={"temperature": 0.4, "max_tokens": 128000}, ), "planning": ModelFactory.create( model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type=os.getenv("PLANNING_ROLE_API_MODEL_TYPE", os.getenv("LLM_ROLE_API_MODEL_TYPE", "qwen-max")), - api_key=os.getenv("PLANNING_ROLE_API_KEY", os.getenv("LLM_ROLE_API_KEY", os.getenv("QWEN_API_KEY", "Your_Key"))), - url=os.getenv("PLANNING_ROLE_API_BASE_URL", os.getenv("LLM_ROLE_API_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")), - model_config_dict={ - "temperature": float(os.getenv("PLANNING_ROLE_API_MODEL_TEMPERATURE", os.getenv("LLM_ROLE_API_MODEL_TEMPERATURE", "0.4"))), - "max_tokens": int(os.getenv("PLANNING_ROLE_API_MODEL_MAX_TOKENS", os.getenv("LLM_ROLE_API_MODEL_MAX_TOKENS", "4096"))) - }, + 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": 128000}, ), "image": ModelFactory.create( model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL, - model_type=os.getenv("IMAGE_ROLE_API_MODEL_TYPE", os.getenv("VLLM_ROLE_API_MODEL_TYPE", "qwen-vl-max")), - api_key=os.getenv("IMAGE_ROLE_API_KEY", os.getenv("VLLM_ROLE_API_KEY", os.getenv("QWEN_API_KEY", "Your_Key"))), - url=os.getenv("IMAGE_ROLE_API_BASE_URL", os.getenv("VLLM_ROLE_API_BASE_URL", "https://dashscope.aliyuncs.com/compatible-mode/v1")), - model_config_dict={ - "temperature": float(os.getenv("IMAGE_ROLE_API_MODEL_TEMPERATURE", os.getenv("VLLM_ROLE_API_MODEL_TEMPERATURE", "0.4"))), - "max_tokens": int(os.getenv("IMAGE_ROLE_API_MODEL_MAX_TOKENS", os.getenv("VLLM_ROLE_API_MODEL_MAX_TOKENS", "4096"))) - }, + model_type="qwen-vl-max", + api_key=os.getenv("QWEN_API_KEY"), + url="https://dashscope.aliyuncs.com/compatible-mode/v1", + model_config_dict={"temperature": 0.4, "max_tokens": 128000}, ), } @@ -144,16 +126,13 @@ def construct_society(question: str) -> RolePlaying: return society +def main(): + r"""Main function to run the OWL system with an example question.""" + # Example 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." -def main(question: str = "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."): - r"""Main function to run the OWL system with an example question. - Args: - question (str): The task or question to be addressed by the society. - If not provided, a default question will be used. - Defaults to "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." - Returns: - None - """ + # 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) @@ -162,9 +141,7 @@ def main(question: str = "Navigate to Amazon.com and identify one product that i # Output the result print(f"\033[94mAnswer: {answer}\033[0m") - # Output the token count - print(f"\033[94mToken count: {token_count}\033[0m") if __name__ == "__main__": - main(sys.argv[1] if len(sys.argv) > 1 else "") + main() diff --git a/owl/.env_template b/owl/.env_template index 39cf958..0261124 100644 --- a/owl/.env_template +++ b/owl/.env_template @@ -24,45 +24,6 @@ QWEN_API_KEY='Your_Key' # DeepSeek API (https://platform.deepseek.com/api_keys) DEEPSEEK_API_KEY='Your_Key' -# Multi-platform LLM/VLLM API, default values for user assistant planning web image roles -# LLM_ROLE_API_BASE_URL='' -# LLM_ROLE_API_KEY='Your_Key' -# LLM_ROLE_API_MODEL_TYPE='' -# LLM_ROLE_API_MODEL_TEMPERATURE='0.0' -# LLM_ROLE_API_MODEL_MAX_TOKENS='0' -# VLLM_ROLE_API_BASE_URL='' -# VLLM_ROLE_API_KEY='Your_Key' -# VLLM_ROLE_API_MODEL_TYPE='' -# VLLM_ROLE_API_MODEL_TEMPERATURE='0.0' -# VLLM_ROLE_API_MODEL_MAX_TOKENS='0' - -# Multi-platform LLM/VLLM API for user assistant planning web image roles -# USER_ROLE_API_BASE_URL='' -# USER_ROLE_API_KEY='Your_Key' -# USER_ROLE_API_MODEL_TYPE='' -# USER_ROLE_API_MODEL_TEMPERATURE='0.8' -# USER_ROLE_API_MODEL_MAX_TOKENS='4096' -# ASSISTANT_ROLE_API_BASE_URL='' -# ASSISTANT_ROLE_API_KEY='Your_Key' -# ASSISTANT_ROLE_API_MODEL_TYPE='' -# ASSISTANT_ROLE_API_MODEL_TEMPERATURE='0.2' -# ASSISTANT_ROLE_API_MODEL_MAX_TOKENS='4096' -# PLANNING_ROLE_API_BASE_URL='' -# PLANNING_ROLE_API_KEY='Your_Key' -# PLANNING_ROLE_API_MODEL_TYPE='' -# PLANNING_ROLE_API_MODEL_TEMPERATURE='0.4' -# PLANNING_ROLE_API_MODEL_MAX_TOKENS='8192' -# WEB_ROLE_API_BASE_URL='' -# WEB_ROLE_API_KEY='Your_Key' -# WEB_ROLE_API_MODEL_TYPE='' -# WEB_ROLE_API_MODEL_TEMPERATURE='0.0' -# WEB_ROLE_API_MODEL_MAX_TOKENS='0' -# IMAGE_ROLE_API_BASE_URL='' -# IMAGE_ROLE_API_KEY='Your_Key' -# IMAGE_ROLE_API_MODEL_TYPE='' -# IMAGE_ROLE_API_MODEL_TEMPERATURE='0.0' -# IMAGE_ROLE_API_MODEL_MAX_TOKENS='0' - #=========================================== # Tools & Services API #=========================================== diff --git a/owl/webapp.py b/owl/webapp.py index 8ce750b..2bd6484 100644 --- a/owl/webapp.py +++ b/owl/webapp.py @@ -245,7 +245,7 @@ MODULE_DESCRIPTIONS = { "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_deepseek_zh": "Using deepseek model to process Chinese tasks", - "run_openai_compatiable_model": "Using multiple openai compatible model to process tasks", + "run_openai_compatiable_model": "Using openai compatible model to process tasks", "run_ollama": "Using local ollama model to process tasks", "run_qwen_mini_zh": "Using qwen model with minimal configuration to process tasks", "run_qwen_zh": "Using qwen model to process tasks", diff --git a/owl/webapp_zh.py b/owl/webapp_zh.py index 4bc32d5..e55d9cb 100644 --- a/owl/webapp_zh.py +++ b/owl/webapp_zh.py @@ -245,7 +245,7 @@ MODULE_DESCRIPTIONS = { "run": "默认模式:使用OpenAI模型的默认的智能体协作模式,适合大多数任务。", "run_mini": "使用使用OpenAI模型最小化配置处理任务", "run_deepseek_zh": "使用deepseek模型处理中文任务", - "run_openai_compatiable_model": "使用多个openai兼容模型处理任务", + "run_openai_compatiable_model": "使用openai兼容模型处理任务", "run_ollama": "使用本地ollama模型处理任务", "run_qwen_mini_zh": "使用qwen模型最小化配置处理任务", "run_qwen_zh": "使用qwen模型处理任务",