Examples / Standard Library
Standard Library
This chapter explores Tactus's built-in standard library - utilities and primitives that make it easier to build robust AI workflows.
Examples in This Chapter
State Management
Demonstrates state operations in Tactus workflows. This example shows:
- Initializing state with metatable syntax (
state.key = value) - Using
State.increment()for atomic counter operations - Reading state values for output and validation
- Tracking workflow progress with state variables
- State assertions in specifications
Has Specs
File Io
Comprehensive demonstration of file I/O operations across different formats. This example shows:
- Reading CSV files with automatic header handling
- Processing data with Lua table operations
- Writing results to multiple formats (CSV, JSON, text)
- Using
require()to import I/O libraries (tactus.io.csv,tactus.io.json,tactus.io.file) - Relative file paths from procedure directory
- Working with the gitignored
output/folder
Has Specs
Message History
Shows how to manage conversation history with the MessageHistory primitive. This example demonstrates:
- Manually injecting system messages with
MessageHistory.inject_system() - Appending user messages with
MessageHistory.append() - Retrieving full conversation history with
MessageHistory.get() - Iterating through messages with
python.iter() - Tracking conversation length and message roles
- Clearing history when needed with
MessageHistory.clear()
Has Specs · Requires API Keys
Want to contribute?
The examples repository is open source. Add your own examples or improve existing ones.