QAway-to commited on
Commit
c279867
·
1 Parent(s): 5c2eabd

New style APP - Bloomberg

Browse files
Files changed (1) hide show
  1. app.py +55 -25
app.py CHANGED
@@ -1,6 +1,4 @@
1
  import gradio as gr
2
- from tomlkit import value
3
-
4
  from services.llm_client import llm_service
5
  from core.analyzer import PortfolioAnalyzer
6
  from core.comparer import PortfolioComparer
@@ -14,44 +12,72 @@ analyzer = PortfolioAnalyzer(llm_service, MODEL_NAME)
14
  comparer = PortfolioComparer(llm_service, MODEL_NAME)
15
  chatbot = ChatAssistant(llm_service, MODEL_NAME)
16
 
17
- # === Custom theme configuration ===
18
- custom_theme = gr.themes.Base(
19
- primary_hue="indigo",
20
  secondary_hue="gray",
21
  neutral_hue="zinc",
22
  ).set(
23
- body_background_fill="#f8f9fa",
24
- body_text_color="#222",
25
- block_background_fill="#ffffff",
26
- block_border_width="1px",
27
- block_border_color="#e5e7eb",
28
- button_primary_background_fill="#4f46e5",
29
- button_primary_text_color="white",
30
- button_primary_background_fill_hover="#4338ca",
31
- block_shadow="0 2px 6px rgba(0,0,0,0.05)",
32
- block_label_text_size="lg",
33
- block_label_text_weight="600",
34
  )
35
 
36
- # === Interface ===
37
- with gr.Blocks(theme=custom_theme, css="""
38
  .gradio-container {
39
- max-width: 900px !important;
40
  margin: auto !important;
41
  font-family: 'Inter', sans-serif;
 
42
  }
43
  h2, h3, .gr-markdown {
44
  font-weight: 600;
 
45
  }
46
  .gr-button {
47
  border-radius: 6px !important;
48
  font-weight: 600 !important;
49
- letter-spacing: 0.2px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
51
  """) as demo:
52
  gr.Markdown("## Investment Portfolio Analyzer")
53
  gr.Markdown(
54
- "A lightweight interface for analyzing and comparing investment portfolios with AI assistance.",
55
  elem_classes="subtitle",
56
  )
57
 
@@ -62,7 +88,7 @@ h2, h3, .gr-markdown {
62
  label="Portfolio ID or Link",
63
  placeholder="Enter a portfolio ID (e.g. ea856c1b-...)",
64
  lines=1,
65
- value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb'
66
  )
67
  analyze_button = gr.Button("Run Analysis", variant="primary")
68
  analyze_output = gr.Textbox(label="Analysis Result", lines=15)
@@ -90,16 +116,20 @@ h2, h3, .gr-markdown {
90
  metrics_output = gr.Dataframe(label="Portfolio Metrics", wrap=True)
91
  metrics_button.click(fn=show_metrics_table, inputs=metrics_input, outputs=metrics_output)
92
 
93
- # --- AlphaBTC Chart Tab ---
94
  with gr.TabItem("AlphaBTC Chart"):
95
  chart_input = gr.Textbox(label="Portfolio ID", value="3852a354-e66e-4bc5-97e9-55124e31e687")
96
  chart_button = gr.Button("Generate Chart", variant="primary")
97
- chart_output = gr.Plot(label="Alpha vs BTC")
 
 
 
 
98
  chart_button.click(fn=build_alpha_chart, inputs=chart_input, outputs=chart_output)
99
 
100
  gr.Markdown("---")
101
  gr.Markdown(
102
- "<center><small>Developed with Featherless.ai • Powered by OpenAI-compatible API</small></center>",
103
  elem_classes="footer",
104
  )
105
 
 
1
  import gradio as gr
 
 
2
  from services.llm_client import llm_service
3
  from core.analyzer import PortfolioAnalyzer
4
  from core.comparer import PortfolioComparer
 
12
  comparer = PortfolioComparer(llm_service, MODEL_NAME)
13
  chatbot = ChatAssistant(llm_service, MODEL_NAME)
14
 
15
+ # === Bloomberg-style dark theme ===
16
+ dark_theme = gr.themes.Base(
17
+ primary_hue="violet",
18
  secondary_hue="gray",
19
  neutral_hue="zinc",
20
  ).set(
21
+ body_background_fill="#0d1117", # main background (dark navy)
22
+ body_text_color="#e6edf3", # main text
23
+ block_background_fill="#161b22", # card background
24
+ block_border_color="#30363d", # subtle border
25
+ button_primary_background_fill="#4f46e5",# indigo-violet accent
26
+ button_primary_background_fill_hover="#6366f1",
27
+ button_primary_text_color="#ffffff",
28
+ input_background_fill="#0d1117",
29
+ block_shadow="0 2px 6px rgba(0,0,0,0.3)",
30
+ block_label_text_color="#9da5b4",
31
+ block_label_text_size="sm",
32
  )
33
 
34
+ with gr.Blocks(theme=dark_theme, css="""
35
+ /* === Bloomberg / Dark Finance Style === */
36
  .gradio-container {
37
+ max-width: 1000px !important;
38
  margin: auto !important;
39
  font-family: 'Inter', sans-serif;
40
+ background-color: #0d1117 !important;
41
  }
42
  h2, h3, .gr-markdown {
43
  font-weight: 600;
44
+ color: #f0f6fc !important;
45
  }
46
  .gr-button {
47
  border-radius: 6px !important;
48
  font-weight: 600 !important;
49
+ letter-spacing: 0.3px;
50
+ box-shadow: 0 2px 4px rgba(0,0,0,0.25);
51
+ }
52
+ .gr-textbox, .gr-dataframe {
53
+ border-radius: 6px !important;
54
+ }
55
+ .gr-button.primary {
56
+ background: linear-gradient(90deg, #6366f1, #4f46e5);
57
+ border: none !important;
58
+ }
59
+ .gr-tab {
60
+ background-color: #161b22 !important;
61
+ color: #c9d1d9 !important;
62
+ }
63
+ .gr-tabs {
64
+ border-bottom: 1px solid #30363d !important;
65
+ }
66
+ .gr-plot {
67
+ background: #0d1117 !important;
68
+ }
69
+ /* Fix Gradio plot overlay */
70
+ #alpha_chart svg {
71
+ display: none !important;
72
+ }
73
+ #alpha_chart .wrap {
74
+ background: transparent !important;
75
+ box-shadow: none !important;
76
  }
77
  """) as demo:
78
  gr.Markdown("## Investment Portfolio Analyzer")
79
  gr.Markdown(
80
+ "A professional dashboard for analyzing and comparing investment portfolios using AI insights.",
81
  elem_classes="subtitle",
82
  )
83
 
 
88
  label="Portfolio ID or Link",
89
  placeholder="Enter a portfolio ID (e.g. ea856c1b-...)",
90
  lines=1,
91
+ value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb',
92
  )
93
  analyze_button = gr.Button("Run Analysis", variant="primary")
94
  analyze_output = gr.Textbox(label="Analysis Result", lines=15)
 
116
  metrics_output = gr.Dataframe(label="Portfolio Metrics", wrap=True)
117
  metrics_button.click(fn=show_metrics_table, inputs=metrics_input, outputs=metrics_output)
118
 
119
+ # --- AlphaBTC Chart Tab (fixed overlay) ---
120
  with gr.TabItem("AlphaBTC Chart"):
121
  chart_input = gr.Textbox(label="Portfolio ID", value="3852a354-e66e-4bc5-97e9-55124e31e687")
122
  chart_button = gr.Button("Generate Chart", variant="primary")
123
+ chart_output = gr.Plot(
124
+ label="Alpha vs BTC",
125
+ show_label=False,
126
+ elem_id="alpha_chart",
127
+ )
128
  chart_button.click(fn=build_alpha_chart, inputs=chart_input, outputs=chart_output)
129
 
130
  gr.Markdown("---")
131
  gr.Markdown(
132
+ "<center><small style='color:#6e7681;'>Developed with Featherless.ai • Powered by OpenAI-compatible API</small></center>",
133
  elem_classes="footer",
134
  )
135