Sachin-Hansaka's picture
src
6fe4093 verified
from langchain_community.tools import ArxivQueryRun
from langchain_community.utilities import ArxivAPIWrapper
from langgraph.prebuilt import ToolNode
def get_arxiv_tools():
"""
Return the list of ArXiv tools for research assistance
"""
# Initialize ArXiv API wrapper with configuration
arxiv_wrapper = ArxivAPIWrapper(
top_k_results=5, # Return top 5 most relevant papers
doc_content_chars_max=5000 # Limit content to 5000 characters per paper
)
# Create ArXiv query tool
arxiv_tool = ArxivQueryRun(api_wrapper=arxiv_wrapper)
tools = [arxiv_tool]
return tools
def create_arxiv_tool_node(tools):
"""
Creates and returns a tool node for ArXiv research tools
"""
return ToolNode(tools=tools)
def get_research_assistant_tools():
"""
Return combined tools for research assistant (ArXiv + web search if needed)
"""
from .search_tool import get_tools as get_web_tools
# Get ArXiv tools
arxiv_tools = get_arxiv_tools()
# Get web search tools
web_tools = get_web_tools()
# Combine both tool sets for comprehensive research
combined_tools = arxiv_tools + web_tools
return combined_tools