Refactor web search tool decorator in agent.py from @tools to @tool for improved clarity and consistency.
Browse files
agent.py
CHANGED
|
@@ -4,7 +4,7 @@ from langchain_core import tools
|
|
| 4 |
from langgraph.graph import StateGraph, START, END
|
| 5 |
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint, HuggingFacePipeline
|
| 6 |
from langchain_core.messages import HumanMessage, AIMessage
|
| 7 |
-
from langchain_core.tools import
|
| 8 |
from duckduckgo_search import DDGS
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
|
|
@@ -22,7 +22,7 @@ base_llm = HuggingFaceEndpoint(
|
|
| 22 |
# Chat model that works with LangGraph
|
| 23 |
model = ChatHuggingFace(llm=base_llm)
|
| 24 |
|
| 25 |
-
@
|
| 26 |
def web_search(keywords: str, max_results:int = 5) -> str:
|
| 27 |
"""
|
| 28 |
Uses duckduckgo to search the web
|
|
|
|
| 4 |
from langgraph.graph import StateGraph, START, END
|
| 5 |
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint, HuggingFacePipeline
|
| 6 |
from langchain_core.messages import HumanMessage, AIMessage
|
| 7 |
+
from langchain_core.tools import tool
|
| 8 |
from duckduckgo_search import DDGS
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
|
|
|
|
| 22 |
# Chat model that works with LangGraph
|
| 23 |
model = ChatHuggingFace(llm=base_llm)
|
| 24 |
|
| 25 |
+
@tool
|
| 26 |
def web_search(keywords: str, max_results:int = 5) -> str:
|
| 27 |
"""
|
| 28 |
Uses duckduckgo to search the web
|