创建 Client

最近更新时间:2025-12-16 17:52:01

我的收藏
MemoryClient() 用于通过 HTTP I/O 请求方式创建一个 Memory 的客户端对象。
class MemoryClient:
def __init__(self,
endpoint: str,
api_key: str,
memory_id: str,
timeout: int = 10,
stub: Optional[Stub] = None):
self.default_memory_id = memory_id
self.default_actor_id = default_actor_id
self.stub = stub or HttpStub(endpoint, api_key, memory_id, timeout)

使用示例

from tdaimemory import MemoryClient

EndPoint = "https://memory.tdai.tencentyun.com"
ApiKey = "***************************"
MemoryId = "tdai-mem-********"
client = MemoryClient(endpoint=EndPoint,
api_key=ApiKey,
memory_id=MemoryId,
timeout=100)

client.close()
参数名
参数含义
是否必须
获取方式
endpoint
客户端所需连接 Memory 服务端的访问地址。
登录 Memory 智能体控制台,在详情页面的 API 接入区域,可获取 Memory 的访问地址与访问密钥。
api_key
客户端访问 Memory 服务端的 API Key,用于鉴权。
memory_id
Memory 服务端具有唯一标识的 ID。
登录 Memory 智能体控制台,在 Memory 的卡片上或详情页面,可复制 ID。
timeout
请求超时时间。
数据类型:Integer。
单位:秒。
默认值:720。
取值范围:大于等于0。
说明:
若 timeout 设置为小于 0 或为 null,系统会自动赋值为默认值。

关闭 Client

关闭客户端连接,释放资源。
client.close()