agentscope.server.servicer module

Server of distributed agent

class agentscope.server.servicer.AgentServerServicer(stop_event: Event, host: str = 'localhost', port: int | None = None, server_id: str | None = None, studio_url: str | 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)[source]

Bases: RpcAgentServicer

A Servicer for RPC Agent Server (formerly RpcServerSideWrapper)

__init__(stop_event: Event, host: str = 'localhost', port: int | None = None, server_id: str | None = None, studio_url: str | 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)[source]

Init the AgentServerServicer.

Parameters:
  • stop_event (Event) – Event to stop the server.

  • host (str, defaults to “localhost”) – Hostname of the rpc agent server.

  • port (int, defaults to None) – Port of the rpc agent server.

  • server_id (str, defaults to None) – Server id of the rpc agent server.

  • studio_url (str, defaults to None) – URL of the AgentScope Studio.

  • capacity (int, default to 32) – The number of concurrent agents in the servicer.

  • 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) – The maximum time (in seconds) that the server will wait for the result of an async call.

agent_exists(agent_id: str) bool[source]

Check whether the agent exists.

Parameters:

agent_id (str) – the agent id.

Returns:

whether the agent exists.

Return type:

bool

get_agent(agent_id: str) Any[source]

Get the object by agent id.

Parameters:

agent_id (str) – the agent id.

Returns:

the object.

Return type:

Any

is_alive(request: Empty, context: ServicerContext) GeneralResponse[source]

Check whether the server is alive.

stop(request: Empty, context: ServicerContext) GeneralResponse[source]

Stop the server.

create_agent(request: CreateAgentRequest, context: ServicerContext) GeneralResponse[source]

Create a new agent on the server.

delete_agent(request: StringMsg, context: ServicerContext) GeneralResponse[source]

Delete agents from the server.

Parameters:
  • request (StringMsg) – The value field is the agent_id of the

  • deleted. (agents to be)

delete_all_agents(request: Empty, context: ServicerContext) GeneralResponse[source]

clear all agent on the server

call_agent_func(request: CallFuncRequest, context: ServicerContext) GeneralResponse[source]

Call the specific servicer function.

update_placeholder(request: UpdatePlaceholderRequest, context: ServicerContext) CallFuncResponse[source]

Update the value of a placeholder.

get_agent_list(request: Empty, context: ServicerContext) GeneralResponse[source]

Get id of all agents on the server as a list.

get_server_info(request: Empty, context: ServicerContext) GeneralResponse[source]

Get the agent server resource usage information.

set_model_configs(request: StringMsg, context: ServicerContext) GeneralResponse[source]

Set the model configs of the agent server.

get_agent_memory(request: StringMsg, context: ServicerContext) StringMsg[source]

Get the memory of a specific agent.

download_file(request: StringMsg, context: ServicerContext) Any[source]

Download file from local path.