Compare commits
1 commit
main
...
pensar-aut
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8243d3db86 |
1 changed files with 8 additions and 20 deletions
|
|
@ -55,28 +55,16 @@ async def search(
|
||||||
Notes:
|
Notes:
|
||||||
Searching by dataset is only available in ENABLE_BACKEND_ACCESS_CONTROL mode
|
Searching by dataset is only available in ENABLE_BACKEND_ACCESS_CONTROL mode
|
||||||
"""
|
"""
|
||||||
# Use search function filtered by permissions if access control is enabled
|
# Enforce backend access control by default (secure)
|
||||||
if os.getenv("ENABLE_BACKEND_ACCESS_CONTROL", "false").lower() == "true":
|
# Only proceed if ENABLE_BACKEND_ACCESS_CONTROL is "true" (case insensitive)
|
||||||
return await permissions_search(
|
if os.getenv("ENABLE_BACKEND_ACCESS_CONTROL", "true").lower() != "true":
|
||||||
query_text, query_type, user, dataset_ids, system_prompt_path, top_k
|
raise PermissionError(
|
||||||
|
"Backend access control is disabled. Set ENABLE_BACKEND_ACCESS_CONTROL to 'true' for secure operation."
|
||||||
)
|
)
|
||||||
|
return await permissions_search(
|
||||||
query = await log_query(query_text, query_type.value, user.id)
|
query_text, query_type, user, dataset_ids, system_prompt_path, top_k
|
||||||
|
|
||||||
search_results = await specific_search(
|
|
||||||
query_type,
|
|
||||||
query_text,
|
|
||||||
user,
|
|
||||||
system_prompt_path=system_prompt_path,
|
|
||||||
top_k=top_k,
|
|
||||||
node_type=node_type,
|
|
||||||
node_name=node_name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
await log_result(query.id, json.dumps(search_results, cls=JSONEncoder), user.id)
|
|
||||||
|
|
||||||
return search_results
|
|
||||||
|
|
||||||
|
|
||||||
async def specific_search(
|
async def specific_search(
|
||||||
query_type: SearchType,
|
query_type: SearchType,
|
||||||
|
|
@ -193,4 +181,4 @@ async def specific_search_by_context(
|
||||||
_search_by_context(dataset, user, query_type, query_text, system_prompt_path, top_k)
|
_search_by_context(dataset, user, query_type, query_text, system_prompt_path, top_k)
|
||||||
)
|
)
|
||||||
|
|
||||||
return await asyncio.gather(*tasks)
|
return await asyncio.gather(*tasks)
|
||||||
Loading…
Add table
Reference in a new issue