Skip to main content

Snow Agent Python SDK

Project description

Snow-Agent SDK

This README documents the same integration pattern used by consumers like genix-nova-be.

Consumer-style async usage (FastAPI)

Use SnowAgentClient in async routes/services and consume streaming events:

from snow_agent_sdk import ChunkEvent, DoneEvent, ErrorEvent, SnowAgentClient

SDK_TEST_SESSION_ID = "sdk-local-test-session"


async def run_local_snow_sdk_smoke_test(
    prompt: str,
    session_id: str,
) -> dict:
    client = SnowAgentClient(
        base_url="https://apps.solugenix.com/api/snow/service",
        token="<jwt-token-from-header-or-env>",
        session_id=session_id or SDK_TEST_SESSION_ID,
    )

    chunk_count = 0
    done_payload = None

    try:
        async for event in client.query(prompt):
            if isinstance(event, ChunkEvent):
                chunk_count += 1
            elif isinstance(event, DoneEvent):
                done_payload = {
                    "intent": event.intent,
                    "flow": event.flow,
                    "fallback": event.fallback,
                }
            elif isinstance(event, ErrorEvent):
                return {
                    "ok": False,
                    "error": event.message,
                    "chunk_count": chunk_count,
                }

        return {
            "ok": True,
            "chunk_count": chunk_count,
            "done": done_payload,
        }
    finally:
        await client.close()

How genix-nova-be uses it

  • Calls SDK from api/ask.py as a non-blocking smoke test in /ask.
  • Uses request session or header-provided session (x-snow-session-id) and passes it to SnowAgentClient(..., session_id=...).
  • Iterates SSE events from client.query(prompt):
    • ChunkEvent -> counts/streams text chunks.
    • DoneEvent -> captures final metadata (intent, flow, fallback).
    • ErrorEvent -> returns/logs SDK error without crashing the API flow.
  • Always closes the async client with await client.close() in finally.

Minimal sync usage

For scripts or blocking contexts, use SnowAgentClientSync:

from snow_agent_sdk import SnowAgentClientSync

client = SnowAgentClientSync(
    base_url="https://apps.solugenix.com/api/snow/service",
    token="<jwt-token-from-header-or-env>",
    session_id="optional-session-id",
)
text = client.ask("create incident for store 17 pos is offline")
print(text)

Notes

  • Do not hardcode secrets/tokens in code.
  • Keep base_url environment-specific (local, dev, qa, prod).
  • Reuse session IDs per conversation when you want contextual continuity.

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

snow_agent_sdk-0.1.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

snow_agent_sdk-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for snow_agent_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 86b7e3af5212a76e542922d66aee6cb93f99c819183b4a6910468b4530c7757b
MD5 84223e2a816e294120ce8dab946a0c9b
BLAKE2b-256 8c6381ca6c87553d41e0c76207bb4a1381b886ed4414d992c9c1eb3ca6115a30

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for snow_agent_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 de1819220de12da8ed1aa7a8d2f02d4e6e11bd1a56f39e85176971e8f73c4623
MD5 3b504cc685d03a7b5797645a6b109259
BLAKE2b-256 c6f5fd745c9c3db3ddaf942463f338390b04c17d5d612e59c3936e4402e2cbc0

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