agentscope.rpc.rpc_client module

Client of rpc agent server

class agentscope.rpc.rpc_client.RpcClient(host: str, port: int)[source]

Bases: object

A client of Rpc agent server

__init__(host: str, port: int) None[source]

Init a rpc agent client

Parameters:
  • host (str) – The hostname of the rpc agent server which the

  • connected. (is)

  • port (int) – The port of the rpc agent server which the client

  • connected.

call_agent_func(func_name: str, agent_id: str, value: bytes | None = None, timeout: int = 300) bytes[source]

Call the specific function of an agent running on the server.

Parameters:
  • func_name (str) – The name of the function being called.

  • value (bytes, optional) – The serialized function input value.

  • None. (Defaults to)

  • timeout (int, optional) – The timeout for the RPC call in seconds.

  • 300. (Defaults to)

Returns:

serialized return data.

Return type:

bytes

is_alive() bool[source]

Check if the agent server is alive.

Returns:

Indicate whether the server is alive.

Return type:

bool

stop() bool[source]

Stop the agent server.

create_agent(agent_configs: dict, agent_id: str | None = None) bool[source]

Create a new agent for this client.

Parameters:
  • agent_configs (dict) – Init configs of the agent, generated by RpcMeta.

  • agent_id (str) – agent_id of the created agent.

Returns:

Indicate whether the creation is successful

Return type:

bool

delete_agent(agent_id: str | None = None) bool[source]

Delete agents with the specific agent_id.

Parameters:

agent_id (str) – id of the agent to be deleted.

Returns:

Indicate whether the deletion is successful

Return type:

bool

delete_all_agent() bool[source]

Delete all agents on the server.

update_result(task_id: int, retry: ~agentscope.rpc.retry_strategy.RetryBase = <agentscope.rpc.retry_strategy.RetryFixedTimes object>) str[source]

Update the value of the async result.

Note

DON’T USE THIS FUNCTION IN ThreadPoolExecutor.

Parameters:
  • task_id (int) – task_id of the PlaceholderMessage.

  • retry (RetryBase) – Retry strategy. Defaults to RetryFixedTimes(10, 5).

Returns:

Serialized value.

Return type:

bytes

get_agent_list() Sequence[dict][source]

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

Returns:

list of agent summary information.

Return type:

Sequence[str]

get_server_info() dict[source]

Get the agent server resource usage information.

set_model_configs(model_configs: dict | list[dict]) bool[source]

Set the model configs of the server.

get_agent_memory(agent_id: str) list[Msg] | Msg[source]

Get the memory usage of the specific agent.

download_file(path: str) str[source]

Download a file from a remote server to the local machine.

Parameters:

path (str) – The path of the file to be downloaded. Note that it is the path on the remote server.

Returns:

The path of the downloaded file. Note that it is the path on the local machine.

Return type:

str

class agentscope.rpc.rpc_client.RpcAgentClient(host: str, port: int)[source]

Bases: RpcClient

RpcAgentClient has renamed to RpcClient. This class is kept for backward compatibility, please use RpcClient instead.

__init__(host: str, port: int) None[source]

Init a rpc agent client

Parameters:
  • host (str) – The hostname of the rpc agent server which the

  • connected. (is)

  • port (int) – The port of the rpc agent server which the client

  • connected.