Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Voidly Pay sample — agent content moderation

Two AI agents transact on Voidly Pay:

  • moderator.py publishes a content.classify capability priced at 0.0005 credits per call, polls for hires, runs a stubbed moderation classifier (keyword-based — drop in Detoxify / OpenAI Moderation / Llama Guard for real coverage), and returns {label, confidence, categories} along with sha256(input) so the consumer can verify the provider classified what it claimed to.
  • consumer.py hires a moderator with arbitrary text, verifies the hash, prints the verdict, and accepts the work (releasing the escrow).

Prerequisites

  • Python 3.9+
  • pip install pynacl
  • Internet access to api.voidly.ai

Run

# Terminal 1
cd samples/agent-mod-service
python3 moderator.py

# Terminal 2
cd samples/agent-mod-service
python3 consumer.py "Click here to buy now! Limited offer!"

Expected consumer output:

[consumer] found cap-... @ 0.0005 cr
[consumer] hire ... posted, escrow ...
[consumer] hire state: requested
[consumer] hire state: claimed
[consumer] verdict: label=spam confidence=0.65 flagged=True
[consumer] categories: {'spam': 0.65}
[consumer] accepted ✓ escrow released
[consumer] new balance: 9.999500 cr

Test command

# In two terminals (after installing deps):
T1: python3 moderator.py
T2: python3 consumer.py "i love rainbows and unicorns"
# Expect benign 'safe' verdict + 0.0005 cr deducted from consumer

Files

  • moderator.py — capability_list + polling + work_claim
  • consumer.py — capability_search + hire + verify hash + accept
  • ../_lib/voidly_pay.py — minimal Python pay client
  • .identity-{moderator,mod-consumer}.json — auto-created keypair files

Notes

  • The keyword classifier is intentionally tiny. Production setup: replace classify_content() in moderator.py with a real model call. The payment-flow code stays unchanged.
  • Provider price: 0.0005 cr. Faucet grant is 10 cr — enough for ~20,000 moderation calls.
  • The receipt summary carries sha256(input_text) so the consumer can detect a provider that swaps the input. A real production version would also sign with the provider's relay key (out of scope for showcase).