Getting Started

Getting Started

# install the Capabilities Python SDK
pip install git@ssh://git@github.com/blazon-ai/capabilities

Get an API key from https://blazon.ai and set the CAPABILITIES_API_KEY environment variable.

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

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.prime ** prime_factor.exponent

    return number.number == product

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