From 469614dfb8b1b59d509015e0ac31d7649907b03e Mon Sep 17 00:00:00 2001 From: "panxuchen.pxc" Date: Tue, 16 Jan 2024 11:16:57 +0800 Subject: [PATCH] move defaults to constants --- src/agentscope/__init__.py | 1 - src/agentscope/constants.py | 3 +++ src/agentscope/service/code/exec_python.py | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/agentscope/__init__.py b/src/agentscope/__init__.py index 5a2d5c42d..5aa9b7eaf 100644 --- a/src/agentscope/__init__.py +++ b/src/agentscope/__init__.py @@ -7,7 +7,6 @@ from . import models from . import pipelines from . import service -from . import utils # TODO: not exposed to the user from . import message from . import prompt diff --git a/src/agentscope/constants.py b/src/agentscope/constants.py index 7683c926e..ef5d3238f 100644 --- a/src/agentscope/constants.py +++ b/src/agentscope/constants.py @@ -20,6 +20,9 @@ _DEFAULT_MAX_RETRIES = 3 _DEFAULT_MESSAGES_KEY = "inputs" _DEFAULT_RETRY_INTERVAL = 1 +# for execute python +_DEFAULT_PYPI_MIRROR = "http://mirrors.aliyun.com/pypi/simple/" +_DEFAULT_TRUSTED_HOST = "mirrors.aliyun.com" # for summarization _DEFAULT_SUMMARIZATION_PROMPT = """ TEXT: {} diff --git a/src/agentscope/service/code/exec_python.py b/src/agentscope/service/code/exec_python.py index f51639918..1098e04d0 100644 --- a/src/agentscope/service/code/exec_python.py +++ b/src/agentscope/service/code/exec_python.py @@ -27,6 +27,10 @@ from agentscope.utils.common import create_tempdir, timer from agentscope.constants import ServiceExecStatus from agentscope.service.service_response import ServiceResponse +from agentscope.constants import ( + _DEFAULT_PYPI_MIRROR, + _DEFAULT_TRUSTED_HOST, +) def execute_python_code( @@ -192,10 +196,6 @@ def _execute_python_code_docker( packages and retry execution until no ImportErrors are found or until execution succeeds. """ - # TODO: delete it or make it configurable when release. - # sources pip install from - pypi_mirror = "http://pypi.douban.com/simple" - pypi_trusted_host = "pypi.douban.com" def docker_execute( exec_code: str, @@ -231,8 +231,8 @@ def docker_execute( # Check if there are missing modules to install install_command = ( f"pip install -q {' '.join(missing_modules)} -i" - f" {pypi_mirror} " - f"--trusted-host {pypi_trusted_host}" + f" {_DEFAULT_PYPI_MIRROR} " + f"--trusted-host {_DEFAULT_TRUSTED_HOST}" if missing_modules else "" )