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
eb3fcef6
Unverified
Commit
eb3fcef6
authored
Jun 03, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 03, 2024
Browse files
Merge pull request #2784 from open-webui/dev
fix
parents
14646e84
59a730cb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
backend/apps/rag/search/searxng.py
backend/apps/rag/search/searxng.py
+23
-17
No files found.
backend/apps/rag/search/searxng.py
View file @
eb3fcef6
...
...
@@ -10,14 +10,16 @@ log = logging.getLogger(__name__)
log
.
setLevel
(
SRC_LOG_LEVELS
[
"RAG"
])
def
search_searxng
(
query_url
:
str
,
query
:
str
,
count
:
int
,
**
kwargs
)
->
List
[
SearchResult
]:
def
search_searxng
(
query_url
:
str
,
query
:
str
,
count
:
int
,
**
kwargs
)
->
List
[
SearchResult
]:
"""
Search a SearXNG instance for a given query and return the results as a list of SearchResult objects.
The function allows passing additional parameters such as language or time_range to tailor the search result.
Args:
query_url (str): The base URL of the SearXNG server
with a placeholder for the query "<query>"
.
query_url (str): The base URL of the SearXNG server.
query (str): The search term or question to find in the SearXNG database.
count (int): The maximum number of results to retrieve from the search.
...
...
@@ -34,24 +36,28 @@ def search_searxng(query_url: str, query: str, count: int, **kwargs) -> List[Sea
"""
# Default values for optional parameters are provided as empty strings or None when not specified.
language
=
kwargs
.
get
(
'
language
'
,
'
en-US
'
)
time_range
=
kwargs
.
get
(
'
time_range
'
,
''
)
categories
=
''
.
join
(
kwargs
.
get
(
'
categories
'
,
[]))
language
=
kwargs
.
get
(
"
language
"
,
"
en-US
"
)
time_range
=
kwargs
.
get
(
"
time_range
"
,
""
)
categories
=
""
.
join
(
kwargs
.
get
(
"
categories
"
,
[]))
params
=
{
"q"
:
query
,
"format"
:
"json"
,
"pageno"
:
1
,
"results_per_page"
:
count
,
'language'
:
language
,
'time_range'
:
time_range
,
'engines'
:
''
,
'categories'
:
categories
,
'theme'
:
'simple'
,
'image_proxy'
:
0
"language"
:
language
,
"time_range"
:
time_range
,
"engines"
:
""
,
"categories"
:
categories
,
"theme"
:
"simple"
,
"image_proxy"
:
0
,
}
# Legacy query format
if
"<query>"
in
query_url
:
# Strip all query parameters from the URL
query_url
=
query_url
.
split
(
"?"
)[
0
]
log
.
debug
(
f
"searching
{
query_url
}
"
)
response
=
requests
.
get
(
...
...
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