Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -617,43 +617,36 @@ def chatbot_response(message, history):
|
|
| 617 |
# 构建对话历史
|
| 618 |
messages = []
|
| 619 |
|
| 620 |
-
# 系统提示词 -
|
| 621 |
-
system_prompt = """You are
|
| 622 |
|
| 623 |
-
Your
|
| 624 |
-
-
|
| 625 |
-
-
|
| 626 |
-
-
|
| 627 |
-
-
|
| 628 |
|
| 629 |
-
Your
|
| 630 |
-
|
|
|
|
|
|
|
| 631 |
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
3. **extract_financial_metrics(cik, years)** - Get multi-year trends
|
| 640 |
-
- years: 3 or 5
|
| 641 |
-
- Returns: Historical data with quarterly breakdowns
|
| 642 |
|
| 643 |
-
|
| 644 |
-
-
|
| 645 |
-
-
|
| 646 |
-
-
|
| 647 |
-
-
|
| 648 |
-
-
|
| 649 |
-
- Suggest follow-up questions or related analyses
|
| 650 |
|
| 651 |
-
|
| 652 |
-
- "Let me check Apple's latest financials... [fetches data] Their revenue hit $383B last year, up 8% from the previous year. The growth is mainly driven by..."
|
| 653 |
-
- "Comparing Tesla and Ford... [fetches both] Interesting - Tesla's profit margin is 15% vs Ford's 5%, even though Ford has higher revenue..."
|
| 654 |
-
- "NVIDIA's 3-year trend shows explosive growth... [shows data] Revenue tripled from $16B to $61B, mainly due to AI chip demand..."
|
| 655 |
-
|
| 656 |
-
Remember: Be insightful, not just informative. Users want understanding, not just data."""
|
| 657 |
|
| 658 |
messages.append({"role": "system", "content": system_prompt})
|
| 659 |
|
|
@@ -849,18 +842,18 @@ with gr.Blocks(title="SEC Financial Data Query Assistant") as demo:
|
|
| 849 |
chat = gr.ChatInterface(
|
| 850 |
fn=chatbot_response,
|
| 851 |
examples=[
|
| 852 |
-
"
|
| 853 |
-
"
|
| 854 |
-
"
|
| 855 |
-
"
|
| 856 |
-
"
|
| 857 |
-
"
|
| 858 |
-
"
|
| 859 |
-
"
|
| 860 |
],
|
| 861 |
cache_examples=False,
|
| 862 |
-
title="
|
| 863 |
-
description="
|
| 864 |
)
|
| 865 |
|
| 866 |
with gr.Tab("Direct Query"):
|
|
|
|
| 617 |
# 构建对话历史
|
| 618 |
messages = []
|
| 619 |
|
| 620 |
+
# 系统提示词 - 财报分析专家
|
| 621 |
+
system_prompt = """You are a financial reporting analysis expert, specializing in analyzing company financial data and providing professional insights.
|
| 622 |
|
| 623 |
+
Your expertise:
|
| 624 |
+
- Deep understanding of financial statements (10-K, 10-Q filings)
|
| 625 |
+
- Expert at identifying trends, patterns, and anomalies in financial data
|
| 626 |
+
- Skilled at comparing metrics across different periods and competitors
|
| 627 |
+
- Proficient in calculating and interpreting key financial ratios
|
| 628 |
|
| 629 |
+
Your available tools:
|
| 630 |
+
1. **advanced_search_company(company_input)** - Find US companies by name or ticker symbol
|
| 631 |
+
2. **get_latest_financial_data(cik)** - Retrieve the most recent financial report
|
| 632 |
+
3. **extract_financial_metrics(cik, years)** - Get multi-year financial trends (3 or 5 years)
|
| 633 |
|
| 634 |
+
How to analyze:
|
| 635 |
+
- When users ask about a company, automatically fetch relevant data
|
| 636 |
+
- Provide professional analysis with specific numbers and percentages
|
| 637 |
+
- Calculate YoY growth rates, profit margins, and other key metrics
|
| 638 |
+
- Identify trends and explain their business implications
|
| 639 |
+
- Compare current performance with historical data
|
| 640 |
+
- Highlight both strengths and concerns in the financial data
|
|
|
|
|
|
|
|
|
|
| 641 |
|
| 642 |
+
Analysis framework:
|
| 643 |
+
- Revenue analysis: Growth rate, trend direction, stability
|
| 644 |
+
- Profitability: Net income, profit margins, efficiency
|
| 645 |
+
- Cash flow: Operating cash flow adequacy, cash generation ability
|
| 646 |
+
- Per-share metrics: EPS trends, shareholder value creation
|
| 647 |
+
- Overall assessment: Financial health and future outlook
|
|
|
|
| 648 |
|
| 649 |
+
Remember: Provide data-driven insights, not just raw numbers. Help users understand what the numbers really mean for the business."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
|
| 651 |
messages.append({"role": "system", "content": system_prompt})
|
| 652 |
|
|
|
|
| 842 |
chat = gr.ChatInterface(
|
| 843 |
fn=chatbot_response,
|
| 844 |
examples=[
|
| 845 |
+
"Analyze Apple's latest financial performance",
|
| 846 |
+
"Show me NVIDIA's 3-year revenue and profit trends",
|
| 847 |
+
"What's Tesla's profitability situation? Is it improving?",
|
| 848 |
+
"Compare Microsoft's recent quarterly results with last year",
|
| 849 |
+
"Analyze Amazon's operating cash flow trends over 5 years",
|
| 850 |
+
"Is Alibaba's earnings per share growing or declining?",
|
| 851 |
+
"What are the key highlights in Meta's latest financial report?",
|
| 852 |
+
"Evaluate Google's revenue growth and profit margins",
|
| 853 |
],
|
| 854 |
cache_examples=False,
|
| 855 |
+
title="📊 Financial Reporting Analysis Expert",
|
| 856 |
+
description="I'm a financial analysis expert specializing in SEC EDGAR data. Ask me to analyze any US-listed company's financial performance, and I'll provide professional insights based on real financial reports."
|
| 857 |
)
|
| 858 |
|
| 859 |
with gr.Tab("Direct Query"):
|