Skip to main content

Clean, minimal package for Orca platform integration

Project description

Orca SDK

Professional Python SDK for building real-time AI agents with streaming and production-ready deployment.

Python 3.8+ License: MIT

Features

  • 🚀 Real-time Streaming - Stream responses to users in real-time
  • 🏗️ Clean Architecture - SOLID principles, dependency injection, modular design
  • AWS Lambda Ready - Deploy to Lambda with one command
  • 🎨 Design Patterns - Builder, middleware, context managers
  • 📦 Storage SDK - Integrated file storage management
  • 💬 Conversation SDK - Create, rename, and manage conversations via external API
  • 🔒 Production Ready - Error handling, logging, type safety
  • ⚙️ Focused Core - Lean dependency surface for core streaming and deployment

Quick Start

Installation

pip install orca-platform-sdk-ui

Note: The package name on PyPI is orca-platform-sdk-ui, but imports still use orca:

from orca import OrcaHandler  # ✅ Correct

Basic Usage

FastAPI / Web App (Standard Factory):

from orca import create_agent_app, ChatMessage, OrcaHandler

async def process_msg(data: ChatMessage):
    handler = OrcaHandler()
    session = handler.begin(data)
    session.stream(f"Echo: {data.message}")
    session.close()

app = create_agent_app(process_message_func=process_msg)
# Run with: uvicorn main:app

SessionBuilder (Queued Operations):

from orca import OrcaHandler
from orca.patterns import SessionBuilder

handler = OrcaHandler(dev_mode=True)

# All operations are queued until execute() or complete() is called
builder = SessionBuilder(handler).start_session(data)
builder.add_stream("Hello, world!")
builder.add_image("https://example.com/image.jpg")
builder.add_button("Click", "https://example.com")
builder.execute()  # Execute all queued operations
result = builder.complete()  # Execute remaining + close session

Lambda Deployment

from orca import create_hybrid_handler, ChatMessage, OrcaHandler

async def my_agent_logic(data: ChatMessage):
    handler = OrcaHandler()
    session = handler.begin(data)
    session.stream("Response from Lambda!")
    session.close()

# Unified handler for HTTP (FastAPI), SQS, and Cron
handler = create_hybrid_handler(process_message_func=my_agent_logic)

Documentation

Document Description
Quick Reference API reference and quick examples
Developer Guide Complete development guide
API Reference Complete API documentation
Patterns Guide Design patterns and best practices
Utilities Guide Exceptions, decorators, and logging
Storage SDK Guide Storage SDK and API reference
Conversation SDK Guide Conversation management SDK
Lambda Deploy Guide AWS Lambda deployment guide
Dev Mode Guide Local development setup
Contributing How to contribute
Security Security policies
Changelog Version history

Examples

Complete examples are available in the examples/ directory:

Quick Start

Deployment

Features

Core Features

Streaming

session.loading.start("thinking")
session.stream("Processing your request...")
session.loading.end("thinking")
session.close()

Buttons

session.button.link("Visit Website", "https://example.com")
session.button.action("Regenerate", "regenerate")

Tracing

session.tracing.begin("Processing", visibility="all")
session.tracing.append("Step 1: Analyzing...")
session.tracing.append("Step 2: Generating...")
session.tracing.end("Complete!")

Usage Tracking

session.usage.track(
    tokens=1500,
    token_type="gpt4",
    cost="0.03",
    label="OpenAI GPT-4"
)

Error Handling

try:
    # Your logic
    pass
except Exception as e:
    session.error("An error occurred", exception=e)

Conversation Management

from orca import OrcaConversation

# Inside an agent (auto-derives config from request)
conv = OrcaConversation(data=data)
conv.rename(thread_id=data.thread_id, title="New Title")

# Standalone
conv = OrcaConversation(token="workspace-token", base_url="https://api.example.com/v1/external")
result = conv.create(project_uuid="abc-123", title="Chat", model="gpt-4", user_id_external="user-1")

Architecture

Orca SDK follows clean architecture principles with 14 distinct layers:

orca/
├── core/           # Core handler and session
├── domain/         # Interfaces and models
├── services/       # Business logic services
├── infrastructure/ # External clients
├── factories/      # Factory patterns
├── helpers/        # Helper utilities
├── utils/          # Utility functions
├── common/         # Cross-cutting concerns
├── patterns/       # Design patterns
├── adapters/       # Deployment adapters
├── storage/        # Storage SDK
└── conversation/   # Conversation SDK

Requirements

  • Python 3.8+
  • requests>=2.31.0
  • pydantic>=2.0.0
  • boto3>=1.34.0 (optional, for Lambda/SQS)

Development

Setup

# Clone repository
git clone https://github.com/orcapt/orca-pip
cd orca-pip

# Install dependencies
pip install -r requirements.txt

# Run tests
pytest

# Run examples
python examples/basic_usage.py

Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=orca

# Run specific test
pytest tests/test_handler.py

Deployment

AWS Lambda

  1. Copy templates:
cp examples/lambda_deployment_simple.py lambda_handler.py
cp examples/Dockerfile.lambda .
cp examples/requirements-lambda.txt .
  1. Build image:
docker build -f Dockerfile.lambda -t my-agent:latest .
  1. Deploy:
orca ship my-agent --image my-agent:latest --env-file .env

See Lambda Deploy Guide for complete instructions.

License

MIT License - see LICENSE file for details.

Support

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Acknowledgments

Built with ❤️ by the Orca team.


Made with 🚀 by Orca

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

orca_platform_sdk_ui-1.0.14.tar.gz (140.9 kB view details)

Uploaded Source

Built Distribution

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

orca_platform_sdk_ui-1.0.14-py3-none-any.whl (107.6 kB view details)

Uploaded Python 3

File details

Details for the file orca_platform_sdk_ui-1.0.14.tar.gz.

File metadata

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

File hashes

Hashes for orca_platform_sdk_ui-1.0.14.tar.gz
Algorithm Hash digest
SHA256 334f39938ef4ab44ccf8da4cf5986135bcf8d786227547023930c34115291cd7
MD5 6d9e210581cf77268e16689ab046c6f5
BLAKE2b-256 f2d850d223395843a052c84c212cc626a63921f38ea5511b233beb3c637bb865

See more details on using hashes here.

File details

Details for the file orca_platform_sdk_ui-1.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for orca_platform_sdk_ui-1.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 58f71fcca70299b53ade2a70f6e1cdf4ec5c9320eb6e4a3ffd6ab79e51d745ee
MD5 8b328cd095438e7f948485155385fc26
BLAKE2b-256 1755c989426c27ab8afa811f97d43e5f9e847100e34a60b4df148be77f2aae9f

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