Skip to main content

Hsafa SDK v7 — connect any service to a Haseef brain

Project description

hsafa-sdk

Python SDK for Hsafa Core v7. Connect any service to a Haseef brain — register tools, handle tool calls over SSE, push events, and read/write the haseef's memory and profile.

Install

pip install hsafa-sdk

Or from source:

cd sdks/python
pip install -e .

Quick Start

import asyncio
import os
from hsafa_sdk import HsafaSDK, SdkOptions

async def main():
    sdk = HsafaSDK(SdkOptions(
        core_url="http://localhost:3001",
        api_key=os.environ.get("HSAFA_CORE_KEY", "test-key"),
        skill="weather",
    ))

    # 1. Register tools
    await sdk.register_tools([{
        "name": "get_weather",
        "description": "Get current weather for a city",
        "input": {"city": "string", "units": "string?"},
    }])

    # 2. Handle tool calls
    async def handle_weather(args, ctx):
        print(f"{ctx['haseef']['name']} wants weather for {args.get('city')}")
        return {"temperature": 72, "conditions": "sunny", "city": args.get("city")}

    sdk.on_tool_call("get_weather", handle_weather)

    # 3. Listen to lifecycle events
    def on_run_started(e):
        print(f"Run started for {e['haseef']['name']}")

    sdk.on("run.started", on_run_started)

    # 4. Connect the SSE stream (blocks until disconnect)
    # For background usage alongside a web server:
    #     asyncio.create_task(sdk.connect())
    try:
        await sdk.connect()
    except KeyboardInterrupt:
        await sdk.disconnect()

if __name__ == "__main__":
    asyncio.run(main())

Namespaces

Namespace Methods
sdk.haseef list(), get(id), create(data), update(id, patch), delete(id), get_profile(id), update_profile(id, patch), add_skill(id, name), remove_skill(id, name), status(id)
sdk.memory list(id), search(id, query, limit), set(id, memories), delete(id, keys), episodes(id, limit), search_episodes(id, query, limit), social(id), procedural(id), stats(id)
sdk.runs list(haseef_id?, status?, limit?), get(run_id)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hsafa_sdk-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hsafa_sdk-0.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file hsafa_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: hsafa_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for hsafa_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b4ac9d3a0cb5195f4455722ddbfa15b1e5b3ec7c6399ac2d92cf7bd7bad5233a
MD5 869ffa633dc7485622f5f3210c976fe8
BLAKE2b-256 fdd10e63640c15d557fd0cf50d560c55321c1502fe371c4c428cd7bc23382970

See more details on using hashes here.

File details

Details for the file hsafa_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hsafa_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for hsafa_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d9bda7c8e45ac0f4761fc0c6dff86b9c9bfb065e0452a3e4cd2787811e611eb
MD5 016120c0b704d3265637fb5da273426e
BLAKE2b-256 2056b8838f85e515f5d7778e53552fa85c9b110cde46c87fa9eee66384a03ebf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page