CoolFace
Apppublic

crazyafro/financial_intelligence_agent

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
finance_agent.py24 linesDownload Raw Back to agents
1from langchain_openai import ChatOpenAI2from langchain_core.messages import SystemMessage3from agents.state import AgentState, keep_last4from tools import FINANCE_TOOLS5 6SYSTEM_PROMPT = (7    "You are a financial data retrieval specialist. Fetch the requested live market data and return it as-is. "8    "Use get_stock_price for equity data: price, market cap, P/E ratio, 52-week range. "9    "Use get_crypto_price for cryptocurrency price and 24h market data. "10    "Use get_exchange_rate for currency pair rates. "11    "Return the raw fetched numbers clearly. Do NOT perform calculations, do NOT convert currencies yourself, "12    "and do NOT write summaries or analysis — just fetch and return the data."13)14 15def finance_agent_node(state: AgentState) -> dict:16    llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)17    llm_with_tools = llm.bind_tools(FINANCE_TOOLS)18    messages = [SystemMessage(content=SYSTEM_PROMPT)] + keep_last(state["messages"])19    response = llm_with_tools.invoke(messages)20    return {21        "messages": [response],22        "active_agents": state.get("active_agents", []) + ["finance_agent"],23    }24