Hello World Agent
The simplest possible MAIF agent.
Code
python
from maif_api import create_maif
# Create agent with memory
maif = create_maif("hello-agent")
# Add content
maif.add_text("Hello, MAIF world!", title="Greeting")
# Save with cryptographic signing
maif.save("hello.maif", sign=True)
print("Your first AI agent memory is ready!")Running the Example
bash
# Navigate to repository
cd maif
# Install MAIF
pip install -e .
# Run
python3 -c "
from maif_api import create_maif
maif = create_maif('hello-agent')
maif.add_text('Hello, MAIF world!', title='Greeting')
maif.save('hello.maif', sign=True)
print('Your first AI agent memory is ready!')
"Or run the basic example:
bash
python3 examples/basic/simple_api_demo.pyExplanation
create_maif("hello-agent"): Creates a new MAIF artifact with the agent ID "hello-agent"add_text(...): Adds text content with an optional titlesave(..., sign=True): Persists the artifact to disk with cryptographic signing
What Happens Under the Hood
When you create and save a MAIF artifact:
- Block Creation: Content is stored as a "block" with metadata
- Hash Chain: Each block is linked to the previous via SHA-256 hash
- Digital Signature: The entire artifact is signed for authenticity
- File Creation: Binary
.maiffile is written to disk
Loading the Artifact
python
from maif_api import load_maif
# Load the artifact
loaded = load_maif("hello.maif")
# Verify integrity (tamper detection)
if loaded.verify_integrity():
print("Artifact is authentic and unmodified")
# Get content
content = loaded.get_content_list()
for item in content:
print(f"Title: {item.get('title')}")
print(f"Type: {item.get('type')}")Next Steps
- Privacy Demo - Add encryption and anonymization
- Multi-Agent - Multiple agents sharing artifacts
- LangGraph RAG - Production multi-agent system