Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,10 @@ import gradio as gr
|
|
| 2 |
from pypdf import PdfReader
|
| 3 |
|
| 4 |
class MetamorphicPhoenix:
|
| 5 |
-
def
|
| 6 |
-
# Organ 1: Sensory Cortex -
|
| 7 |
if file_obj is None:
|
| 8 |
-
return ""
|
| 9 |
try:
|
| 10 |
reader = PdfReader(file_obj.name)
|
| 11 |
text = ""
|
|
@@ -13,42 +13,39 @@ class MetamorphicPhoenix:
|
|
| 13 |
text += page.extract_text() or ""
|
| 14 |
return text.strip()
|
| 15 |
except Exception as e:
|
| 16 |
-
return f"
|
| 17 |
|
| 18 |
-
def
|
| 19 |
-
# Organ 3: Compliance Spine
|
| 20 |
-
if not assertion or not
|
| 21 |
-
return "Awaiting input..."
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
if assertion.lower().strip() not in
|
| 25 |
-
return "
|
| 26 |
-
return "
|
| 27 |
|
| 28 |
-
# Initialize
|
| 29 |
system = MetamorphicPhoenix()
|
| 30 |
|
|
|
|
| 31 |
with gr.Blocks(title="Metamorphic Phoenix") as demo:
|
| 32 |
-
gr.Markdown("# THE METAMORPHIC PHOENIX
|
|
|
|
| 33 |
|
| 34 |
with gr.Row():
|
| 35 |
with gr.Column():
|
| 36 |
gr.Markdown("### 1. Sensory Intake")
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
fact_ledger = gr.Textbox(label="Extracted Fact Ledger", lines=10, interactive=False)
|
| 41 |
-
|
| 42 |
-
# Link the file upload to the PDF reader
|
| 43 |
-
file_input.change(system.process_pdf, inputs=file_input, outputs=fact_ledger)
|
| 44 |
|
| 45 |
with gr.Column():
|
| 46 |
gr.Markdown("### 2. Forensic Audit")
|
| 47 |
-
|
| 48 |
-
audit_btn = gr.Button("
|
| 49 |
-
result_output = gr.Textbox(label="Outcome")
|
| 50 |
-
|
| 51 |
-
audit_btn.click(system.integrity_lock, inputs=[assertion_input, fact_ledger], outputs=result_output)
|
| 52 |
|
| 53 |
-
# CRITICAL: Keeps the
|
| 54 |
demo.launch()
|
|
|
|
| 2 |
from pypdf import PdfReader
|
| 3 |
|
| 4 |
class MetamorphicPhoenix:
|
| 5 |
+
def ingest_document(self, file_obj):
|
| 6 |
+
# Organ 1: Sensory Cortex - PDF Perception
|
| 7 |
if file_obj is None:
|
| 8 |
+
return "No file detected."
|
| 9 |
try:
|
| 10 |
reader = PdfReader(file_obj.name)
|
| 11 |
text = ""
|
|
|
|
| 13 |
text += page.extract_text() or ""
|
| 14 |
return text.strip()
|
| 15 |
except Exception as e:
|
| 16 |
+
return f"Sensory Error: {str(e)}"
|
| 17 |
|
| 18 |
+
def audit_logic(self, assertion, evidence):
|
| 19 |
+
# Organ 3: Compliance Spine - Busted Logic
|
| 20 |
+
if not assertion or not evidence:
|
| 21 |
+
return "Awaiting data input..."
|
| 22 |
|
| 23 |
+
# Pure text comparison - No emojis to break the code
|
| 24 |
+
if assertion.lower().strip() not in evidence.lower():
|
| 25 |
+
return "RESULT: BUSTED. Falsehood Matrix Detected. Assertion not in evidence."
|
| 26 |
+
return "RESULT: VERIFIED. Assertion matches the Fact Ledger."
|
| 27 |
|
| 28 |
+
# Initialize Organism
|
| 29 |
system = MetamorphicPhoenix()
|
| 30 |
|
| 31 |
+
# --- CLEAN INTERFACE ---
|
| 32 |
with gr.Blocks(title="Metamorphic Phoenix") as demo:
|
| 33 |
+
gr.Markdown("# THE METAMORPHIC PHOENIX")
|
| 34 |
+
gr.Markdown("Universal Regulatory AI Architecture")
|
| 35 |
|
| 36 |
with gr.Row():
|
| 37 |
with gr.Column():
|
| 38 |
gr.Markdown("### 1. Sensory Intake")
|
| 39 |
+
file_input = gr.File(label="Upload PDF Evidence", file_types=[".pdf"])
|
| 40 |
+
fact_ledger = gr.Textbox(label="Extracted Facts", lines=10, interactive=False)
|
| 41 |
+
file_input.change(system.ingest_document, inputs=file_input, outputs=fact_ledger)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
with gr.Column():
|
| 44 |
gr.Markdown("### 2. Forensic Audit")
|
| 45 |
+
claim_input = gr.Textbox(label="Institutional Assertion")
|
| 46 |
+
audit_btn = gr.Button("Execute Integrity Lock")
|
| 47 |
+
result_output = gr.Textbox(label="Audit Outcome")
|
| 48 |
+
audit_btn.click(system.audit_logic, inputs=[claim_input, fact_ledger], outputs=result_output)
|
|
|
|
| 49 |
|
| 50 |
+
# CRITICAL: Keeps the heart beating
|
| 51 |
demo.launch()
|