bpmredacademy commited on
Commit
a53d475
·
verified ·
1 Parent(s): 8c8a8ac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +85 -66
app.py CHANGED
@@ -1,80 +1,99 @@
1
  import gradio as gr
2
-
3
- DISCLAIMER = """
4
- ⚠️ PFI does NOT provide financial advice.
5
- Responses are non-executive, exploratory, and informational only.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  """
7
 
8
- def pfi_reasoning(
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
- PFI INSIGHT:
42
- Your goal is not limited by numbers, but by behavioral consistency.
43
- Your primary task is to reduce decision noise and protect focus.
44
 
45
- NEXT 30 DAYS:
46
- - Remove one recurring expense
47
- - Freeze non-essential decisions
48
- - Track discipline, not money
 
49
 
50
- TRAINING SIGNAL:
51
- Financial clarity is a *skill*, not a feeling.
52
-
53
- {DISCLAIMER}
54
- """
55
 
56
- with gr.Blocks(theme=gr.themes.Base()) as demo:
57
- gr.Markdown("# 🧠 PFI | Life")
58
- gr.Markdown("High-density financial cognition. Intentionally constrained.")
59
- gr.Markdown(DISCLAIMER)
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- with gr.Group():
62
- goal = gr.Textbox(label="🎯 Financial Goal", placeholder="What do you want to achieve?")
63
- timeframe = gr.Textbox(label="⏱ Timeframe", placeholder="By when?")
64
- income = gr.Textbox(label="💸 Monthly Income")
65
- expenses = gr.Textbox(label="🔻 Main Expenses")
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
- submit = gr.Button("Request PFI Reasoning")
 
 
 
71
 
72
- output = gr.Textbox(label="PFI Output", lines=18)
 
73
 
74
- submit.click(
75
- pfi_reasoning,
76
- inputs=[goal, timeframe, income, expenses, stress, blocker, discipline],
77
- outputs=output
78
  )
79
 
80
- demo.launch()
 
 
 
 
 
 
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()