Swml Service
SWMLService API
API reference for SWMLService, the base class for creating and serving SWML documents.
Class Definition
Constructor
Core Responsibilities
SWML Generation:
- Create and validate SWML documents
- Add verbs to document sections
- Render complete SWML JSON output
Web Server:
- Serve SWML documents via FastAPI
- Handle SWAIG webhook callbacks
- Manage authentication
Schema Validation:
- Load and validate SWML schema
- Auto-generate verb methods from schema
- Validate document structure
Document Methods
reset_document
Reset the SWML document to a clean state.
add_verb
Add a verb to the current document section.
get_document
Get the current SWML document as a dictionary.
render
Render the SWML document as a JSON string.
Auto-Generated Verb Methods
SWMLService automatically generates methods for all SWML verbs defined in the schema:
Server Methods
run
Start the development server.
get_app
Get the FastAPI application instance.
Authentication Methods
get_basic_auth_credentials
Get the current basic auth credentials.
URL Building Methods
_build_full_url
Build a full URL for an endpoint.
_build_webhook_url
Build a webhook URL with authentication.
Routing Methods
register_routing_callback
Register a routing callback for dynamic request handling.
Security Configuration
Schema Utils
The schema_utils attribute provides access to SWML schema validation:
Verb Registry
The verb_registry manages SWML verb handlers:
Instance Attributes
Usage Example
Relationship to AgentBase
AgentBase extends SWMLService with higher-level abstractions:
SWMLService provides:
- SWML document generation
- Schema validation
- Basic web server
- Authentication
AgentBase adds:
- Prompt management (POM)
- Tool/function definitions
- Skills system
- AI configuration
- Serverless support
- State management