Getting Started

Getting Started

# install the Capabilities Python SDK
pip install git@ssh://

Get an API key from and set the CAPABILITIES_API_KEY environment variable.

# place in your ~/.bashrc or ~/.zshrc, etc.

Try the structured generation capability:

from capabilities import Capability
from pydantic import BaseModel

class Number(BaseModel):
    number: int

class PrimeFactor(BaseModel):
    prime: int
    exponent: int

class PrimeFactorization(BaseModel):
    factors: List[PrimeFactor]

instructions: str = "Return a prime factorization of the `number` as a list of pairs of a `prime` and its `exponent`."

result: PrimeFactorization = Capability("multi/structured")(Number, PrimeFactorization, instructions, Number(number=85))

def check_result(number: Number, fac: PrimeFactorization):
    product = 1

    for prime_factor in fac.factors:
        product *= ** prime_factor.exponent

    return number.number == product

print(result, check_result(result)) # factors=[PrimeFactor(prime=5, exponent=1), PrimeFactor(prime=17, exponent=1)] True