omarequalmars
added excel/csv analysis
a1c1d9a
# nodes/core.py (Updated to include Excel tool)
from states.state import AgentState
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from tools.langchain_tools import EXTENDED_TOOLS # ✅ Changed from individual imports
load_dotenv()
openrouter_api_key = os.getenv("OPENROUTER_API_KEY")
if not openrouter_api_key:
raise ValueError("OPENROUTER_API_KEY not found in environment variables")
# Initialize OpenRouter ChatOpenAI
chat = ChatOpenAI(
model="google/gemini-2.5-pro-preview", # Tool-compatible model
temperature=0,
max_retries=2,
base_url="https://openrouter.ai/api/v1",
api_key=openrouter_api_key,
default_headers={
"HTTP-Referer": "https://your-app.com",
"X-Title": "LangGraph Agent",
}
)
# Use EXTENDED_TOOLS which includes Excel support
tools = EXTENDED_TOOLS
chat_with_tools = chat.bind_tools(tools)
def assistant(state: AgentState):
"""Assistant node with Excel support"""
sys_msg = (
"You are a helpful assistant with access to tools. Understand user requests accurately. "
"Use your tools when needed to answer effectively. Strictly follow all user instructions and constraints. "
"Pay attention: your output needs to contain only the final answer without any reasoning since it will be "
"strictly evaluated against a dataset which contains only the specific response. "
"Your final output needs to be just the string or integer containing the answer, not an array or technical stuff."
)
return {
"messages": [chat_with_tools.invoke([sys_msg] + state["messages"])]
}