agentscope.rpc package

Submodules

Module contents

Import all rpc related modules in the package.

class agentscope.rpc.RpcAgentClient(host: str, port: int, agent_id: str | None = None)[源代码]

基类:object

A client of Rpc agent server

__init__(host: str, port: int, agent_id: str | None = None) None[源代码]

Init a rpc agent client

参数:
  • 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.

  • agent_id (str) – The agent id of the agent being called.

  • None. (Defaults to)

call_agent_func(func_name: str, value: str | None = None, timeout: int = 300) str[源代码]

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

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

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

  • None. (Defaults to)

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

  • 300. (Defaults to)

返回:

serialized return data.

返回类型:

str

is_alive() bool[源代码]

Check if the agent server is alive.

返回:

Indicate whether the server is alive.

返回类型:

bool

stop() None[源代码]

Stop the agent server.

create_agent(agent_configs: dict, agent_id: str | None = None) bool[源代码]

Create a new agent for this client.

参数:
  • agent_configs (dict) – Init configs of the agent, generated by

  • _AgentMeta.

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

返回:

Indicate whether the creation is successful

返回类型:

bool

delete_agent(agent_id: str | None = None) bool[源代码]

Delete agents with the specific agent_id.

参数:

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

返回:

Indicate whether the deletion is successful

返回类型:

bool

delete_all_agent() bool[源代码]

Delete all agents on the server.

clone_agent(agent_id: str) str | None[源代码]

Clone a new agent instance from the origin instance.

参数:

agent_id (str) – The agent_id of the agent to be cloned.

返回:

The agent_id of the generated agent.

返回类型:

str

update_placeholder(task_id: int) str[源代码]

Update the placeholder value.

参数:

task_id (int) – task_id of the PlaceholderMessage.

返回:

Whether the update is successful. str: Serialized message value.

返回类型:

bool

get_agent_list() Sequence[dict][源代码]

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

返回:

list of agent summary information.

返回类型:

Sequence[str]

get_server_info() dict[源代码]

Get the agent server resource usage information.

set_model_configs(model_configs: dict | list[dict]) bool[源代码]

Set the model configs of the server.

get_agent_memory(agent_id: str) list[Msg] | Msg[源代码]

Get the memory usage of the specific agent.

download_file(path: str) str[源代码]

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

Args: path (str): The path of the file to be downloaded. Note that

it is the path on the remote server.

返回:

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

返回类型:

str

class agentscope.rpc.ResponseStub[源代码]

基类:object

A stub used to save the response of a rpc call in a sub-thread.

__init__() None[源代码]
set_response(response: str) None[源代码]

Set the message.

get_response() str[源代码]

Get the message.

class agentscope.rpc.RpcMsg

基类:Message, Message

DESCRIPTOR = <google._upb._message.Descriptor object>
class agentscope.rpc.RpcAgentServicer[源代码]

基类:object

Servicer for rpc agent server

is_alive(request, context)[源代码]

check server is alive

stop(request, context)[源代码]

stop the server

create_agent(request, context)[源代码]

create a new agent on the server

delete_agent(request, context)[源代码]

delete agent from the server

delete_all_agents(request, context)[源代码]

clear all agent on the server

clone_agent(request, context)[源代码]

clone an agent with specific agent_id

get_agent_list(request, context)[源代码]

get id of all agents on the server as a list

get_server_info(request, context)[源代码]

get the resource utilization information of the server

set_model_configs(request, context)[源代码]

update the model configs in the server

get_agent_memory(request, context)[源代码]

get memory of a specific agent

call_agent_func(request, context)[源代码]

call funcs of agent running on the server

update_placeholder(request, context)[源代码]

update value of PlaceholderMessage

download_file(request, context)[源代码]

file transfer

class agentscope.rpc.RpcAgentStub(channel)[源代码]

基类:object

Servicer for rpc agent server

__init__(channel)[源代码]

Constructor.

参数:

channel – A grpc.Channel.

agentscope.rpc.call_in_thread(client: RpcAgentClient, value: str, func_name: str) ResponseStub[源代码]

Call rpc function in a sub-thread.

参数:
  • client (RpcAgentClient) – The rpc client.

  • value (str) – The value of the request.

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

返回:

A stub to get the response.

返回类型:

ResponseStub

agentscope.rpc.add_RpcAgentServicer_to_server(servicer, server)[源代码]