Skip to main content

A Python SDK for Asteroid

Project description

Asteroid AI

Asteroid Python SDK ☄️

A Python SDK for interacting with the Asteroid platform. To successfully use Asteroid Python SDK, you need to have a running instance of the Asteroid server. Book a demo with Asteroid founders to get started!

Installation

pip install asteroid-sdk

Quick Start

from asteroid_sdk.wrappers.openai import asteroid_openai_client
from asteroid_sdk.registration.initialise_project import asteroid_init
from asteroid_sdk.supervision.decorators import supervise
from asteroid_sdk.supervision.base_supervisors import llm_supervisor, human_supervisor
from openai import OpenAI

# Define your tools with supervisors
@supervise(supervision_functions=[
    [llm_supervisor(instructions="For flights above $1000, escalate."), human_supervisor()]])
def book_flight(departure_city: str, arrival_city: str, datetime: str):
    """Book a flight ticket."""
    return f"Flight booked from {departure_city} to {arrival_city} on {datetime}."

tools = [{
    "type": "function",
    "function": {
        "name": "book_flight",
        "description": "Book a flight ticket.",
        "parameters": {
            "type": "object",
            "properties": {
                "departure_city": {
                    "type": "string"
                },
                "arrival_city": {
                    "type": "string"
                },
                "datetime": {
                    "type": "string"
                }
            },
            "required": [
                "departure_city",
                "arrival_city",
                "datetime"
            ],
            "additionalProperties": False
        },
        "strict": True
    }
}]

# Initialize the SDK
run_id = asteroid_init()

# Wrap your LLM client
client = OpenAI()
wrapped_client = asteroid_openai_client(client, run_id)

# Run your LLM
response = wrapped_client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Book a flight from SF to LA for tomorrow for $1100."}],
    tools=tools
)
# The response is supervised by Asteroid, check the web UI for the results and human review

Documentation

For more information, please refer to the Asteroid 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

asteroid_sdk-0.1.24.tar.gz (86.9 kB view details)

Uploaded Source

Built Distribution

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

asteroid_sdk-0.1.24-py3-none-any.whl (185.0 kB view details)

Uploaded Python 3

File details

Details for the file asteroid_sdk-0.1.24.tar.gz.

File metadata

  • Download URL: asteroid_sdk-0.1.24.tar.gz
  • Upload date:
  • Size: 86.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for asteroid_sdk-0.1.24.tar.gz
Algorithm Hash digest
SHA256 600e79fc131d695e4a8a8bee13007471072e10e309cfadad9ff9ef63e0e680e7
MD5 bbeea5b9c9977c2f0294fe4408d5ad38
BLAKE2b-256 821dddf9e692b72a4e7692e8ae4f4205d6eeb7b44062a4fce0955e7fd0a3e56b

See more details on using hashes here.

File details

Details for the file asteroid_sdk-0.1.24-py3-none-any.whl.

File metadata

  • Download URL: asteroid_sdk-0.1.24-py3-none-any.whl
  • Upload date:
  • Size: 185.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for asteroid_sdk-0.1.24-py3-none-any.whl
Algorithm Hash digest
SHA256 68f59390a96702350a58d3bb281c392c9d3ce6bb91fece605f9fa62656b80569
MD5 f7f748c7debaa2fea233f5433659a4dc
BLAKE2b-256 3a71ac7bdf42525c8e7c5b5e151fa77fa84b0a1e78c96473e05a9a1e6e509be6

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