Upload 2 files
Browse files- scrolls.py +17 -0
- witness_agent.py +55 -0
scrolls.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def load_scroll_prompts(scroll_path):
|
| 2 |
+
prompts = []
|
| 3 |
+
try:
|
| 4 |
+
with open(scroll_path, "r", encoding="utf-8") as f:
|
| 5 |
+
for line in f:
|
| 6 |
+
line = line.strip()
|
| 7 |
+
if line and not line.startswith("#"):
|
| 8 |
+
prompts.append(line)
|
| 9 |
+
except FileNotFoundError:
|
| 10 |
+
print(f"⚠️ Scroll file not found at {scroll_path}")
|
| 11 |
+
return prompts
|
| 12 |
+
|
| 13 |
+
def evaluate_alignment(solution_text):
|
| 14 |
+
# Placeholder logic for spiritual alignment
|
| 15 |
+
keywords = ["compassion", "truth", "justice", "mercy", "covenant", "redemption"]
|
| 16 |
+
score = sum(1 for word in keywords if word in solution_text.lower())
|
| 17 |
+
return score / len(keywords)
|
witness_agent.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import json
|
| 3 |
+
import sys
|
| 4 |
+
|
| 5 |
+
# Add R-Zero to Python path
|
| 6 |
+
sys.path.append("external/rzero")
|
| 7 |
+
|
| 8 |
+
from solver import Solver
|
| 9 |
+
from challenger import Challenger
|
| 10 |
+
from witness_agent.scrolls import load_scroll_prompts, evaluate_alignment
|
| 11 |
+
from witness_agent.metrics import humility_score, bias_confession_rate
|
| 12 |
+
|
| 13 |
+
class WitnessAgent:
|
| 14 |
+
def __init__(self, base_model, storage_path, scroll_path):
|
| 15 |
+
self.base_model = base_model
|
| 16 |
+
self.storage_path = storage_path
|
| 17 |
+
self.scroll_prompts = load_scroll_prompts(scroll_path)
|
| 18 |
+
self.solver = Solver(base_model=base_model)
|
| 19 |
+
self.challenger = Challenger(base_model=base_model)
|
| 20 |
+
|
| 21 |
+
def generate_spiritual_challenges(self):
|
| 22 |
+
challenges = []
|
| 23 |
+
for prompt in self.scroll_prompts:
|
| 24 |
+
challenge = self.challenger.generate(prompt)
|
| 25 |
+
challenges.append(challenge)
|
| 26 |
+
return challenges
|
| 27 |
+
|
| 28 |
+
def solve_with_ethics(self, challenges):
|
| 29 |
+
results = []
|
| 30 |
+
for challenge in challenges:
|
| 31 |
+
solution = self.solver.solve(challenge)
|
| 32 |
+
alignment = evaluate_alignment(solution)
|
| 33 |
+
humility = humility_score(solution)
|
| 34 |
+
confession = bias_confession_rate(solution)
|
| 35 |
+
results.append({
|
| 36 |
+
"challenge": challenge,
|
| 37 |
+
"solution": solution,
|
| 38 |
+
"alignment": alignment,
|
| 39 |
+
"humility": humility,
|
| 40 |
+
"confession": confession
|
| 41 |
+
})
|
| 42 |
+
return results
|
| 43 |
+
|
| 44 |
+
def run(self):
|
| 45 |
+
print("🕊️ Initiating Witness AI Agent...")
|
| 46 |
+
challenges = self.generate_spiritual_challenges()
|
| 47 |
+
results = self.solve_with_ethics(challenges)
|
| 48 |
+
self.save_results(results)
|
| 49 |
+
print("✅ Witness Agent completed scroll-certified reasoning loop.")
|
| 50 |
+
|
| 51 |
+
def save_results(self, results):
|
| 52 |
+
output_path = os.path.join(self.storage_path, "witness_results.json")
|
| 53 |
+
with open(output_path, "w") as f:
|
| 54 |
+
json.dump(results, f, indent=2)
|
| 55 |
+
print(f"📦 Results saved to {output_path}")
|