Skip to content

Commit

Permalink
Fix: event loop for DuckDuckGoSearch (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiangning30 authored Aug 2, 2024
1 parent 34284d7 commit d37ff17
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lagent/actions/bing_browser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import json
import logging
import random
Expand Down Expand Up @@ -70,6 +71,8 @@ def search(self, query: str, max_retry: int = 3) -> dict:
'Failed to get search results from DuckDuckGo after retries.')

def _call_ddgs(self, query: str, **kwargs) -> dict:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
ddgs = DDGS(**kwargs)
response = ddgs.text(query.strip("'"), max_results=10)
return response
Expand Down

0 comments on commit d37ff17

Please sign in to comment.