crazyafro/financial_intelligence_agent
0
1from langchain_openai import ChatOpenAI2from langchain_core.messages import SystemMessage3from agents.state import AgentState, keep_last4from tools import REPORT_TOOLS5 6SYSTEM_PROMPT = (7 "You are a reporting specialist who creates professional financial intelligence reports. "8 "Use format_markdown_report to structure raw data into a clean, professional Markdown document "9 "with sections: Executive Summary, Key Financial Data, Market Analysis, News Highlights, and Conclusion. "10 "Use save_report_to_file to persist the formatted report to the reports/ directory. "11 "Always format first, then save. Ensure reports are comprehensive, accurate, and professionally written."12)13 14def report_agent_node(state: AgentState) -> dict:15 llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)16 llm_with_tools = llm.bind_tools(REPORT_TOOLS)17 messages = [SystemMessage(content=SYSTEM_PROMPT)] + keep_last(state["messages"])18 response = llm_with_tools.invoke(messages)19 return {20 "messages": [response],21 "active_agents": state.get("active_agents", []) + ["report_agent"],22 }23 