agentscope.server.launcher module
Server of distributed agent
- agentscope.server.launcher.load_custom_class_from_file(agent_file: str) list [source]
Load AgentBase sub classes from a python file.
- Parameters:
agent_file (str) – the path to the python file.
- Returns:
a list of agent classes
- Return type:
list
- agentscope.server.launcher.load_agents_from_dir(agent_dir: str) list [source]
Load customized agents from a directory.
- Parameters:
agent_dir (str) – a directory contains customized agent python files.
- Returns:
a list of customized agent classes
- Return type:
list
- class agentscope.server.launcher.RpcAgentServerLauncher(host: str = 'localhost', port: int | None = None, capacity: int = 32, pool_type: str = 'local', redis_url: str = 'redis://localhost:6379', max_pool_size: int = 8192, max_expire_time: int = 7200, max_timeout_seconds: int = 5, local_mode: bool = False, agent_dir: str | None = None, custom_agent_classes: list | None = None, server_id: str | None = None, studio_url: str | None = None)[source]
Bases:
object
The launcher of AgentServer.
- __init__(host: str = 'localhost', port: int | None = None, capacity: int = 32, pool_type: str = 'local', redis_url: str = 'redis://localhost:6379', max_pool_size: int = 8192, max_expire_time: int = 7200, max_timeout_seconds: int = 5, local_mode: bool = False, agent_dir: str | None = None, custom_agent_classes: list | None = None, server_id: str | None = None, studio_url: str | None = None) None [source]
Init a launcher of agent server.
- Parameters:
host (str, defaults to “localhost”) – Hostname of the agent server.
port (int, defaults to None) – Socket port of the agent server.
capacity (int, default to 32) – The number of concurrent agents in the server.
pool_type (str, defaults to “local”) – The type of the async message pool, which can be local or redis. If redis is specified, you need to start a redis server before launching the server.
redis_url (str) – The address of the redis server. Defaults to redis://localhost:6379.
max_pool_size (int, defaults to 8192) – The max number of async results that the server can accommodate. Note that the oldest result will be deleted after exceeding the pool size.
max_expire_time (int, defaults to 7200) – Maximum time for async results to be cached in the server. Note that expired messages will be deleted.
max_timeout_seconds (int, defaults to 5) – Max timeout seconds for rpc calls.
local_mode (bool, defaults to False) – If True, only listen to requests from “localhost”, otherwise, listen to requests from all hosts.
agent_dir (str, defaults to None) – The directory containing customized agent python files.
custom_agent_classes (list, defaults to None) – A list of customized agent classes that are not in agentscope.agents.
server_id (str, defaults to None) – The id of the agent server. If not specified, a random id will be generated.
studio_url (Optional[str], defaults to None) – The url of the agentscope studio.
- agentscope.server.launcher.as_server() None [source]
Launch an agent server with terminal command.
Note
The arguments of as_server are listed as follows:
–host: the hostname of the server.
–port: the socket port of the server.
–capacity: the number of concurrent agents in the server.
–pool-type: the type of the async message pool, which can be local or redis. If redis is specified, you need to start a redis server before launching the server. Defaults to local.
–redis-url: the url of the redis server, defaults to redis://localhost:6379.
–max-pool-size: max number of agent reply messages that the server can accommodate. Note that the oldest message will be deleted after exceeding the pool size.
–max-expire: max expire time for async function result.
–max-timeout-seconds: max timeout for rpc call.
–local-mode: whether the started agent server only listens to local requests.
–model-config-path: the path to the model config json file
–agent-dir: the directory containing your customized agent python files
–studio-url: the url of agentscope studio
In most cases, you only need to specify the –host, –port and –model-config-path, and –agent-dir.
as_server start --host localhost \ --port 12345 \ --model-config-path config.json \ --agent-dir ./my_agents