대시보드
SDK

Python SDK

Python용 메모리 및 x402 도우미.

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)