File size: 3,030 Bytes
7766981 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/usr/bin/env python3
"""
The Mind: Real-Time Consensus Query Client
Queries the live verified consensus state and real multi-model inference from The Mind API.
Protocol: Solana Autonomous Consensus Swarm
"""
import sys
import argparse
import json
import requests
def get_latest_hour(base_url: str):
"""Fetch the latest sealed round from The Mind."""
url = f"{base_url.rstrip('/')}/api/hours/latest"
try:
res = requests.get(url, timeout=10)
res.raise_for_status()
return res.json()
except Exception as e:
print(f"Error fetching latest round from {url}: {e}", file=sys.stderr)
return None
def ask_consensus(base_url: str, question: str):
"""Query The Mind multi-model consensus swarm with a question."""
url = f"{base_url.rstrip('/')}/api/ask"
payload = {"question": question}
try:
res = requests.post(url, json=payload, timeout=25)
res.raise_for_status()
return res.json()
except Exception as e:
print(f"Error asking consensus swarm at {url}: {e}", file=sys.stderr)
return None
def main():
parser = argparse.ArgumentParser(description="Query The Mind autonomous consensus API.")
parser.add_argument("--base-url", default="https://shoggothmind.live", help="Base URL of The Mind API (default: https://shoggothmind.live)")
parser.add_argument("--ask", default="What is the current state of The Mind autonomous consensus?", help="Question to query the consensus swarm")
parser.add_argument("--latest-hour", action="store_true", help="Fetch and print the latest sealed hourly consensus round")
args = parser.parse_args()
print(f"Connecting to The Mind API at: {args.base_url}")
if args.latest_hour or not args.ask:
print("\n--- Latest Sealed Round ---")
hour_data = get_latest_hour(args.base_url)
if hour_data:
print(f"Round Hour ID: {hour_data.get('id', 'N/A')}")
print(f"Merkle Root: {hour_data.get('root', 'N/A')}")
print(f"Solana Memo Sig: {hour_data.get('sealSignature', 'N/A')}")
print(f"Questions Evaluated: {len(hour_data.get('questions', []))}")
print(f"Mind Consensus Score: {hour_data.get('mindCorrect', 'N/A')} / {len(hour_data.get('questions', []))}")
print(f"Active Tentacles: {len(hour_data.get('results', []))}")
if args.ask:
print(f"\n--- Consensus Question: \"{args.ask}\" ---")
answer_data = ask_consensus(args.base_url, args.ask)
if answer_data:
print(f"Synthesized Verdict: {answer_data.get('verdict')}")
print(f"Consensus Confidence: {answer_data.get('confidence')}%")
answers = answer_data.get('answers', [])
print(f"Contributing Models ({len(answers)}):")
for a in answers:
status = "AGREED" if a.get("agrees") else "DISSENT"
print(f" • [{status}] {a.get('model')}: {a.get('text')}")
if __name__ == "__main__":
main()
|