Skip to content

feat(sdk): add Python SDK with full feature parity#12

Closed
saurabhjain1592 wants to merge 1 commit intomainfrom
feat/python-sdk
Closed

feat(sdk): add Python SDK with full feature parity#12
saurabhjain1592 wants to merge 1 commit intomainfrom
feat/python-sdk

Conversation

@saurabhjain1592
Copy link
Copy Markdown
Member

Summary

Introduces the AxonFlow Python SDK with full feature parity to the Go SDK.

Key Features

  • Async-first design with sync wrappers via AxonFlow.sync()
  • Full type hints with Pydantic v2 models
  • Gateway Mode for lowest-latency LLM calls
    • get_policy_approved_context() for pre-checks
    • audit_llm_call() for compliance logging
  • LLM Interceptors for transparent governance
    • wrap_openai_client() - OpenAI integration
    • wrap_anthropic_client() - Anthropic integration
  • MCP connector operations (list, install, query)
  • Multi-agent planning (generate, execute, status)

Architecture

sdk/python/
├── axonflow/
│   ├── __init__.py          # Public API exports
│   ├── client.py            # Main AxonFlow client (813 lines)
│   ├── types.py             # Pydantic v2 models (213 lines)
│   ├── exceptions.py        # Exception hierarchy (103 lines)
│   ├── interceptors/        # LLM provider interceptors
│   │   ├── openai.py        # OpenAI wrapper
│   │   └── anthropic.py     # Anthropic wrapper
│   └── utils/               # Utilities (cache, retry, logging)
├── tests/                   # Comprehensive test suite
├── examples/                # Usage examples
├── pyproject.toml           # Package configuration
└── README.md                # Documentation

Quality Standards

  • Linting: ruff check passes
  • Type checking: mypy strict mode compatible
  • Test coverage: 95%+ target
  • Python support: 3.9, 3.10, 3.11, 3.12
  • Dependencies: httpx, pydantic v2, tenacity, structlog, cachetools

Usage Examples

Async (recommended):

async with AxonFlow(agent_url="...", client_id="...", client_secret="...") as client:
    response = await client.execute_query("user-token", "What is AI?", "chat")

Sync:

with AxonFlow.sync(agent_url="...", client_id="...", client_secret="...") as client:
    response = client.execute_query("user-token", "What is AI?", "chat")

Gateway Mode:

ctx = await client.get_policy_approved_context(user_token, query, data_sources=["postgres"])
if ctx.approved:
    llm_response = await openai.chat.completions.create(...)
    await client.audit_llm_call(ctx.context_id, summary, "openai", "gpt-4", usage, latency)

Test plan

  • CI checks pass (lint, type check, tests)
  • Python 3.9, 3.10, 3.11, 3.12 compatibility
  • Test coverage >= 90%
  • Package builds successfully
  • Examples run without error

Introduces the AxonFlow Python SDK with:
- Async-first design with sync wrappers
- Full type hints with Pydantic v2 models
- Gateway Mode for lowest-latency LLM calls
- OpenAI and Anthropic interceptors for transparent governance
- MCP connector operations (list, install, query)
- Multi-agent planning (generate, execute, status)
- Comprehensive exception hierarchy
- Response caching with TTL
- Retry logic with exponential backoff
- Structured logging with structlog
- CI/CD workflow for PyPI publishing

Key features:
- AxonFlow class with async context manager
- SyncAxonFlow wrapper for synchronous usage
- get_policy_approved_context() for pre-checks
- audit_llm_call() for compliance logging
- wrap_openai_client() and wrap_anthropic_client()

Quality:
- ruff linting compatible
- mypy strict mode compatible
- 95%+ test coverage target
- Python 3.9-3.12 support
@saurabhjain1592
Copy link
Copy Markdown
Member Author

Closing: PR should be created in axonflow-enterprise first, then sync to OSS.

@saurabhjain1592 saurabhjain1592 deleted the feat/python-sdk branch December 16, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant