Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,80 +1,99 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"""
|
| 7 |
|
| 8 |
-
|
| 9 |
-
goal,
|
| 10 |
-
timeframe,
|
| 11 |
-
income,
|
| 12 |
-
expenses,
|
| 13 |
-
stress,
|
| 14 |
-
blocker,
|
| 15 |
-
discipline
|
| 16 |
-
):
|
| 17 |
-
if not goal or not timeframe:
|
| 18 |
-
return "Please complete all required fields."
|
| 19 |
-
|
| 20 |
-
return f"""
|
| 21 |
-
🧠 PFI — Financial Cognition Output
|
| 22 |
-
|
| 23 |
-
GOAL:
|
| 24 |
-
{goal}
|
| 25 |
-
|
| 26 |
-
TIMEFRAME:
|
| 27 |
-
{timeframe}
|
| 28 |
-
|
| 29 |
-
REALITY SNAPSHOT:
|
| 30 |
-
- Income: {income}
|
| 31 |
-
- Major expenses: {expenses}
|
| 32 |
-
- Current stressor: {stress}
|
| 33 |
-
|
| 34 |
-
BEHAVIORAL BLOCKER:
|
| 35 |
-
{blocker}
|
| 36 |
|
| 37 |
-
DISCIPLINE LEVEL:
|
| 38 |
-
{discipline}/5
|
| 39 |
|
| 40 |
-
---
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
Your primary task is to reduce decision noise and protect focus.
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
"""
|
| 55 |
|
| 56 |
-
with gr.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
stress = gr.Textbox(label="⚠️ Biggest Financial Stress")
|
| 67 |
-
blocker = gr.Textbox(label="🧠 Behavioral Blocker")
|
| 68 |
-
discipline = gr.Slider(1, 5, step=1, label="🔁 Discipline Level")
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
|
|
|
| 73 |
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
inputs=[goal, timeframe, income, expenses, stress, blocker, discipline],
|
| 77 |
-
outputs=output
|
| 78 |
)
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import textwrap
|
| 3 |
+
|
| 4 |
+
# -------------------------------
|
| 5 |
+
# Core PFI reasoning stub
|
| 6 |
+
# (preview-only, non-executive)
|
| 7 |
+
# -------------------------------
|
| 8 |
+
|
| 9 |
+
def pfi_reasoning(question: str) -> str:
|
| 10 |
+
if not question or len(question.strip()) < 20:
|
| 11 |
+
return (
|
| 12 |
+
"Input rejected.\n\n"
|
| 13 |
+
"PFI requires a precise, high-density financial question.\n"
|
| 14 |
+
"Ambiguous or underspecified inputs reduce analytical value."
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
response = f"""
|
| 18 |
+
PFI ANALYSIS (PREVIEW)
|
| 19 |
+
|
| 20 |
+
Question Structure:
|
| 21 |
+
- Topic domain identified
|
| 22 |
+
- Scope appears conceptual, not executable
|
| 23 |
+
- Time horizon and constraints are partially defined
|
| 24 |
+
|
| 25 |
+
Cognitive Decomposition:
|
| 26 |
+
- Primary variables detected
|
| 27 |
+
- Secondary dependencies inferred
|
| 28 |
+
- Risk vectors identified at a structural level
|
| 29 |
+
|
| 30 |
+
Reasoning Notes:
|
| 31 |
+
- This output is exploratory and non-executive
|
| 32 |
+
- No prediction, advice, or action is implied
|
| 33 |
+
- Further precision would increase analytical depth
|
| 34 |
+
|
| 35 |
+
Next Step (Optional):
|
| 36 |
+
- Narrow the scope
|
| 37 |
+
- Specify constraints
|
| 38 |
+
- Clarify the decision context
|
| 39 |
"""
|
| 40 |
|
| 41 |
+
return textwrap.dedent(response).strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# -------------------------------
|
| 45 |
+
# Gradio UI
|
| 46 |
+
# -------------------------------
|
|
|
|
| 47 |
|
| 48 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 49 |
+
gr.Markdown(
|
| 50 |
+
"""
|
| 51 |
+
# 🧠 Personal Financial Intelligence (PFI)
|
| 52 |
+
**High-density financial reasoning · Research Preview**
|
| 53 |
|
| 54 |
+
⚠️ *PFI is a research preview system.
|
| 55 |
+
It does NOT provide financial advice or execute decisions.*
|
| 56 |
+
"""
|
| 57 |
+
)
|
|
|
|
| 58 |
|
| 59 |
+
with gr.Row():
|
| 60 |
+
question_input = gr.Textbox(
|
| 61 |
+
label="Your Question",
|
| 62 |
+
placeholder=(
|
| 63 |
+
"Formulate one precise, high-impact financial question.\n"
|
| 64 |
+
"Ambiguity reduces output quality."
|
| 65 |
+
),
|
| 66 |
+
lines=4
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
analyze_button = gr.Button("Request Analysis (Limited)")
|
| 70 |
+
|
| 71 |
+
output_box = gr.Textbox(
|
| 72 |
+
label="PFI Output (Exploratory · Non-Executable)",
|
| 73 |
+
lines=12
|
| 74 |
+
)
|
| 75 |
|
| 76 |
+
analyze_button.click(
|
| 77 |
+
fn=pfi_reasoning,
|
| 78 |
+
inputs=question_input,
|
| 79 |
+
outputs=output_box
|
| 80 |
+
)
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
+
gr.Markdown(
|
| 83 |
+
"""
|
| 84 |
+
---
|
| 85 |
+
**Disclaimer**
|
| 86 |
|
| 87 |
+
PFI outputs are exploratory and informational only.
|
| 88 |
+
No financial advice, trading signals, or decision execution is provided.
|
| 89 |
|
| 90 |
+
© 2026 BPM RED Academy · All rights reserved.
|
| 91 |
+
"""
|
|
|
|
|
|
|
| 92 |
)
|
| 93 |
|
| 94 |
+
# -------------------------------
|
| 95 |
+
# Launch
|
| 96 |
+
# -------------------------------
|
| 97 |
+
|
| 98 |
+
if __name__ == "__main__":
|
| 99 |
+
demo.launch()
|