Python SDK は、同じ明示的なメモリおよび x402 境界を公開します。 Python の命名規則。
#インストール
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)