Skip to content

Commit

Permalink
move defaults to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-x-c committed Jan 16, 2024
1 parent 457beb5 commit 469614d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/agentscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/agentscope/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down
12 changes: 6 additions & 6 deletions src/agentscope/service/code/exec_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ""
)
Expand Down

0 comments on commit 469614d

Please sign in to comment.