agentscope.rpc.rpc_client module
Client of rpc agent server
- class agentscope.rpc.rpc_client.RpcClient(host: str, port: int)[源代码]
基类:
object
A client of Rpc agent server
- __init__(host: str, port: int) 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.
- call_agent_func(func_name: str, agent_id: str, value: bytes | None = None, timeout: int = 300) bytes [源代码]
Call the specific function of an agent running on the server.
- 参数:
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)
- 返回:
serialized return data.
- 返回类型:
bytes
- is_alive() bool [源代码]
Check if the agent server is alive.
- 返回:
Indicate whether the server is alive.
- 返回类型:
bool
- 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 RpcMeta.
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
- update_result(task_id: int, retry: ~agentscope.rpc.retry_strategy.RetryBase = <agentscope.rpc.retry_strategy.RetryFixedTimes object>) str [源代码]
Update the value of the async result.
备注
DON’T USE THIS FUNCTION IN ThreadPoolExecutor.
- 参数:
task_id (int) – task_id of the PlaceholderMessage.
retry (RetryBase) – Retry strategy. Defaults to RetryFixedTimes(10, 5).
- 返回:
Serialized value.
- 返回类型:
bytes
- get_agent_list() Sequence[dict] [源代码]
Get the summary of all agents on the server as a list.
- 返回:
list of agent summary information.
- 返回类型:
Sequence[str]