Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -113,31 +113,13 @@ def generate_summary(info, ratios):
|
|
113 |
summary = summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
|
114 |
return summary
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
return {
|
124 |
-
'P/E Ratio': pe_ratio,
|
125 |
-
'P/S Ratio': ps_ratio,
|
126 |
-
'P/B Ratio': pb_ratio,
|
127 |
-
'PEG Ratio': peg_ratio,
|
128 |
-
'Dividend Yield (%)': dividend_yield
|
129 |
-
}
|
130 |
-
|
131 |
-
def compare_to_sector(sector, ratios):
|
132 |
-
averages = sector_averages.get(sector, None)
|
133 |
-
if not averages:
|
134 |
-
return pd.DataFrame({"Metric": ["Sector data not available"], "Value": ["N/A"]})
|
135 |
-
comparison = {}
|
136 |
-
for key in averages:
|
137 |
-
stock_value = ratios.get(key, 0)
|
138 |
-
sector_value = averages[key]
|
139 |
-
comparison[key] = f"{stock_value:.2f} vs Sector Avg {sector_value:.2f}"
|
140 |
-
return pd.DataFrame({"Ratio": list(comparison.keys()), "Comparison": list(comparison.values())})
|
141 |
|
142 |
def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
|
143 |
if assumed_eps is None:
|
|
|
113 |
summary = summarizer(report, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
|
114 |
return summary
|
115 |
|
116 |
+
def answer_investing_question(question):
|
117 |
+
basic_prompt = f"Explain clearly and simply: {question}"
|
118 |
+
response = summarizer(basic_prompt, max_length=150, min_length=50, do_sample=False)[0]['summary_text']
|
119 |
+
return response
|
120 |
+
|
121 |
+
# (Rest of the app continues with stock_research, download_report, and Gradio UI, now including a new Tab for Q&A)
|
122 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
def stock_research(symbol, assumed_eps=5.0, growth_rate=0.1, book_value=500000000):
|
125 |
if assumed_eps is None:
|