Skip to main content

Helpers for loading and validating OpenVerb verb libraries

Project description

OpenVerb

Lightweight helpers for working with OpenVerb verb libraries.

OpenVerb is an open, text-first standard for describing what actions an AI is allowed to perform inside an application. Instead of wiring one-off "tools" or plugins, applications expose verb libraries: JSON files that describe actions (verbs), their parameters, and their results.

This package provides Python helpers for loading, validating, and executing OpenVerb actions.

Installation

pip install openverb

Quick Start

from openverb import load_library, create_executor

# Load library
library = load_library({
    'namespace': 'my.app',
    'version': '1.0.0',
    'verbs': [
        {
            'name': 'create_item',
            'category': 'data',
            'description': 'Create a new item',
            'params': {
                'collection': {'type': 'string', 'required': True},
                'data': {'type': 'object', 'required': True}
            }
        }
    ]
})

# Create executor
executor = create_executor(library)

# Register handler
def create_item_handler(params):
    collection = params['collection']
    data = params['data']
    # Your implementation here
    return {
        'verb': 'create_item',
        'status': 'success',
        'data': {'id': '123', **data}
    }

executor.register('create_item', create_item_handler)

# Execute action
action = {
    'verb': 'create_item',
    'params': {
        'collection': 'jobs',
        'data': {
            'client': 'Smith Construction',
            'job_type': 'Boundary Survey'
        }
    }
}

result = executor.execute(action)
print(result)
# {'verb': 'create_item', 'status': 'success', 'data': {'id': '123', ...}}

Core Concepts

From the OpenVerb specification:

  • Verb – An action the AI can perform (e.g. create_item, navigate, create_file)
  • Verb Library – A JSON file that groups related verbs under a namespace (e.g. openverb.core)
  • Action – A single request from the AI to execute a verb with parameters
  • Executor – Your code that takes (verb, params) and performs the real work

API Reference

load_library(source)

Load a verb library from a JSON string, dict, or file path.

# From dict
library = load_library({'namespace': 'test', 'verbs': [...]})

# From JSON string
library = load_library('{"namespace": "test", "verbs": [...]}')

# From file
library = load_library('openverb.core.json')
library = load_library(Path('openverb.core.json'))

build_registry(library)

Build a verb registry for quick lookup by verb name.

registry = build_registry(library)
verb_def = registry['create_item']

validate_action(action, verb_def)

Validate an action against a verb definition.

validation = validate_action(action, verb_def)
if not validation['valid']:
    print(validation['error'])

create_executor(library)

Create a simple executor with handler registration.

executor = create_executor(library)

# Register handlers
executor.register('create_item', lambda params: {
    'verb': 'create_item',
    'status': 'success',
    'data': {...}
})

# Execute actions
result = executor.execute(action)

Executor methods:

  • register(verb_name, handler) - Register a handler for a verb
  • execute(action) - Execute an action
  • get_registry() - Get the verb registry
  • get_verbs() - Get list of verb names
  • get_verb(name) - Get a specific verb definition

load_core_library()

Load the official openverb.core library.

from openverb import load_core_library

core = load_core_library()
print(core['namespace'])  # 'openverb.core'

Type Hints

Full type hint support:

from openverb import (
    VerbLibrary,
    Verb,
    Action,
    ActionResult,
    VerbHandler
)

library: VerbLibrary = {...}
action: Action = {'verb': 'create_item', 'params': {...}}

def handler(params: dict) -> ActionResult:
    return {'verb': '...', 'status': 'success', 'data': {...}}

Complete Example

from openverb import load_library, create_executor

# Simple in-memory database
db = {'jobs': []}

# Load library
library = load_library({
    'namespace': 'my.app',
    'version': '1.0.0',
    'verbs': [
        {
            'name': 'create_item',
            'category': 'data',
            'description': 'Create an item',
            'params': {
                'collection': {'type': 'string', 'required': True},
                'data': {'type': 'object', 'required': True}
            }
        },
        {
            'name': 'list_items',
            'category': 'data',
            'description': 'List items',
            'params': {
                'collection': {'type': 'string', 'required': True}
            }
        }
    ]
})

# Create executor
executor = create_executor(library)

# Register handlers
def create_item(params):
    collection = params['collection']
    data = params['data']
    if collection not in db:
        db[collection] = []
    
    item_id = str(len(db[collection]))
    item = {'id': item_id, **data}
    db[collection].append(item)
    
    return {
        'verb': 'create_item',
        'status': 'success',
        'data': item
    }

def list_items(params):
    collection = params['collection']
    return {
        'verb': 'list_items',
        'status': 'success',
        'items': db.get(collection, [])
    }

executor.register('create_item', create_item)
executor.register('list_items', list_items)

# Execute actions
result1 = executor.execute({
    'verb': 'create_item',
    'params': {
        'collection': 'jobs',
        'data': {
            'client': 'Smith Construction',
            'job_type': 'Boundary Survey'
        }
    }
})
print('Created:', result1)

result2 = executor.execute({
    'verb': 'list_items',
    'params': {'collection': 'jobs'}
})
print('Jobs:', result2)

Using with AI Models

# 1. Provide the library to the AI in your prompt
verbs = executor.get_verbs()
prompt = f"""
Available actions: {', '.join(verbs)}

You can perform these actions by responding with:
{{"verb": "create_item", "params": {{"collection": "jobs", "data": {{...}}}}}}
"""

# 2. Parse AI response and execute
import json
ai_response = '{"verb":"create_item","params":{...}}'
action = json.loads(ai_response)
result = executor.execute(action)

OpenVerb Core Library

The official openverb.core library includes these verbs:

Data:

  • create_item - Create a new item in a collection
  • get_item - Fetch a single item by ID
  • list_items - List items with optional filtering
  • update_item - Update fields on an item
  • delete_item - Delete an item
  • search_items - Search items with free-text query

File System:

  • create_file - Create a new file
  • read_file - Read file contents
  • write_file - Write/overwrite file
  • delete_file - Delete a file

Navigation:

  • navigate - Navigate to a route/view

Communication:

  • notify_user - Show user notification

System:

  • log_message - Write to application log
  • run_command - Execute pre-approved command

Analysis:

  • calculate - Perform calculations

NLP:

  • summarize_text - Generate text summaries
  • transform_text - Transform text (rewrite, translate, etc.)

Load it with:

from openverb import load_core_library
core = load_core_library()

Flask Example

from flask import Flask, request, jsonify
from openverb import create_executor, load_core_library

app = Flask(__name__)
executor = create_executor(load_core_library())

# Register handlers
executor.register('create_item', create_item_handler)
executor.register('list_items', list_items_handler)

@app.route('/execute', methods=['POST'])
def execute_action():
    action = request.json
    result = executor.execute(action)
    return jsonify(result)

if __name__ == '__main__':
    app.run()

FastAPI Example

from fastapi import FastAPI
from openverb import create_executor, load_core_library

app = FastAPI()
executor = create_executor(load_core_library())

# Register handlers
executor.register('create_item', create_item_handler)

@app.post("/execute")
async def execute_action(action: dict):
    result = executor.execute(action)
    return result

Philosophy

From the OpenVerb README:

AI already "thinks" and talks in verbs. OpenVerb turns that into a clear, reusable action API.

OpenVerb is:

  • Language-native – Verbs are how humans and AIs naturally express actions
  • Text-first – Works with any LLM that can read/write text
  • Framework-agnostic – Use with agents, tools, MCP, or your own executor
  • Simple JSON – Verb libraries are just JSON files

Links

License

MIT © Roman Hancel

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

openverb-0.1.0.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

openverb-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file openverb-0.1.0.tar.gz.

File metadata

  • Download URL: openverb-0.1.0.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for openverb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4daad7b33f585a88be7344e35094f0c25c22d15fddc007bafb74bcc752169f5
MD5 cca00b8cf95eef05c4e29325d813bddb
BLAKE2b-256 8c6a00318485b30274dbb2ea085b2c8199ca17679b72c39b94fb115d174ab860

See more details on using hashes here.

File details

Details for the file openverb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openverb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for openverb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91e8af80c11233da078e538936333eeccccc241f96c7f94ed16ac48e711fba23
MD5 79e22912acd3892cc3ecf0ce6b160973
BLAKE2b-256 cf2e955b6ba0440adab15e229c81a6bd060c7b9de5827c91832a0249cbd2f4e3

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