Python SDK 在 Python 命名约定中公开相同的显式记忆和 x402 边界。
#安装
pip install halo-sdk#身份验证和 OAuth
from halo import HaloAuthClient, HaloOAuthClient
# OEM or application user Authentication.
auth = HaloAuthClient(
publishable_key=HALO_PROJECT_PUBLISHABLE_KEY,
)
session = auth.sign_in_with_password(
"user@example.com",
"Secret123!",
)
refreshed = auth.refresh_session(session["refresh_token"])
user = auth.get_user(refreshed["access_token"])
# Service-side OAuth App client.
oauth = HaloOAuthClient(
client_id="halo_client_...",
client_secret=HALO_OAUTH_CLIENT_SECRET,
)
tokens = oauth.exchange_code(
code=callback_code,
redirect_uri="https://service.example.com/callback",
)Python 客户端公开与 Node.js SDK 相同的项目用户和服务 OAuth 边界,并且从不保留返回的令牌。
#记忆客户端
from halo import HaloMemoryClient
memory = HaloMemoryClient(
api_key=HALO_API_KEY,
project_key="customer-product",
)
declaration = memory.function_declaration()
result = memory.execute_retrieve_function(
end_user_key="user_123",
session_data={
"messages": [
{"role": "user", "content": "What are my report preferences?"}
]
},
limit=5,
)
# Feed result["functionResponse"] to your model, then capture the final answer.
memory.capture(
end_user_key="user_123",
session_data={
"messages": [
{"role": "user", "content": "What are my report preferences?"}
]
},
response={
"role": "assistant",
"content": "You prefer concise reports in the morning.",
},
)#记忆删除
memory.delete_topic(
end_user_key="user_123",
topic_key="report_preferences",
include_raw=False,
)
memory.delete_raw_entry(
end_user_key="user_123",
raw_entry_id="raw_entry_id",
)#关联帐户
result = memory.start_oauth(
scope_id="memory-scope-uuid",
connector_id="google.calendar",
completion_mode="mobile_deep_link",
return_uri="example-app://oauth/complete",
)#旧路由器标头
from halo import halo_memory_headers
headers = halo_memory_headers(
project_key="customer-product",
end_user_key="user_123",
mode="capture",
)
# Pass headers through the provider client's per-request header option.新集成应该更喜欢函数声明和直接函数执行。路由器检索要求 HALO 将紧凑上下文和函数声明注入代理模型请求中。
#付款助手
from halo import HaloPaymentTools
tools = HaloPaymentTools(
private_key=secure_wallet_private_key,
api_key=HALO_API_KEY,
halo_url="https://api.agihalo.com",
)
decision = tools.consult_judge(
context="Continue an important agent task",
amount_str="1.00 USDC",
)
signature = tools.sign_payment(payment_requirement)