Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +308 -115
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -118,7 +118,6 @@ def collect_clock_jitter(n=256):
|
|
| 118 |
for _ in range(n * 4):
|
| 119 |
timestamps.append(time.perf_counter_ns())
|
| 120 |
deltas = np.diff(timestamps).astype(np.float64)
|
| 121 |
-
# Subsample
|
| 122 |
block = len(deltas) // n
|
| 123 |
signal = np.array([deltas[i*block:(i+1)*block].mean() for i in range(n)])
|
| 124 |
return (signal - signal.mean()) / (signal.std() + 1e-15)
|
|
@@ -152,7 +151,7 @@ def run_oracle_prediction(question: str, deadline: str, n_samples: int = 256, n_
|
|
| 152 |
q_hash = hashlib.sha256(question.encode()).hexdigest()
|
| 153 |
base_seed = int(q_hash[:8], 16)
|
| 154 |
|
| 155 |
-
# Collect signals from 4 sources
|
| 156 |
sources = {
|
| 157 |
"entropy": collect_entropy(n_samples, seed=base_seed),
|
| 158 |
"clock": collect_clock_jitter(n_samples),
|
|
@@ -185,10 +184,12 @@ def run_oracle_prediction(question: str, deadline: str, n_samples: int = 256, n_
|
|
| 185 |
# Confidence
|
| 186 |
mean_z = np.mean(z_scores)
|
| 187 |
if mean_z >= 10:
|
|
|
|
|
|
|
| 188 |
confidence = "HIGH"
|
| 189 |
elif mean_z >= 3:
|
| 190 |
confidence = "MEDIUM"
|
| 191 |
-
elif mean_z >= 1:
|
| 192 |
confidence = "LOW"
|
| 193 |
else:
|
| 194 |
confidence = "UNCERTAIN"
|
|
@@ -198,81 +199,234 @@ def run_oracle_prediction(question: str, deadline: str, n_samples: int = 256, n_
|
|
| 198 |
prob = 1.0 / (1.0 + np.exp(-k * mean_z))
|
| 199 |
prob = max(0.5, min(prob, 0.95))
|
| 200 |
|
| 201 |
-
return results, consensus, confidence, prob, vote_count
|
| 202 |
|
| 203 |
|
| 204 |
-
def
|
| 205 |
-
"""
|
|
|
|
|
|
|
|
|
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
## ๐ Prediction Result
|
| 218 |
-
|
| 219 |
-
| Metric | Value |
|
| 220 |
-
|--------|-------|
|
| 221 |
-
| **Consensus** | **{consensus}** |
|
| 222 |
-
| **Confidence** | {confidence} |
|
| 223 |
-
| **Probability** | {prob:.1%} |
|
| 224 |
-
| **Vote** | {votes}/4 sources |
|
| 225 |
-
|
| 226 |
-
---
|
| 227 |
-
|
| 228 |
-
## ๐ฌ Per-Source Analysis
|
| 229 |
-
|
| 230 |
-
| Source | Z-Score | Classification | Prediction |
|
| 231 |
-
|--------|---------|----------------|------------|
|
| 232 |
-
"""
|
| 233 |
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
md += f"| {name} | {data['z_score']:.2f} | {emoji} {data['classification']} | {data['prediction']} |\n"
|
| 237 |
|
| 238 |
-
|
| 239 |
-
---
|
| 240 |
-
|
| 241 |
-
## ๐งฌ Methodology
|
| 242 |
-
|
| 243 |
-
- **Algorithm:** Temporal Bispectral Operator (TBO)
|
| 244 |
-
- **Signal Sources:** 4 independent channels
|
| 245 |
-
- **Null Surrogates:** 100 permutations per source
|
| 246 |
-
- **Threshold:** z < -1.96 (95% confidence deficit)
|
| 247 |
-
|
| 248 |
-
> *"The shape is the oracle โ we reveal, not compute."*
|
| 249 |
-
|
| 250 |
-
---
|
| 251 |
-
|
| 252 |
-
๐ **Paper:** [On-Chain (BSV)](https://plugins.whatsonchain.com/api/plugin/main/657b8e90425aeed06b435a16cc759c1d594308bd815535b1628a2df7bbc75c23/0)
|
| 253 |
-
๐ **GitHub:** [OriginNeuralAI/Oracle](https://github.com/OriginNeuralAI/Oracle)
|
| 254 |
-
"""
|
| 255 |
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
|
| 259 |
def predict(question: str, deadline: str, n_samples: int, n_null: int):
|
| 260 |
"""Main prediction function for Gradio."""
|
| 261 |
|
| 262 |
if not question.strip():
|
| 263 |
-
return "โ Please enter a question."
|
| 264 |
|
| 265 |
if not deadline:
|
| 266 |
-
return "โ Please select a deadline."
|
| 267 |
|
| 268 |
try:
|
| 269 |
-
results, consensus, confidence, prob, votes = run_oracle_prediction(
|
| 270 |
question, deadline, int(n_samples), int(n_null)
|
| 271 |
)
|
| 272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
except Exception as e:
|
| 274 |
-
return f"โ Error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
|
| 277 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 278 |
# GRADIO INTERFACE
|
|
@@ -283,98 +437,137 @@ EXAMPLES = [
|
|
| 283 |
["Will there be a major AI breakthrough in 2026?", "2026-12-31", 256, 100],
|
| 284 |
["Will SpaceX land humans on Mars by 2030?", "2030-12-31", 256, 100],
|
| 285 |
["Will the Fed cut rates in Q2 2026?", "2026-06-30", 256, 100],
|
|
|
|
| 286 |
]
|
| 287 |
|
| 288 |
with gr.Blocks(
|
| 289 |
-
title="TBO Oracle",
|
| 290 |
theme=gr.themes.Base(
|
| 291 |
-
primary_hue="
|
| 292 |
-
secondary_hue="
|
| 293 |
neutral_hue="slate",
|
| 294 |
),
|
| 295 |
-
css=
|
| 296 |
-
.gradio-container { max-width: 900px !important; }
|
| 297 |
-
.gr-button-primary { background: linear-gradient(135deg, #00d4aa, #0088ff) !important; }
|
| 298 |
-
"""
|
| 299 |
) as demo:
|
| 300 |
|
| 301 |
gr.Markdown("""
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
""")
|
| 313 |
|
| 314 |
with gr.Row():
|
| 315 |
-
with gr.Column(scale=
|
| 316 |
question = gr.Textbox(
|
| 317 |
-
label="๐ฏ Question",
|
| 318 |
placeholder="Ask a binary yes/no question about the future...",
|
| 319 |
lines=2,
|
|
|
|
| 320 |
)
|
| 321 |
deadline = gr.Textbox(
|
| 322 |
-
label="๐
Deadline",
|
| 323 |
placeholder="YYYY-MM-DD",
|
| 324 |
value="2026-12-31",
|
| 325 |
)
|
| 326 |
|
| 327 |
-
with gr.Column(scale=
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
predict_btn = gr.Button("๐ฎ Query the Oracle", variant="primary", size="lg")
|
|
|
|
| 344 |
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
predict_btn.click(
|
| 348 |
fn=predict,
|
| 349 |
inputs=[question, deadline, n_samples, n_null],
|
| 350 |
-
outputs=
|
| 351 |
)
|
| 352 |
|
| 353 |
gr.Examples(
|
| 354 |
examples=EXAMPLES,
|
| 355 |
inputs=[question, deadline, n_samples, n_null],
|
|
|
|
| 356 |
)
|
| 357 |
|
| 358 |
gr.Markdown("""
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
|
| 379 |
if __name__ == "__main__":
|
| 380 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 118 |
for _ in range(n * 4):
|
| 119 |
timestamps.append(time.perf_counter_ns())
|
| 120 |
deltas = np.diff(timestamps).astype(np.float64)
|
|
|
|
| 121 |
block = len(deltas) // n
|
| 122 |
signal = np.array([deltas[i*block:(i+1)*block].mean() for i in range(n)])
|
| 123 |
return (signal - signal.mean()) / (signal.std() + 1e-15)
|
|
|
|
| 151 |
q_hash = hashlib.sha256(question.encode()).hexdigest()
|
| 152 |
base_seed = int(q_hash[:8], 16)
|
| 153 |
|
| 154 |
+
# Collect signals from 4 sources
|
| 155 |
sources = {
|
| 156 |
"entropy": collect_entropy(n_samples, seed=base_seed),
|
| 157 |
"clock": collect_clock_jitter(n_samples),
|
|
|
|
| 184 |
# Confidence
|
| 185 |
mean_z = np.mean(z_scores)
|
| 186 |
if mean_z >= 10:
|
| 187 |
+
confidence = "VERY HIGH"
|
| 188 |
+
elif mean_z >= 5:
|
| 189 |
confidence = "HIGH"
|
| 190 |
elif mean_z >= 3:
|
| 191 |
confidence = "MEDIUM"
|
| 192 |
+
elif mean_z >= 1.5:
|
| 193 |
confidence = "LOW"
|
| 194 |
else:
|
| 195 |
confidence = "UNCERTAIN"
|
|
|
|
| 199 |
prob = 1.0 / (1.0 + np.exp(-k * mean_z))
|
| 200 |
prob = max(0.5, min(prob, 0.95))
|
| 201 |
|
| 202 |
+
return results, consensus, confidence, prob, vote_count, mean_z
|
| 203 |
|
| 204 |
|
| 205 |
+
def create_source_chart(results):
|
| 206 |
+
"""Create a visual bar chart of z-scores."""
|
| 207 |
+
import matplotlib
|
| 208 |
+
matplotlib.use('Agg')
|
| 209 |
+
import matplotlib.pyplot as plt
|
| 210 |
|
| 211 |
+
sources = list(results.keys())
|
| 212 |
+
z_scores = [results[s]["z_score"] for s in sources]
|
| 213 |
+
colors = []
|
| 214 |
+
for z in z_scores:
|
| 215 |
+
if z < -1.96:
|
| 216 |
+
colors.append('#10b981') # green - deficit
|
| 217 |
+
elif z > 1.96:
|
| 218 |
+
colors.append('#8b5cf6') # purple - excess
|
| 219 |
+
else:
|
| 220 |
+
colors.append('#6b7280') # gray - normal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
+
fig, ax = plt.subplots(figsize=(8, 4), facecolor='#0f172a')
|
| 223 |
+
ax.set_facecolor('#0f172a')
|
|
|
|
| 224 |
|
| 225 |
+
bars = ax.barh(sources, z_scores, color=colors, height=0.6, edgecolor='#1e293b', linewidth=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
# Add threshold lines
|
| 228 |
+
ax.axvline(x=-1.96, color='#10b981', linestyle='--', alpha=0.5, label='Deficit threshold')
|
| 229 |
+
ax.axvline(x=1.96, color='#8b5cf6', linestyle='--', alpha=0.5, label='Excess threshold')
|
| 230 |
+
ax.axvline(x=0, color='#475569', linestyle='-', alpha=0.3)
|
| 231 |
+
|
| 232 |
+
# Style
|
| 233 |
+
ax.set_xlabel('Z-Score', color='#e2e8f0', fontsize=12)
|
| 234 |
+
ax.set_title('Source Analysis', color='#e2e8f0', fontsize=14, fontweight='bold')
|
| 235 |
+
ax.tick_params(colors='#e2e8f0')
|
| 236 |
+
ax.spines['bottom'].set_color('#334155')
|
| 237 |
+
ax.spines['left'].set_color('#334155')
|
| 238 |
+
ax.spines['top'].set_visible(False)
|
| 239 |
+
ax.spines['right'].set_visible(False)
|
| 240 |
+
|
| 241 |
+
# Add value labels
|
| 242 |
+
for bar, z in zip(bars, z_scores):
|
| 243 |
+
width = bar.get_width()
|
| 244 |
+
ax.text(width + 0.1 if width >= 0 else width - 0.5, bar.get_y() + bar.get_height()/2,
|
| 245 |
+
f'{z:.2f}', ha='left' if width >= 0 else 'right', va='center',
|
| 246 |
+
color='#e2e8f0', fontsize=10)
|
| 247 |
+
|
| 248 |
+
plt.tight_layout()
|
| 249 |
+
return fig
|
| 250 |
|
| 251 |
|
| 252 |
def predict(question: str, deadline: str, n_samples: int, n_null: int):
|
| 253 |
"""Main prediction function for Gradio."""
|
| 254 |
|
| 255 |
if not question.strip():
|
| 256 |
+
return "โ Please enter a question.", None, "", ""
|
| 257 |
|
| 258 |
if not deadline:
|
| 259 |
+
return "โ Please select a deadline.", None, "", ""
|
| 260 |
|
| 261 |
try:
|
| 262 |
+
results, consensus, confidence, prob, votes, mean_z = run_oracle_prediction(
|
| 263 |
question, deadline, int(n_samples), int(n_null)
|
| 264 |
)
|
| 265 |
+
|
| 266 |
+
# Create chart
|
| 267 |
+
chart = create_source_chart(results)
|
| 268 |
+
|
| 269 |
+
# Big result display
|
| 270 |
+
if consensus == "YES":
|
| 271 |
+
result_emoji = "โ
"
|
| 272 |
+
result_color = "green"
|
| 273 |
+
else:
|
| 274 |
+
result_emoji = "โ"
|
| 275 |
+
result_color = "red"
|
| 276 |
+
|
| 277 |
+
big_result = f"""
|
| 278 |
+
<div style="text-align: center; padding: 30px; background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); border-radius: 20px; border: 2px solid #334155; margin: 20px 0;">
|
| 279 |
+
<div style="font-size: 72px; margin-bottom: 10px;">{result_emoji}</div>
|
| 280 |
+
<div style="font-size: 48px; font-weight: bold; color: {'#10b981' if consensus == 'YES' else '#ef4444'}; text-shadow: 0 0 20px {'#10b98155' if consensus == 'YES' else '#ef444455'};">
|
| 281 |
+
{consensus}
|
| 282 |
+
</div>
|
| 283 |
+
<div style="font-size: 18px; color: #94a3b8; margin-top: 10px;">
|
| 284 |
+
Confidence: <span style="color: #e2e8f0; font-weight: bold;">{confidence}</span> โข
|
| 285 |
+
Probability: <span style="color: #e2e8f0; font-weight: bold;">{prob:.1%}</span>
|
| 286 |
+
</div>
|
| 287 |
+
<div style="font-size: 14px; color: #64748b; margin-top: 5px;">
|
| 288 |
+
{votes}/4 sources agree โข Mean |z| = {mean_z:.2f}
|
| 289 |
+
</div>
|
| 290 |
+
</div>
|
| 291 |
+
"""
|
| 292 |
+
|
| 293 |
+
# Detailed breakdown
|
| 294 |
+
details = f"""
|
| 295 |
+
### ๐ Source Breakdown
|
| 296 |
+
|
| 297 |
+
| Source | Z-Score | Status | Vote |
|
| 298 |
+
|--------|---------|--------|------|
|
| 299 |
+
"""
|
| 300 |
+
for name, data in results.items():
|
| 301 |
+
emoji = "๐ข" if data["classification"] == "DEFICIT" else "โช" if data["classification"] == "NORMAL" else "๐ฃ"
|
| 302 |
+
vote_emoji = "โ" if data["prediction"] == "YES" else "โ"
|
| 303 |
+
details += f"| {name.title()} | {data['z_score']:.2f} | {emoji} {data['classification']} | {vote_emoji} {data['prediction']} |\n"
|
| 304 |
+
|
| 305 |
+
details += f"""
|
| 306 |
+
---
|
| 307 |
+
|
| 308 |
+
**Question:** {question}
|
| 309 |
+
**Deadline:** {deadline}
|
| 310 |
+
**Timestamp:** {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')}
|
| 311 |
+
|
| 312 |
+
---
|
| 313 |
+
|
| 314 |
+
<details>
|
| 315 |
+
<summary>๐ฌ Methodology</summary>
|
| 316 |
+
|
| 317 |
+
- **Algorithm:** Temporal Bispectral Operator (TBO)
|
| 318 |
+
- **Signal Sources:** 4 independent channels (entropy, clock, hash_chain, cyclotomic)
|
| 319 |
+
- **Null Surrogates:** {n_null} permutations per source
|
| 320 |
+
- **Threshold:** z < -1.96 (95% confidence deficit)
|
| 321 |
+
- **Philosophy:** *"The shape is the oracle โ we reveal, not compute."*
|
| 322 |
+
|
| 323 |
+
</details>
|
| 324 |
+
"""
|
| 325 |
+
|
| 326 |
+
return big_result, chart, details, f"๐ฎ Prediction: {consensus} ({confidence})"
|
| 327 |
+
|
| 328 |
except Exception as e:
|
| 329 |
+
return f"โ Error: {str(e)}", None, "", ""
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 333 |
+
# CUSTOM CSS
|
| 334 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 335 |
|
| 336 |
+
CUSTOM_CSS = """
|
| 337 |
+
/* Dark theme overrides */
|
| 338 |
+
.gradio-container {
|
| 339 |
+
background: linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%) !important;
|
| 340 |
+
max-width: 1000px !important;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
/* Header styling */
|
| 344 |
+
.prose h1 {
|
| 345 |
+
background: linear-gradient(90deg, #10b981, #06b6d4, #8b5cf6);
|
| 346 |
+
-webkit-background-clip: text;
|
| 347 |
+
-webkit-text-fill-color: transparent;
|
| 348 |
+
background-clip: text;
|
| 349 |
+
font-size: 2.5rem !important;
|
| 350 |
+
text-align: center;
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
/* Input styling */
|
| 354 |
+
.gr-input, .gr-textarea {
|
| 355 |
+
background: #1e293b !important;
|
| 356 |
+
border: 1px solid #334155 !important;
|
| 357 |
+
color: #e2e8f0 !important;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
.gr-input:focus, .gr-textarea:focus {
|
| 361 |
+
border-color: #10b981 !important;
|
| 362 |
+
box-shadow: 0 0 0 3px #10b98133 !important;
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
/* Button styling */
|
| 366 |
+
.gr-button-primary {
|
| 367 |
+
background: linear-gradient(135deg, #10b981 0%, #06b6d4 50%, #8b5cf6 100%) !important;
|
| 368 |
+
border: none !important;
|
| 369 |
+
font-size: 1.2rem !important;
|
| 370 |
+
padding: 15px 30px !important;
|
| 371 |
+
transition: all 0.3s ease !important;
|
| 372 |
+
}
|
| 373 |
+
|
| 374 |
+
.gr-button-primary:hover {
|
| 375 |
+
transform: translateY(-2px) !important;
|
| 376 |
+
box-shadow: 0 10px 40px -10px #10b98177 !important;
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
/* Card styling */
|
| 380 |
+
.gr-box {
|
| 381 |
+
background: #1e293b !important;
|
| 382 |
+
border: 1px solid #334155 !important;
|
| 383 |
+
border-radius: 12px !important;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
/* Slider styling */
|
| 387 |
+
.gr-slider input[type="range"] {
|
| 388 |
+
background: linear-gradient(90deg, #10b981, #8b5cf6) !important;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
/* Example table */
|
| 392 |
+
.gr-samples-table {
|
| 393 |
+
background: #1e293b !important;
|
| 394 |
+
}
|
| 395 |
+
|
| 396 |
+
/* Accordion */
|
| 397 |
+
.gr-accordion {
|
| 398 |
+
background: #1e293b !important;
|
| 399 |
+
border: 1px solid #334155 !important;
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
/* Animations */
|
| 403 |
+
@keyframes pulse-glow {
|
| 404 |
+
0%, 100% { box-shadow: 0 0 20px #10b98133; }
|
| 405 |
+
50% { box-shadow: 0 0 40px #10b98155; }
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
.prediction-result {
|
| 409 |
+
animation: pulse-glow 2s infinite;
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/* Quote styling */
|
| 413 |
+
blockquote {
|
| 414 |
+
border-left: 4px solid #10b981 !important;
|
| 415 |
+
background: #1e293b !important;
|
| 416 |
+
padding: 15px !important;
|
| 417 |
+
margin: 20px 0 !important;
|
| 418 |
+
border-radius: 0 8px 8px 0 !important;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
/* Links */
|
| 422 |
+
a {
|
| 423 |
+
color: #10b981 !important;
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
a:hover {
|
| 427 |
+
color: #06b6d4 !important;
|
| 428 |
+
}
|
| 429 |
+
"""
|
| 430 |
|
| 431 |
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 432 |
# GRADIO INTERFACE
|
|
|
|
| 437 |
["Will there be a major AI breakthrough in 2026?", "2026-12-31", 256, 100],
|
| 438 |
["Will SpaceX land humans on Mars by 2030?", "2030-12-31", 256, 100],
|
| 439 |
["Will the Fed cut rates in Q2 2026?", "2026-06-30", 256, 100],
|
| 440 |
+
["Will a nuclear fusion plant achieve net energy gain by 2027?", "2027-12-31", 256, 100],
|
| 441 |
]
|
| 442 |
|
| 443 |
with gr.Blocks(
|
| 444 |
+
title="๐ฎ TBO Oracle",
|
| 445 |
theme=gr.themes.Base(
|
| 446 |
+
primary_hue="emerald",
|
| 447 |
+
secondary_hue="cyan",
|
| 448 |
neutral_hue="slate",
|
| 449 |
),
|
| 450 |
+
css=CUSTOM_CSS,
|
|
|
|
|
|
|
|
|
|
| 451 |
) as demo:
|
| 452 |
|
| 453 |
gr.Markdown("""
|
| 454 |
+
# ๐ฎ TBO Oracle
|
| 455 |
+
|
| 456 |
+
### Temporal Bispectral Operator โ Blockchain-Anchored Predictions
|
| 457 |
+
|
| 458 |
+
> *"The shape is the oracle โ we reveal, not compute."*
|
| 459 |
+
|
| 460 |
+
TBO Oracle uses **bispectral analysis** and **Two-State Vector Formalism (TSVF)**
|
| 461 |
+
to detect retrocausal signals in independent noise sources. When sources converge
|
| 462 |
+
despite their independence, the topology reveals the answer.
|
| 463 |
+
""")
|
|
|
|
| 464 |
|
| 465 |
with gr.Row():
|
| 466 |
+
with gr.Column(scale=3):
|
| 467 |
question = gr.Textbox(
|
| 468 |
+
label="๐ฏ Your Question",
|
| 469 |
placeholder="Ask a binary yes/no question about the future...",
|
| 470 |
lines=2,
|
| 471 |
+
max_lines=4,
|
| 472 |
)
|
| 473 |
deadline = gr.Textbox(
|
| 474 |
+
label="๐
Resolution Deadline",
|
| 475 |
placeholder="YYYY-MM-DD",
|
| 476 |
value="2026-12-31",
|
| 477 |
)
|
| 478 |
|
| 479 |
+
with gr.Column(scale=2):
|
| 480 |
+
with gr.Accordion("โ๏ธ Advanced Settings", open=False):
|
| 481 |
+
n_samples = gr.Slider(
|
| 482 |
+
label="Signal Length",
|
| 483 |
+
minimum=64,
|
| 484 |
+
maximum=512,
|
| 485 |
+
value=256,
|
| 486 |
+
step=64,
|
| 487 |
+
info="More samples = more precision"
|
| 488 |
+
)
|
| 489 |
+
n_null = gr.Slider(
|
| 490 |
+
label="Null Surrogates",
|
| 491 |
+
minimum=50,
|
| 492 |
+
maximum=200,
|
| 493 |
+
value=100,
|
| 494 |
+
step=25,
|
| 495 |
+
info="More surrogates = better z-score estimation"
|
| 496 |
+
)
|
| 497 |
|
| 498 |
predict_btn = gr.Button("๐ฎ Query the Oracle", variant="primary", size="lg")
|
| 499 |
+
status = gr.Textbox(label="Status", visible=False)
|
| 500 |
|
| 501 |
+
# Results section
|
| 502 |
+
with gr.Row():
|
| 503 |
+
result_html = gr.HTML(label="Prediction")
|
| 504 |
+
|
| 505 |
+
with gr.Row():
|
| 506 |
+
with gr.Column(scale=1):
|
| 507 |
+
chart = gr.Plot(label="๐ Z-Score Analysis")
|
| 508 |
+
with gr.Column(scale=1):
|
| 509 |
+
details = gr.Markdown(label="Details")
|
| 510 |
|
| 511 |
predict_btn.click(
|
| 512 |
fn=predict,
|
| 513 |
inputs=[question, deadline, n_samples, n_null],
|
| 514 |
+
outputs=[result_html, chart, details, status],
|
| 515 |
)
|
| 516 |
|
| 517 |
gr.Examples(
|
| 518 |
examples=EXAMPLES,
|
| 519 |
inputs=[question, deadline, n_samples, n_null],
|
| 520 |
+
label="๐ก Example Questions"
|
| 521 |
)
|
| 522 |
|
| 523 |
gr.Markdown("""
|
| 524 |
+
---
|
| 525 |
+
|
| 526 |
+
### ๐ How It Works
|
| 527 |
+
|
| 528 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 20px 0;">
|
| 529 |
+
|
| 530 |
+
<div style="background: #1e293b; padding: 20px; border-radius: 12px; border: 1px solid #334155;">
|
| 531 |
+
<h4 style="color: #10b981; margin-top: 0;">๐ Bispectral Analysis</h4>
|
| 532 |
+
<p style="color: #94a3b8; font-size: 14px;">Detects third-order phase coupling invisible to standard power spectrum analysis.</p>
|
| 533 |
+
</div>
|
| 534 |
+
|
| 535 |
+
<div style="background: #1e293b; padding: 20px; border-radius: 12px; border: 1px solid #334155;">
|
| 536 |
+
<h4 style="color: #06b6d4; margin-top: 0;">๐ Hโ=0 Topology</h4>
|
| 537 |
+
<p style="color: #94a3b8; font-size: 14px;">Manifold closure condition ensuring prediction convergence through topological constraints.</p>
|
| 538 |
+
</div>
|
| 539 |
+
|
| 540 |
+
<div style="background: #1e293b; padding: 20px; border-radius: 12px; border: 1px solid #334155;">
|
| 541 |
+
<h4 style="color: #8b5cf6; margin-top: 0;">โณ TSVF Framework</h4>
|
| 542 |
+
<p style="color: #94a3b8; font-size: 14px;">Two-State Vector Formalism from quantum mechanics enables retrocausal signal detection.</p>
|
| 543 |
+
</div>
|
| 544 |
+
|
| 545 |
+
<div style="background: #1e293b; padding: 20px; border-radius: 12px; border: 1px solid #334155;">
|
| 546 |
+
<h4 style="color: #f59e0b; margin-top: 0;">๐ก 4 Independent Sources</h4>
|
| 547 |
+
<p style="color: #94a3b8; font-size: 14px;">Entropy, clock jitter, hash chains, and cyclotomic signals vote independently.</p>
|
| 548 |
+
</div>
|
| 549 |
+
|
| 550 |
+
</div>
|
| 551 |
+
|
| 552 |
+
### ๐ Track Record
|
| 553 |
+
|
| 554 |
+
| Date | Question | Prediction | Outcome |
|
| 555 |
+
|------|----------|------------|---------|
|
| 556 |
+
| Feb 2026 | Canada wins Hockey Gold | NO | โ
**Correct** (USA won) |
|
| 557 |
+
| Mar 2026 | BTC >$100k | YES | โณ Pending |
|
| 558 |
+
|
| 559 |
+
---
|
| 560 |
+
|
| 561 |
+
<div style="text-align: center; color: #64748b; font-size: 14px;">
|
| 562 |
+
|
| 563 |
+
๐ [On-Chain Paper (BSV)](https://whatsonchain.com) โข
|
| 564 |
+
๐ [GitHub](https://github.com/OriginNeuralAI/Oracle) โข
|
| 565 |
+
๐ง [SmartLedger Solutions](https://smartledger.solutions)
|
| 566 |
+
|
| 567 |
+
*Built by Bryan Daugherty | SmartLedger Solutions | 2026*
|
| 568 |
+
|
| 569 |
+
</div>
|
| 570 |
+
""")
|
| 571 |
|
| 572 |
if __name__ == "__main__":
|
| 573 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ numpy>=1.24,<2.0
|
|
| 2 |
scipy>=1.10,<2.0
|
| 3 |
gradio==4.44.0
|
| 4 |
huggingface_hub>=0.23.0,<0.30.0
|
|
|
|
|
|
| 2 |
scipy>=1.10,<2.0
|
| 3 |
gradio==4.44.0
|
| 4 |
huggingface_hub>=0.23.0,<0.30.0
|
| 5 |
+
matplotlib>=3.7.0
|