This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @dataclass | |
| class NarrativeAgent: | |
| def run(self, state: Dict[str, Any]) -> Dict[str, Any]: | |
| symbol = state["symbol"] | |
| signals = state.get("signals", []) | |
| fired = [s for s in signals if s.get("fired")] | |
| score = len(fired) | |
| if score >= 3: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # agents/ratios_agent.py | |
| from state import ResearchState | |
| from mcp_client import call_mcp_tool | |
| class RatiosAgent: | |
| def run(self, state: ResearchState) -> ResearchState: | |
| symbol = state.symbol | |
| if not symbol: | |
| raise ValueError("Symbol missing in state.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # agents/fundamentals_agent.py | |
| from state import ResearchState | |
| from mcp_client import call_mcp_tool | |
| class FundamentalsAgent: | |
| def run(self, state: ResearchState) -> ResearchState: | |
| symbol = state.symbol | |
| if not symbol: | |
| raise ValueError("Symbol missing in state.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # agents/profile_agent.py | |
| from typing import Optional | |
| from state import ResearchState | |
| from mcp_client import call_mcp_tool | |
| class ProfileAgent: | |
| def _extract_symbol(self, query: str) -> Optional[str]: | |
| # simple heuristic: if user passes "NVDA" or "AAPL" | |
| parts = query.strip().split() | |
| for token in parts: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from agents.profile_agent import ProfileAgent | |
| from agents.fundamentals_agent import FundamentalsAgent | |
| from agents.ratios_agent import RatiosAgent | |
| from agents.risk_agent import RiskAgent | |
| from agents.summary_agent import SummaryAgent | |
| from state import ResearchState | |
| def run_research_pipeline(query: str) -> ResearchState: | |
| state = ResearchState(query=query) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass, field | |
| from typing import Any, Dict, List, Optional | |
| @dataclass | |
| class ResearchState: | |
| # user input | |
| query: str | |
| symbol: Optional[str] = None | |
| # core data blobs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| from config import FMP_MCP_ENDPOINT | |
| def call_mcp_tool(tool_name: str, params: dict | None = None): | |
| payload = { | |
| "jsonrpc": "2.0", | |
| "id": 1, | |
| "method": tool_name, | |
| "params": params or {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mylst = [10,20,30] | |
| a,b,c = mylst | |
| print(c, a, b ) | |
| print(a, c, b ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sum(i for i in range(5) ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| str ="Python" | |
| print(str * 4) |
NewerOlder