Skip to content

Commit

Permalink
fix(bug): refactor Tavily class to prioritize metadata over config fo…
Browse files Browse the repository at this point in the history
…r API key
  • Loading branch information
elisalimli committed Apr 10, 2024
1 parent 101626d commit b0ad699
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/superagent/app/tools/tavily.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Tavily(BaseTool):

def _run(self, query: str) -> str:
tavily = TavilyClient(
api_key=config("TAVILY_API_KEY") or self.metadata.get("apiKey")
api_key=self.metadata.get("apiKey") or config("TAVILY_API_KEY")
)
response = tavily.search(query=query, search_depth="advanced")
context = [
Expand All @@ -22,7 +22,7 @@ def _run(self, query: str) -> str:

async def _arun(self, query: str) -> str:
tavily = TavilyClient(
api_key=config("TAVILY_API_KEY") or self.metadata.get("apiKey")
api_key=self.metadata.get("apiKey") or config("TAVILY_API_KEY")
)
loop = asyncio.get_event_loop()
response = await loop.run_in_executor(None, tavily.search, query, "advanced")
Expand Down

0 comments on commit b0ad699

Please sign in to comment.