ameglei-external commited on
Commit
7dc40c2
·
verified ·
1 Parent(s): e027c55

Don't mess with self, make search tool to be a staticmethod

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -29,7 +29,7 @@ class State(TypedDict):
29
 
30
  class BasicAgent:
31
  def __init__(self):
32
- self.tools = [self.search_tool]
33
 
34
  # Chat model with tool support
35
  self.model = ChatOpenAI(model="gpt-4o", temperature=0)
@@ -82,10 +82,11 @@ class BasicAgent:
82
  "messages": [response]
83
  }
84
 
 
85
  @tool(
86
  description="Search the web using DuckDuckGo and return the best result snippet.",
87
  )
88
- def search_tool(self, question: str, max_length: int = 2048) -> str:
89
  print(f"Calling search tool with: {question}, max_lentgh: {max_length}")
90
  with DDGS() as ddgs:
91
  hits = list(ddgs.text(question, max_results=5))
 
29
 
30
  class BasicAgent:
31
  def __init__(self):
32
+ self.tools = [BasicAgent.search_tool]
33
 
34
  # Chat model with tool support
35
  self.model = ChatOpenAI(model="gpt-4o", temperature=0)
 
82
  "messages": [response]
83
  }
84
 
85
+ @staticmethod
86
  @tool(
87
  description="Search the web using DuckDuckGo and return the best result snippet.",
88
  )
89
+ def search_tool(question: str, max_length: int = 2048) -> str:
90
  print(f"Calling search tool with: {question}, max_lentgh: {max_length}")
91
  with DDGS() as ddgs:
92
  hits = list(ddgs.text(question, max_results=5))