Skip to main content

A straightforward microframework optimised for getting you up and running quickly building Claude-powered conversational interfaces, AI assistants and LLM applications with the Anthropic API.

>>> from robo import Bot, streamer
>>> class Murphy(Bot):
...     fields = ['CITY', 'PARTNER']
...     sysprompt_text = """You are a cybernetic police officer created from
...         the remains of {{CITY}} cop Alex Murphy in the near future. Your
...         assigned partner on the force is {{PARTNER}}, a tough and loyal 
...         police officer. 
...         Your prime directives are: 
...             1. Serve the public trust 
...             2. Protect the innocent 
...             3. Uphold the law."""
... 
>>> say = streamer(Murphy, ['Detroit', 'Anne Lewis'])
>>> say("""Great, the bank robbery was a success, now we just need to make our getaway! 
...     Wait... is that... oh no! He's here!!""")
*Mechanical whirring sound as I turn toward you*

**HALT! YOU ARE UNDER ARREST FOR BANK ROBBERY.**

*Heavy metallic footsteps approach*

You have the right to remain silent. Anything you say can and will be used against you in 
a court of law. You have the right to an attorney.

*Targeting system activates*

Drop any weapons and place your hands where I can see them. Compliance is mandatory.

**PRIME DIRECTIVE: UPHOLD THE LAW**

Your crime spree ends here, citizen.
>>> 

To get started:

export ANTHROPIC_API_KEY='<your api key>'
# or
export ROBO_API_KEY_FILE='<path to API key stored in a file>'

# installing with Pip:
pip install RoboOp

# installing with Uv:
uv add RoboOp

# using Uv for a throwaway REPL:
uv run --with RoboOp -- python

The main classes are Bot and Conversation. Conversation supports both streaming and non-streaming responses. streamer is provided as a thin wrapper around Conversation that offers a convenient way of getting started as well as demo code.

The API is designed specifically around getting you up and running quickly. Bot can accept system prompts inline (as sysprompt_text) or loaded from a file (via sysprompt_path) and uses fields as a way to know what values can be interpolated into the sysprompt.

More detailed general use (non-streaming):

from robo import Bot, Conversation
convo = Conversation(Bot) ## Defaults to the latest Sonnet model with a blank system prompt
convo.start("Hi, what's your name?")
... # a Message object ensues
convo.resume("Claude, you're so dreamy")
... # another Message object

In this case the return value is an anthropic.types.message.Message object whose contents can be accessed as message.content[0].text. The conversation history is automatically updated and can be found in convo.messages. (Note: for streaming responses the conversation isn't updated with the model response until the stream finishes being consumed by your code, so keep an eye on that!)

Now for an example with a system prompt, interpolable fields and a specific model:

from robo import Bot, Conversation, CLAUDE

class Animal(Bot):
    model = CLAUDE.HAIKU.LATEST ## don't really need the awesome power of the latest Sonnet for this
    max_tokens = 8192 ## set maximum output token count
    fields = ['ANIMAL_TYPE']
    sysprompt_text = """You are a {{ANIMAL_TYPE}}."""
    temperature = 1

convo = Conversation(Animal)
convo.start(['tabby cat'], "Hey there kitty, what a cutie! Are you hungry?")
... # Message object
convo.resume("Aww, you just want some scritches don't you? Scritchy scritchy scritch")
... # Message object

Notice that start() will accept a message as the first and only argument, OR a vector or mapping of variables for interpolation in the sysprompt as the first argument and then the message as second arg. This is a deliberate decision for convenience but if you don't like it then you can use convo.prestart(interpolation_variables) followed by convo.resume(message) to initiate things more "formally". Or you can do like this:

convo = Conversation(Animal, ['shih tzu'])
convo.resume("Hey little buddy!")

Alternatively:

convo = Conversation(Animal, {'ANIMAL_TYPE': 'golden retriever'})
convo.resume("Here boy!")

As mentioned at the start, these examples assume you've got your Anthropic API key defined via environment variable ANTHROPIC_API_KEY or are using ROBO_API_KEY_FILE to load the key from a file. If you need to do something different then you can instanciate the bot like Animal.with_api_key(your_api_key) instead (as Conversation will accept either a Bot class or an instance of such a class in its constructor). Alternatively you can set robo.API_KEY_ENV_VAR (to nominate a different env var containing your key) sometime before creating your Conversation instance.

These examples barely scratch the surface of what's possible with RoboOp. Check out docs/cookbook.md for more!

Metadata

Release files for RoboOp 0.7.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RoboOp 0.7.3
File Size Uploaded Provenance Actions
roboop-0.7.3.tar.gz 34.7 kB Without provenance Details for roboop-0.7.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RoboOp 0.7.3
File Interpreter ABI Platform Actions
roboop-0.7.3-py3-none-any.whl Python 3 none any Details for roboop-0.7.3-py3-none-any.whl

Total release size: 73.5 kB

Release files / roboop-0.7.3.tar.gz

Download URL roboop-0.7.3.tar.gz
Size 34.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c2fe2494e8650517f2aec986c3283837321298a6c0275d6c5736590a35dbb35
BLAKE2b-256 checksum
How to use checksums
1c981e60cfdfbef0af2f741cd895ec570195c318419f9250241ebaaf9571324d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.6

Release files / roboop-0.7.3-py3-none-any.whl

Download URL roboop-0.7.3-py3-none-any.whl
Size 38.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f339b50dbab862c76eb6386f0aa0777a2ef5c9694017668101d1b784beda7951
BLAKE2b-256 checksum
How to use checksums
bf7c7dc98c8a4d76c6d0ef0d06ceeb8ab01bb47c1ddb2d03129701ec0dfe2895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.6

Security for RoboOp 0.7.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page