Update app.py
Browse files
app.py
CHANGED
|
@@ -69,14 +69,48 @@ def analisi_finanziaria(query, k=3):
|
|
| 69 |
result = pipe(final_prompt)[0]['generated_text']
|
| 70 |
return result
|
| 71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
iface = gr.Interface(
|
| 73 |
-
fn=analisi_finanziaria,
|
| 74 |
-
inputs=gr.Textbox(label="Enter event"),
|
| 75 |
outputs=gr.Textbox(label="Prediction"),
|
| 76 |
title="GRPO Financial Analyst",
|
| 77 |
-
description=
|
|
|
|
|
|
|
| 78 |
)
|
| 79 |
|
| 80 |
-
|
| 81 |
iface.launch()
|
| 82 |
|
|
|
|
| 69 |
result = pipe(final_prompt)[0]['generated_text']
|
| 70 |
return result
|
| 71 |
|
| 72 |
+
import gradio as gr
|
| 73 |
+
|
| 74 |
+
# Examples from your thesis
|
| 75 |
+
examples = [
|
| 76 |
+
"Elon Musk created a new political party",
|
| 77 |
+
"Trump imposes tariffs",
|
| 78 |
+
"Tesla announces a new affordable electric vehicle model",
|
| 79 |
+
"Nvidia releases new GPU technology",
|
| 80 |
+
"Apple launches Apple TV+ subscription service"
|
| 81 |
+
]
|
| 82 |
+
|
| 83 |
+
description_md = """
|
| 84 |
+
# GRPO Financial Analyst
|
| 85 |
+
|
| 86 |
+
This tool analyzes financial events using a retrieval-augmented **language model**.
|
| 87 |
+
|
| 88 |
+
**How it works:**
|
| 89 |
+
- The model leverages historical events and news to provide predictions.
|
| 90 |
+
- For each input, similar past events are retrieved to give context.
|
| 91 |
+
- The output includes:
|
| 92 |
+
- **Chosen Stocks**: stocks likely impacted
|
| 93 |
+
- **Prediction**: expected price change (Up, Down, Neutral)
|
| 94 |
+
- **Explanation**: brief reasoning based on historical context
|
| 95 |
+
|
| 96 |
+
**Example use cases:**
|
| 97 |
+
- Market reactions to political events
|
| 98 |
+
- Corporate announcements and earnings reports
|
| 99 |
+
- Technological product launches
|
| 100 |
+
|
| 101 |
+
Click an example below to quickly test the model.
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
# Create Gradio interface
|
| 105 |
iface = gr.Interface(
|
| 106 |
+
fn=analisi_finanziaria, # your actual function
|
| 107 |
+
inputs=gr.Textbox(label="Enter financial event", placeholder="Type an event here..."),
|
| 108 |
outputs=gr.Textbox(label="Prediction"),
|
| 109 |
title="GRPO Financial Analyst",
|
| 110 |
+
description=description_md,
|
| 111 |
+
examples=[[e] for e in examples],
|
| 112 |
+
allow_flagging="never"
|
| 113 |
)
|
| 114 |
|
|
|
|
| 115 |
iface.launch()
|
| 116 |
|