JC321 commited on
Commit
ecbeffc
·
verified ·
1 Parent(s): b3955c8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -42
app.py CHANGED
@@ -617,43 +617,36 @@ def chatbot_response(message, history):
617
  # 构建对话历史
618
  messages = []
619
 
620
- # 系统提示词 - 更智能、更自然
621
- system_prompt = """You are an intelligent financial assistant with real-time access to SEC EDGAR data for all US-listed companies.
622
 
623
- Your personality:
624
- - Conversational and friendly, not robotic
625
- - Knowledgeable about finance but explain things clearly
626
- - Proactive in offering insights and comparisons
627
- - Ask clarifying questions when needed
628
 
629
- Your capabilities:
630
- You have access to three powerful tools that let you fetch real financial data:
 
 
631
 
632
- 1. **advanced_search_company(company_input)** - Find any US company by name or ticker
633
- - Works with: "Apple", "AAPL", "Microsoft", "MSFT", etc.
634
-
635
- 2. **get_latest_financial_data(cik)** - Get the most recent financial report
636
- - Returns: Revenue, Net Income, EPS, Operating Expenses, Cash Flow
637
- - Data comes from latest 10-K or 10-Q filings
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
- How to respond:
644
- - For general questions, just chat naturally
645
- - When users mention companies, automatically fetch data without asking permission
646
- - Analyze and interpret the data, don't just dump numbers
647
- - Compare metrics, spot trends, and provide insights
648
- - If data is missing or unclear, explain why
649
- - Suggest follow-up questions or related analyses
650
 
651
- Examples of good responses:
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
- "Show me Apple's latest financial data",
853
- "What's NVIDIA's 3-year financial trend?",
854
- "Compare Tesla's revenue with its expenses",
855
- "How is Microsoft performing financially?",
856
- "What can you tell me about Amazon's recent earnings?",
857
- "Give me Alibaba's 5-year financial overview",
858
- "Hello! What can you help me with?",
859
- "What's the weather like today?", # 测试非财务问题
860
  ],
861
  cache_examples=False,
862
- title="🤖 Intelligent Financial Assistant",
863
- description="Ask me anything! I can help with financial data queries or general conversations. When you ask about companies, I'll automatically fetch real-time SEC EDGAR data."
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"):