Skip to main content

Python SDK for the SLOP protocol — let AI observe and interact with your app's state

Project description

slop-ai

Python SDK for the SLOP protocol.

The package includes provider and consumer APIs, descriptor helpers, tree scaling utilities, and transports for ASGI, WebSocket, Unix socket, and stdio flows.

Install

pip install slop-ai[websocket]

Use the websocket extra when you want the standalone WebSocket transport. The core package itself has no required runtime dependencies.

Quick start

from fastapi import FastAPI
from slop_ai import SlopServer
from slop_ai.transports.asgi import SlopMiddleware

app = FastAPI()
slop = SlopServer("my-api", "My API")

@slop.node("todos")
def todos_node():
    return {
        "type": "collection",
        "items": [
            {"id": str(todo.id), "props": {"title": todo.title, "done": todo.done}}
            for todo in db.get_todos()
        ],
    }

@slop.action("todos", "create", params={"title": "string"})
def create_todo(title: str):
    db.create_todo(title)

app.add_middleware(SlopMiddleware, slop=slop)

Included modules

  • slop_ai.SlopServer and slop_ai.SlopConsumer
  • slop_ai.discovery for provider scanning, bridge relay, lazy/auto-connect, and AI-facing tool helpers
  • slop_ai.pick, slop_ai.omit, slop_ai.normalize_descriptor
  • slop_ai.transports.asgi, .websocket, .unix, .stdio
  • scaling helpers such as prepare_tree, truncate_tree, and auto_compact

Discovery layer

The Python SDK includes the core discovery layer in slop_ai.discovery:

import asyncio

from slop_ai.discovery import DiscoveryOptions, create_discovery_service


async def main() -> None:
    service = create_discovery_service(DiscoveryOptions())
    await service.start()
    try:
        provider = await service.ensure_connected("my-app")
        if provider is not None:
            print(provider.name)
    finally:
        await service.stop()


asyncio.run(main())

Install slop-ai[websocket] when discovery needs browser bridge support or direct WebSocket providers.

Documentation

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

slop_ai-0.2.0rc4.tar.gz (53.0 kB view details)

Uploaded Source

Built Distribution

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

slop_ai-0.2.0rc4-py3-none-any.whl (49.2 kB view details)

Uploaded Python 3

File details

Details for the file slop_ai-0.2.0rc4.tar.gz.

File metadata

  • Download URL: slop_ai-0.2.0rc4.tar.gz
  • Upload date:
  • Size: 53.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for slop_ai-0.2.0rc4.tar.gz
Algorithm Hash digest
SHA256 d1ee00caddc85f98d5097a29a557844f1b296dd680e585f28fafece9caa4b4b0
MD5 2be46b1f5b81cacc781020466e56e051
BLAKE2b-256 0e45a0dfd4dd25c7398746a30b41bd687b1c97b385134be397ab35dd8ace4800

See more details on using hashes here.

File details

Details for the file slop_ai-0.2.0rc4-py3-none-any.whl.

File metadata

  • Download URL: slop_ai-0.2.0rc4-py3-none-any.whl
  • Upload date:
  • Size: 49.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for slop_ai-0.2.0rc4-py3-none-any.whl
Algorithm Hash digest
SHA256 04578b9ac2923a23fe9649d61765da550f1ac1337071c559311c224ccde5a535
MD5 287476062cdd9c554951278066ed8881
BLAKE2b-256 2ac8d8e33e643fee110947f45402d959b0dd8724f21b96b21e192a69c9068365

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