Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -234,66 +234,84 @@ def continue_chat(chat_history, user_message, analysis_text):
|
|
| 234 |
# Gradio UI
|
| 235 |
# -----------------------
|
| 236 |
def build_demo():
|
| 237 |
-
with gr.Blocks(title="AURA Chat β Hedge Fund Picks"
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
.
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
gr.Markdown("# AURA Chat β Hedge Fund Picks")
|
| 244 |
gr.Markdown("**Enter one or more data prompts (one per line)** β e.g. `SEC insider transactions october 2025 company XYZ`.\n\nOnly input prompts; model, tokens and timing are fixed. Press **Analyze** to fetch & generate the picks. After analysis you can chat with the assistant about the results.")
|
| 245 |
|
| 246 |
with gr.Row():
|
| 247 |
with gr.Column(scale=1):
|
| 248 |
-
prompts = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
analyze_btn = gr.Button("Analyze", variant="primary")
|
| 250 |
error_box = gr.Markdown("", visible=False)
|
| 251 |
gr.Markdown(f"**Fixed settings:** Model = `{LLM_MODEL}` β’ Max tokens = `{MAX_TOKENS}` β’ Scrape delay = `{SCRAPE_DELAY}s`")
|
| 252 |
gr.Markdown("**Important:** Add your `OPENAI_API_KEY` to Space Secrets before running.")
|
| 253 |
with gr.Column(scale=1):
|
| 254 |
-
analysis_out = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
gr.Markdown("**Chat with AURA about this analysis**")
|
| 256 |
chatbot = gr.Chatbot(label="AURA Chat", height=420)
|
| 257 |
-
user_input = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
| 258 |
send_btn = gr.Button("Send")
|
| 259 |
|
| 260 |
-
#
|
| 261 |
-
analysis_state = gr.State("")
|
| 262 |
-
chat_state = gr.State([])
|
| 263 |
-
|
| 264 |
-
#
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
def render_chat(chat_state_list):
|
| 290 |
-
# gr.Chatbot expects a list of (user, assistant) pairs
|
| 291 |
-
return chat_state_list or []
|
| 292 |
-
|
| 293 |
-
chat_state.change(fn=render_chat, inputs=[chat_state], outputs=[chatbot])
|
| 294 |
|
| 295 |
return demo
|
| 296 |
|
|
|
|
| 297 |
# -----------------------
|
| 298 |
# Clean shutdown helper
|
| 299 |
# -----------------------
|
|
|
|
| 234 |
# Gradio UI
|
| 235 |
# -----------------------
|
| 236 |
def build_demo():
|
| 237 |
+
with gr.Blocks(title="AURA Chat β Hedge Fund Picks") as demo:
|
| 238 |
+
|
| 239 |
+
# Inject custom CSS in a totally safe, backward-compatible way
|
| 240 |
+
gr.HTML("""
|
| 241 |
+
<style>
|
| 242 |
+
.gradio-container { max-width: 1100px; margin: 18px auto; }
|
| 243 |
+
.header { text-align: left; margin-bottom: 6px; }
|
| 244 |
+
.muted { color: #7d8590; font-size: 14px; }
|
| 245 |
+
.analysis-box {
|
| 246 |
+
background: #ffffff;
|
| 247 |
+
border-radius: 8px;
|
| 248 |
+
padding: 12px;
|
| 249 |
+
box-shadow: 0 4px 14px rgba(0,0,0,0.06);
|
| 250 |
+
}
|
| 251 |
+
</style>
|
| 252 |
+
""")
|
| 253 |
+
|
| 254 |
gr.Markdown("# AURA Chat β Hedge Fund Picks")
|
| 255 |
gr.Markdown("**Enter one or more data prompts (one per line)** β e.g. `SEC insider transactions october 2025 company XYZ`.\n\nOnly input prompts; model, tokens and timing are fixed. Press **Analyze** to fetch & generate the picks. After analysis you can chat with the assistant about the results.")
|
| 256 |
|
| 257 |
with gr.Row():
|
| 258 |
with gr.Column(scale=1):
|
| 259 |
+
prompts = gr.Textbox(
|
| 260 |
+
lines=6,
|
| 261 |
+
label="Data Prompts (one per line)",
|
| 262 |
+
placeholder="SEC insider transactions october 2025\n13F filings Q3 2025\ncompany: ACME corp insider buys"
|
| 263 |
+
)
|
| 264 |
analyze_btn = gr.Button("Analyze", variant="primary")
|
| 265 |
error_box = gr.Markdown("", visible=False)
|
| 266 |
gr.Markdown(f"**Fixed settings:** Model = `{LLM_MODEL}` β’ Max tokens = `{MAX_TOKENS}` β’ Scrape delay = `{SCRAPE_DELAY}s`")
|
| 267 |
gr.Markdown("**Important:** Add your `OPENAI_API_KEY` to Space Secrets before running.")
|
| 268 |
with gr.Column(scale=1):
|
| 269 |
+
analysis_out = gr.Textbox(
|
| 270 |
+
label="Generated Analysis (Top picks with Investment Duration)",
|
| 271 |
+
lines=18,
|
| 272 |
+
interactive=False
|
| 273 |
+
)
|
| 274 |
gr.Markdown("**Chat with AURA about this analysis**")
|
| 275 |
chatbot = gr.Chatbot(label="AURA Chat", height=420)
|
| 276 |
+
user_input = gr.Textbox(
|
| 277 |
+
placeholder="Ask a follow-up question about the analysis...",
|
| 278 |
+
label="Your question"
|
| 279 |
+
)
|
| 280 |
send_btn = gr.Button("Send")
|
| 281 |
|
| 282 |
+
# States
|
| 283 |
+
analysis_state = gr.State("")
|
| 284 |
+
chat_state = gr.State([])
|
| 285 |
+
|
| 286 |
+
# Analyze click
|
| 287 |
+
analyze_btn.click(
|
| 288 |
+
fn=on_analyze,
|
| 289 |
+
inputs=[prompts],
|
| 290 |
+
outputs=[analysis_out, error_box, analysis_state, chat_state]
|
| 291 |
+
)
|
| 292 |
+
|
| 293 |
+
# Chat send
|
| 294 |
+
send_btn.click(
|
| 295 |
+
fn=on_send,
|
| 296 |
+
inputs=[chat_state, user_input, analysis_state],
|
| 297 |
+
outputs=[chat_state, user_input]
|
| 298 |
+
)
|
| 299 |
+
user_input.submit(
|
| 300 |
+
fn=on_send,
|
| 301 |
+
inputs=[chat_state, user_input, analysis_state],
|
| 302 |
+
outputs=[chat_state, user_input]
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
+
# Render chat
|
| 306 |
+
chat_state.change(
|
| 307 |
+
fn=render_chat,
|
| 308 |
+
inputs=[chat_state],
|
| 309 |
+
outputs=[chatbot]
|
| 310 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 311 |
|
| 312 |
return demo
|
| 313 |
|
| 314 |
+
|
| 315 |
# -----------------------
|
| 316 |
# Clean shutdown helper
|
| 317 |
# -----------------------
|