diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 8d008dafcc..b615a1264c 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -327,6 +327,7 @@ from open_webui.config import ( ENABLE_MESSAGE_RATING, ENABLE_USER_WEBHOOKS, ENABLE_EVALUATION_ARENA_MODELS, + ENABLE_ADMIN_WORKSPACE_CONTENT_ACCESS, USER_PERMISSIONS, DEFAULT_USER_ROLE, PENDING_USER_OVERLAY_CONTENT, @@ -1320,7 +1321,7 @@ async def get_models( model_order_dict = {model_id: i for i, model_id in enumerate(model_order_list)} # Sort models by order list priority, with fallback for those not in the list models.sort( - key=lambda x: (model_order_dict.get(x["id"], float("inf")), x["name"]) + key=lambda x: (model_order_dict.get(x["id"], float("inf")), x.get("name")) ) # Filter out models that the user does not have access to @@ -1395,7 +1396,9 @@ async def chat_completion( model_info = Models.get_model_by_id(model_id) # Check if user has access to the model - if not BYPASS_MODEL_ACCESS_CONTROL and user.role == "user": + if not BYPASS_MODEL_ACCESS_CONTROL and ( + user.role != "admin" or not ENABLE_ADMIN_WORKSPACE_CONTENT_ACCESS + ): try: check_model_access(user, model) except Exception as e: diff --git a/backend/open_webui/retrieval/utils.py b/backend/open_webui/retrieval/utils.py index 539adda329..7e13cbf164 100644 --- a/backend/open_webui/retrieval/utils.py +++ b/backend/open_webui/retrieval/utils.py @@ -124,12 +124,14 @@ def query_doc_with_hybrid_search( hybrid_bm25_weight: float, ) -> dict: try: - log.debug(f"query_doc_with_hybrid_search:doc {collection_name}") - bm25_retriever = BM25Retriever.from_texts( - texts=collection_result.documents[0], - metadatas=collection_result.metadatas[0], - ) - bm25_retriever.k = k + # BM_25 required only if weight is greater than 0 + if hybrid_bm25_weight > 0: + log.debug(f"query_doc_with_hybrid_search:doc {collection_name}") + bm25_retriever = BM25Retriever.from_texts( + texts=collection_result.documents[0], + metadatas=collection_result.metadatas[0], + ) + bm25_retriever.k = k vector_search_retriever = VectorSearchRetriever( collection_name=collection_name, @@ -337,18 +339,22 @@ def query_collection_with_hybrid_search( # Fetch collection data once per collection sequentially # Avoid fetching the same data multiple times later collection_results = {} - for collection_name in collection_names: - try: - log.debug( - f"query_collection_with_hybrid_search:VECTOR_DB_CLIENT.get:collection {collection_name}" - ) - collection_results[collection_name] = VECTOR_DB_CLIENT.get( - collection_name=collection_name - ) - except Exception as e: - log.exception(f"Failed to fetch collection {collection_name}: {e}") - collection_results[collection_name] = None - + # Only retrieve entire collection if bm_25 calculation is required + if hybrid_bm25_weight > 0: + for collection_name in collection_names: + try: + log.debug( + f"query_collection_with_hybrid_search:VECTOR_DB_CLIENT.get:collection {collection_name}" + ) + collection_results[collection_name] = VECTOR_DB_CLIENT.get( + collection_name=collection_name + ) + except Exception as e: + log.exception(f"Failed to fetch collection {collection_name}: {e}") + collection_results[collection_name] = None + else: + for collection_name in collection_names: + collection_results[collection_name] = [] log.info( f"Starting hybrid search for {len(queries)} queries in {len(collection_names)} collections..." ) diff --git a/backend/open_webui/utils/tools.py b/backend/open_webui/utils/tools.py index e9506fd2d8..45f0ef7dda 100644 --- a/backend/open_webui/utils/tools.py +++ b/backend/open_webui/utils/tools.py @@ -38,6 +38,7 @@ from open_webui.models.users import UserModel from open_webui.utils.plugin import load_tool_module_by_id from open_webui.env import ( SRC_LOG_LEVELS, + AIOHTTP_CLIENT_TIMEOUT, AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA, AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL, ) @@ -613,7 +614,9 @@ async def execute_tool_server( if token: headers["Authorization"] = f"Bearer {token}" - async with aiohttp.ClientSession(trust_env=True) as session: + async with aiohttp.ClientSession( + trust_env=True, timeout=aiohttp.ClientTimeout(total=AIOHTTP_CLIENT_TIMEOUT) + ) as session: request_method = getattr(session, http_method.lower()) if http_method in ["post", "put", "patch"]: diff --git a/src/lib/components/admin/Settings/Connections.svelte b/src/lib/components/admin/Settings/Connections.svelte index 11a67322b5..0b9d2874b2 100644 --- a/src/lib/components/admin/Settings/Connections.svelte +++ b/src/lib/components/admin/Settings/Connections.svelte @@ -6,7 +6,7 @@ import { getOllamaConfig, updateOllamaConfig } from '$lib/apis/ollama'; import { getOpenAIConfig, updateOpenAIConfig, getOpenAIModels } from '$lib/apis/openai'; - import { getModels as _getModels } from '$lib/apis'; + import { getModels as _getModels, getBackendConfig } from '$lib/apis'; import { getConnectionsConfig, setConnectionsConfig } from '$lib/apis/configs'; import { config, models, settings, user } from '$lib/stores'; @@ -114,6 +114,7 @@ if (res) { toast.success($i18n.t('Connections settings updated')); await models.set(await getModels()); + await config.set(await getBackendConfig()); } }; @@ -198,6 +199,8 @@ updateOllamaHandler(); dispatch('save'); + + await config.set(await getBackendConfig()); }; diff --git a/src/lib/components/admin/Users/Groups/GroupItem.svelte b/src/lib/components/admin/Users/Groups/GroupItem.svelte index c84eb4b3aa..f7a065eda6 100644 --- a/src/lib/components/admin/Users/Groups/GroupItem.svelte +++ b/src/lib/components/admin/Users/Groups/GroupItem.svelte @@ -1,6 +1,6 @@ {#each userGroups as userGroup} - {userGroup.name} + + goto('/admin/users/groups?id=' + userGroup.id)} + > + {userGroup.name} + {/each} diff --git a/src/lib/components/chat/Navbar.svelte b/src/lib/components/chat/Navbar.svelte index da00f24159..b44ced62d9 100644 --- a/src/lib/components/chat/Navbar.svelte +++ b/src/lib/components/chat/Navbar.svelte @@ -59,7 +59,7 @@ aria-label="New Chat" /> -