cryogenic22 commited on
Commit
503993f
·
verified ·
1 Parent(s): e156a83

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -7,15 +7,13 @@ from langchain.tools import BaseTool
7
  from langchain_community.tools import DuckDuckGoSearchRun
8
  from langchain_openai import OpenAI
9
  from typing import Optional, Type
 
10
 
11
  class SearchTool(BaseTool):
12
  name: str = "Search"
13
  description: str = "Search the internet for information"
14
  return_direct: bool = False
15
-
16
- def __init__(self):
17
- super().__init__()
18
- self.search = DuckDuckGoSearchRun()
19
 
20
  def _run(self, query: str) -> str:
21
  """Execute the search tool"""
@@ -25,6 +23,8 @@ class SearchTool(BaseTool):
25
  """Async implementation"""
26
  raise NotImplementedError("Async not implemented")
27
 
 
 
28
  def setup_api_keys():
29
  """Setup API keys from Hugging Face Spaces secrets"""
30
  try:
 
7
  from langchain_community.tools import DuckDuckGoSearchRun
8
  from langchain_openai import OpenAI
9
  from typing import Optional, Type
10
+ from pydantic import Field
11
 
12
  class SearchTool(BaseTool):
13
  name: str = "Search"
14
  description: str = "Search the internet for information"
15
  return_direct: bool = False
16
+ search: DuckDuckGoSearchRun = Field(default_factory=DuckDuckGoSearchRun)
 
 
 
17
 
18
  def _run(self, query: str) -> str:
19
  """Execute the search tool"""
 
23
  """Async implementation"""
24
  raise NotImplementedError("Async not implemented")
25
 
26
+ # Rest of the code remains the same...
27
+
28
  def setup_api_keys():
29
  """Setup API keys from Hugging Face Spaces secrets"""
30
  try: