Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
7d2ad8c4
Unverified
Commit
7d2ad8c4
authored
Jun 17, 2024
by
Que Nguyen
Committed by
GitHub
Jun 17, 2024
Browse files
Set filter_list as optional param in duckduckgo.py
parent
a02139ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
backend/apps/rag/search/duckduckgo.py
backend/apps/rag/search/duckduckgo.py
+6
-6
No files found.
backend/apps/rag/search/duckduckgo.py
View file @
7d2ad8c4
import
logging
from
typing
import
List
from
apps.rag.search.main
import
SearchResult
,
filter
_by_whitelist
from
typing
import
List
,
Optional
from
apps.rag.search.main
import
SearchResult
,
get_
filter
ed_results
from
duckduckgo_search
import
DDGS
from
config
import
SRC_LOG_LEVELS
...
...
@@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"RAG"
])
def
search_duckduckgo
(
query
:
str
,
count
:
int
,
whitelist
:
List
[
str
])
->
list
[
SearchResult
]:
def
search_duckduckgo
(
query
:
str
,
count
:
int
,
filter_list
:
Optional
[
List
[
str
]
]
=
None
)
->
list
[
SearchResult
]:
"""
Search using DuckDuckGo's Search API and return the results as a list of SearchResult objects.
Args:
...
...
@@ -41,7 +41,7 @@ def search_duckduckgo(query: str, count: int, whitelist:List[str]) -> list[Searc
snippet
=
result
.
get
(
"body"
),
)
)
# print(results)
filtered_
results
=
filter
_by_whitelist
(
results
,
white
list
)
if
filter_list
:
results
=
get_
filter
ed_results
(
results
,
filter_
list
)
# Return the list of search results
return
filtered_
results
return
results
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment