simodocs

Building with Simo

Async and command line

AsyncClient

AsyncClient has the same methods as Client (ask, ask_json, models, health), as coroutines. max_concurrency caps requests in flight.

Python
import asyncio
from simoai import AsyncClient, Noul

async def main(texts):
    async with AsyncClient(max_concurrency=8) as c:     # reads $SIMO_API_KEY
        results = await asyncio.gather(*(c.ask(t, {"spam": Noul("This is spam")}) for t in texts))
    return [r["spam"].noul for r in results]

scores = asyncio.run(main(["Win a free iPhone!!!", "Your invoice for October is attached."]))

For a synchronous batch with thresholds, see Task.run_many.

Command line

The SDK installs a simo command (also available as python -m simoai):

cURL
export SIMO_API_KEY=simo_sk_...
simo health
simo models
simo ask request.json --full               # request.json: {"state": ..., "questions": {...}}
simo ask - --self-check < request.json     # read the request from stdin

request.json uses the wire format:

request.json
{"state": "The customer wants their money back for order A-1042.",
 "model": "simo-1-pro",
 "questions": {"refund": {"type": "noul", "instructions": "The customer asks for a refund"},
               "order": {"type": "extract", "instructions": "the order number", "kind": "text",
                         "many": false, "max_tokens": 8}}}