QAway-to commited on
Commit
cdab94b
·
1 Parent(s): d586eea

New style APP (Tab Changes v3.0)

Browse files
Files changed (3) hide show
  1. .idea/TradeLinkAI.iml +5 -4
  2. .idea/modules.xml +8 -0
  3. app.py +94 -118
.idea/TradeLinkAI.iml CHANGED
@@ -1,7 +1,8 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <module version="4">
3
- <component name="PyDocumentationSettings">
4
- <option name="format" value="PLAIN" />
5
- <option name="myDocStringFormat" value="Plain" />
 
6
  </component>
7
  </module>
 
1
  <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$" />
5
+ <orderEntry type="inheritedJdk" />
6
+ <orderEntry type="sourceFolder" forTests="false" />
7
  </component>
8
  </module>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/TradeLinkAI.iml" filepath="$PROJECT_DIR$/.idea/TradeLinkAI.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
app.py CHANGED
@@ -5,6 +5,7 @@ from core.comparer import PortfolioComparer
5
  from core.chat import ChatAssistant
6
  from core.metrics import show_metrics_table
7
  from core.visualization import build_alpha_chart
 
8
 
9
  MODEL_NAME = "meta-llama/Meta-Llama-3.1-8B-Instruct"
10
 
@@ -18,11 +19,11 @@ dark_theme = gr.themes.Base(
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",
@@ -31,34 +32,17 @@ dark_theme = gr.themes.Base(
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
- /* === LLM Commentary Styling === */
43
- #llm_comment_box textarea {
44
- max-height: 420px !important; /* ограничение высоты */
45
- overflow-y: auto !important; /* вертикальный скроллинг */
46
- background-color: #161b22 !important;
47
- color: #f0f6fc !important;
48
- border: 1px solid #30363d !important;
49
- border-radius: 6px !important;
50
- font-family: 'JetBrains Mono', monospace !important;
51
- font-size: 14px !important;
52
- line-height: 1.5 !important;
53
- padding: 12px !important;
54
- }
55
- /* === Comparison Table === */
56
- #comparison_table {
57
- margin-top: 8px !important;
58
- }
59
-
60
  h2, h3, .gr-markdown {
61
- font-weight: 600;
62
  color: #f0f6fc !important;
63
  }
64
  .gr-button {
@@ -70,48 +54,38 @@ h2, h3, .gr-markdown {
70
  .gr-textbox, .gr-dataframe {
71
  border-radius: 6px !important;
72
  }
73
- .gr-button.primary {
74
- background: linear-gradient(90deg, #6366f1, #4f46e5);
75
- border: none !important;
76
- }
77
- .gr-tab {
78
- background-color: #161b22 !important;
79
- color: #c9d1d9 !important;
80
- }
81
- .gr-tabs {
82
- border-bottom: 1px solid #30363d !important;
83
- }
84
- .gr-plot {
85
- background: #0d1117 !important;
86
- }
87
- /* Fix Gradio plot overlay */
88
- #alpha_chart svg {
89
- display: none !important;
90
- }
91
- #alpha_chart .wrap {
92
- background: transparent !important;
93
- box-shadow: none !important;
94
- }
95
- /* === Styled comparison table === */
96
- .gr-dataframe table {
97
- border-collapse: collapse !important;
98
- width: 100% !important;
99
- color: #c9d1d9 !important;
100
- background-color: #161b22 !important;
101
  }
102
- .gr-dataframe th {
103
- background-color: #21262d !important;
104
- color: #f0f6fc !important;
105
- font-weight: 600 !important;
106
- text-transform: uppercase;
107
- border-bottom: 1px solid #30363d !important;
108
  }
109
- .gr-dataframe td {
110
- border-top: 1px solid #30363d !important;
111
- padding: 8px !important;
 
 
 
 
 
 
 
112
  }
113
 
114
- """) as demo:
 
 
 
 
 
 
115
  gr.Markdown("## Investment Portfolio Analyzer")
116
  gr.Markdown(
117
  "A professional dashboard for analyzing and comparing investment portfolios using AI insights.",
@@ -121,73 +95,75 @@ h2, h3, .gr-markdown {
121
  with gr.Tabs():
122
  # --- Analysis Tab ---
123
  with gr.TabItem("Analysis"):
124
- portfolio_input = gr.Textbox(
125
- label="Portfolio ID or Link",
126
- placeholder="Enter a portfolio ID (e.g. ea856c1b-...)",
127
- lines=1,
128
- value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb',
129
- )
130
- analyze_button = gr.Button("Run Analysis", variant="primary")
131
- analyze_output = gr.Textbox(label="Analysis Result", lines=15)
132
- analyze_button.click(fn=analyzer.run, inputs=portfolio_input, outputs=analyze_output)
 
 
 
 
 
133
 
134
  # --- Comparison Table Tab ---
135
  with gr.TabItem("Comparison Table"):
136
- comp_input_1 = gr.Textbox(label="Portfolio A", value="3852a354-e66e-4bc5-97e9-55124e31e687")
137
- comp_input_2 = gr.Textbox(label="Portfolio B", value="b1ef37aa-5b9a-41b4-9394-8823f2de36bb")
138
- comp_button = gr.Button("Load Comparison", variant="primary")
139
-
140
- # комментарий теперь над таблицей
141
- comp_output_comment = gr.Textbox(
142
- label="AI Commentary",
143
- lines=8,
144
- interactive=True,
145
- show_copy_button=True,
146
- elem_id="llm_comment_box",
147
- )
148
-
149
- comp_output_table = gr.Dataframe(
150
- label="Comparative Metrics",
151
- wrap=True,
152
- elem_id="comparison_table",
153
- )
154
-
155
- from core.comparison_table import show_comparison_table
156
-
157
- comp_button.click(
158
- fn=show_comparison_table,
159
- inputs=[comp_input_1, comp_input_2],
160
- outputs=[comp_output_table, comp_output_comment],
161
- )
162
 
163
  # --- Chat Assistant Tab ---
164
  with gr.TabItem("Assistant"):
165
- chat_input = gr.Textbox(label="Ask about investments or analysis")
166
- chat_button = gr.Button("Send Question", variant="primary")
167
- chat_output = gr.Textbox(label="AI Response", lines=8)
168
- chat_button.click(fn=chatbot.run, inputs=chat_input, outputs=chat_output)
 
169
 
170
  # --- Metrics Table Tab ---
171
  with gr.TabItem("Metrics Table"):
172
- metrics_input = gr.Textbox(label="Portfolio ID", value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb')
173
- metrics_button = gr.Button("Load Metrics", variant="primary")
174
- metrics_output = gr.Dataframe(label="Portfolio Metrics", wrap=True)
175
- metrics_button.click(fn=show_metrics_table, inputs=metrics_input, outputs=metrics_output)
 
176
 
177
- # --- AlphaBTC Chart Tab (fixed overlay) ---
178
  with gr.TabItem("AlphaBTC Chart"):
179
- chart_input = gr.Textbox(label="Portfolio ID", value="3852a354-e66e-4bc5-97e9-55124e31e687")
180
- chart_button = gr.Button("Generate Chart", variant="primary")
181
- chart_output = gr.Plot(
182
- label="Alpha vs BTC",
183
- show_label=False,
184
- elem_id="alpha_chart",
185
- )
186
- chart_button.click(fn=build_alpha_chart, inputs=chart_input, outputs=chart_output)
187
 
188
  gr.Markdown("---")
189
  gr.Markdown(
190
- "<center><small style='color:#6e7681;'>Developed with Featherless.ai • Powered by OpenAI-compatible API</small></center>",
191
  elem_classes="footer",
192
  )
193
 
 
5
  from core.chat import ChatAssistant
6
  from core.metrics import show_metrics_table
7
  from core.visualization import build_alpha_chart
8
+ from core.comparison_table import show_comparison_table
9
 
10
  MODEL_NAME = "meta-llama/Meta-Llama-3.1-8B-Instruct"
11
 
 
19
  secondary_hue="gray",
20
  neutral_hue="zinc",
21
  ).set(
22
+ body_background_fill="#0d1117",
23
+ body_text_color="#e6edf3",
24
+ block_background_fill="#161b22",
25
+ block_border_color="#30363d",
26
+ button_primary_background_fill="#4f46e5",
27
  button_primary_background_fill_hover="#6366f1",
28
  button_primary_text_color="#ffffff",
29
  input_background_fill="#0d1117",
 
32
  block_label_text_size="sm",
33
  )
34
 
35
+ with gr.Blocks(
36
+ theme=dark_theme,
37
+ css="""
38
+ /* === Unified Finance UI === */
39
  .gradio-container {
40
+ max-width: 1100px !important;
41
  margin: auto !important;
42
  font-family: 'Inter', sans-serif;
43
  background-color: #0d1117 !important;
44
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  h2, h3, .gr-markdown {
 
46
  color: #f0f6fc !important;
47
  }
48
  .gr-button {
 
54
  .gr-textbox, .gr-dataframe {
55
  border-radius: 6px !important;
56
  }
57
+
58
+ /* === Unified block layout === */
59
+ .block-section {
60
+ display: flex;
61
+ flex-direction: column;
62
+ gap: 12px;
63
+ min-height: 520px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
+ .gr-textbox textarea {
66
+ min-height: 420px !important;
67
+ resize: none !important;
68
+ overflow-y: auto !important;
 
 
69
  }
70
+
71
+ /* === Comparison / Analysis boxes alignment === */
72
+ #llm_comment_box textarea,
73
+ #comparison_table,
74
+ #analysis_output textarea,
75
+ #chat_output textarea {
76
+ min-height: 400px !important;
77
+ overflow-y: auto !important;
78
+ font-family: 'JetBrains Mono', monospace !important;
79
+ font-size: 14px !important;
80
  }
81
 
82
+ /* === Footer === */
83
+ .footer small {
84
+ color: #6e7681 !important;
85
+ text-align: center;
86
+ }
87
+ """
88
+ ) as demo:
89
  gr.Markdown("## Investment Portfolio Analyzer")
90
  gr.Markdown(
91
  "A professional dashboard for analyzing and comparing investment portfolios using AI insights.",
 
95
  with gr.Tabs():
96
  # --- Analysis Tab ---
97
  with gr.TabItem("Analysis"):
98
+ with gr.Column(elem_classes="block-section"):
99
+ portfolio_input = gr.Textbox(
100
+ label="Portfolio ID or Link",
101
+ placeholder="Enter a portfolio ID (e.g. ea856c1b-...)",
102
+ lines=1,
103
+ value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb',
104
+ )
105
+ analyze_button = gr.Button("Run Analysis", variant="primary")
106
+ analyze_output = gr.Textbox(
107
+ label="Analysis Result",
108
+ lines=15,
109
+ elem_id="analysis_output"
110
+ )
111
+ analyze_button.click(fn=analyzer.run, inputs=portfolio_input, outputs=analyze_output)
112
 
113
  # --- Comparison Table Tab ---
114
  with gr.TabItem("Comparison Table"):
115
+ with gr.Column(elem_classes="block-section"):
116
+ comp_input_1 = gr.Textbox(label="Portfolio A", value="3852a354-e66e-4bc5-97e9-55124e31e687")
117
+ comp_input_2 = gr.Textbox(label="Portfolio B", value="b1ef37aa-5b9a-41b4-9394-8823f2de36bb")
118
+ comp_button = gr.Button("Load Comparison", variant="primary")
119
+
120
+ comp_output_comment = gr.Textbox(
121
+ label="AI Commentary",
122
+ lines=8,
123
+ interactive=True,
124
+ show_copy_button=True,
125
+ elem_id="llm_comment_box",
126
+ )
127
+
128
+ comp_output_table = gr.Dataframe(
129
+ label="Comparative Metrics",
130
+ wrap=True,
131
+ elem_id="comparison_table",
132
+ )
133
+
134
+ comp_button.click(
135
+ fn=show_comparison_table,
136
+ inputs=[comp_input_1, comp_input_2],
137
+ outputs=[comp_output_table, comp_output_comment],
138
+ )
 
 
139
 
140
  # --- Chat Assistant Tab ---
141
  with gr.TabItem("Assistant"):
142
+ with gr.Column(elem_classes="block-section"):
143
+ chat_input = gr.Textbox(label="Ask about investments or analysis")
144
+ chat_button = gr.Button("Send Question", variant="primary")
145
+ chat_output = gr.Textbox(label="AI Response", lines=8, elem_id="chat_output")
146
+ chat_button.click(fn=chatbot.run, inputs=chat_input, outputs=chat_output)
147
 
148
  # --- Metrics Table Tab ---
149
  with gr.TabItem("Metrics Table"):
150
+ with gr.Column(elem_classes="block-section"):
151
+ metrics_input = gr.Textbox(label="Portfolio ID", value='b1ef37aa-5b9a-41b4-9394-8823f2de36bb')
152
+ metrics_button = gr.Button("Load Metrics", variant="primary")
153
+ metrics_output = gr.Dataframe(label="Portfolio Metrics", wrap=True)
154
+ metrics_button.click(fn=show_metrics_table, inputs=metrics_input, outputs=metrics_output)
155
 
156
+ # --- AlphaBTC Chart Tab ---
157
  with gr.TabItem("AlphaBTC Chart"):
158
+ with gr.Column(elem_classes="block-section"):
159
+ chart_input = gr.Textbox(label="Portfolio ID", value="3852a354-e66e-4bc5-97e9-55124e31e687")
160
+ chart_button = gr.Button("Generate Chart", variant="primary")
161
+ chart_output = gr.Plot(label="Alpha vs BTC", show_label=False, elem_id="alpha_chart")
162
+ chart_button.click(fn=build_alpha_chart, inputs=chart_input, outputs=chart_output)
 
 
 
163
 
164
  gr.Markdown("---")
165
  gr.Markdown(
166
+ "<center><small>Developed with Featherless.ai • Powered by OpenAI-compatible API</small></center>",
167
  elem_classes="footer",
168
  )
169