diff --git a/litellm/proxy/_types.py b/litellm/proxy/_types.py index 6322a1212fe..2bf7b1ee803 100644 --- a/litellm/proxy/_types.py +++ b/litellm/proxy/_types.py @@ -123,6 +123,7 @@ class SupportedDBObjectType(str, enum.Enum): MODEL_COST_MAP = "model_cost_map" TOOLS = "tools" CONFIG_OVERRIDES = "config_overrides" + WEBSEARCH_INTERCEPTION_SETTINGS = "websearch_interception_settings" def __str__(self): return str(self.value) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 9579807d01c..3660506dbc8 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -7714,7 +7714,7 @@ class ProxyConfig: if self._should_load_db_object(object_type="semantic_filter_settings"): await self._init_semantic_filter_settings_in_db(prisma_client=prisma_client) - if self._should_load_db_object(object_type="websearch_interception_settings"): + if self._should_load_db_object(object_type=SupportedDBObjectType.WEBSEARCH_INTERCEPTION_SETTINGS): await self.init_websearch_interception_settings_in_db(prisma_client=prisma_client) if self._should_load_db_object(object_type="config_overrides"): diff --git a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py index 5606ffda02d..462489f48b0 100644 --- a/tests/test_litellm/proxy/proxy_server/test_proxy_config.py +++ b/tests/test_litellm/proxy/proxy_server/test_proxy_config.py @@ -4700,3 +4700,17 @@ def test_init_websearch_interception_honors_enabled_providers(monkeypatch): registered = [cb for cb in litellm.callbacks if isinstance(cb, logger_cls)] assert len(registered) == 1 assert registered[0].enabled_providers == ["bedrock", "vertex_ai"] + + +def test_websearch_interception_settings_can_be_named_in_supported_db_objects(monkeypatch): + from litellm.proxy import proxy_server + from litellm.proxy._types import ConfigGeneralSettings + + allowlist = ConfigGeneralSettings(supported_db_objects=["websearch_interception_settings"]).supported_db_objects + assert allowlist + + monkeypatch.setattr(proxy_server, "general_settings", {"supported_db_objects": allowlist}) + assert proxy_server.should_load_db_object(object_type="websearch_interception_settings") is True + + monkeypatch.setattr(proxy_server, "general_settings", {"supported_db_objects": ["models"]}) + assert proxy_server.should_load_db_object(object_type="websearch_interception_settings") is False diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useUpdateWebSearchInterceptionSettings.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useUpdateWebSearchInterceptionSettings.ts index 7de84c52310..ae6454aaba0 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useUpdateWebSearchInterceptionSettings.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useUpdateWebSearchInterceptionSettings.ts @@ -1,4 +1,4 @@ -import { updateWebSearchInterceptionSettings } from "@/components/networking"; +import { updateWebSearchInterceptionSettings, type WebSearchInterceptionSettings } from "@/components/networking"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { createQueryKeys } from "../common/queryKeysFactory"; @@ -8,7 +8,7 @@ export const useUpdateWebSearchInterceptionSettings = (accessToken: string) => { const queryClient = useQueryClient(); return useMutation({ - mutationFn: async (settings: Record) => { + mutationFn: async (settings: WebSearchInterceptionSettings) => { if (!accessToken) { throw new Error("Access token is required"); } diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useWebSearchInterceptionSettings.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useWebSearchInterceptionSettings.ts index 4c2b549209c..0e6a28ad742 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useWebSearchInterceptionSettings.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/webSearchInterceptionSettings/useWebSearchInterceptionSettings.ts @@ -1,4 +1,4 @@ -import { getWebSearchInterceptionSettings } from "@/components/networking"; +import { getWebSearchInterceptionSettings, type WebSearchInterceptionSettingsResponse } from "@/components/networking"; import { useQuery } from "@tanstack/react-query"; import { createQueryKeys } from "../common/queryKeysFactory"; import useAuthorized from "../useAuthorized"; @@ -7,7 +7,7 @@ const webSearchInterceptionSettingsKeys = createQueryKeys("webSearchInterception export const useWebSearchInterceptionSettings = () => { const { accessToken } = useAuthorized(); - return useQuery>({ + return useQuery({ queryKey: webSearchInterceptionSettingsKeys.list({}), queryFn: async () => await getWebSearchInterceptionSettings(accessToken), enabled: !!accessToken, diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index b82674f42d1..ab1203cf440 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -3667,17 +3667,26 @@ export const updateMCPSemanticFilterSettings = async (accessToken: string, setti } }; -export const getWebSearchInterceptionSettings = async (accessToken: string) => { +export type WebSearchInterceptionSettings = components["schemas"]["WebSearchInterceptionSettings"]; +export type WebSearchInterceptionSettingsResponse = components["schemas"]["WebSearchInterceptionSettingsResponse"]; + +export const getWebSearchInterceptionSettings = async ( + accessToken: string, +): Promise => { try { - const data = await apiClient.get(`/get/websearch_interception_settings`, { accessToken }); - return data; + return await apiClient.get(`/get/websearch_interception_settings`, { + accessToken, + }); } catch (error) { console.error("Failed to get web search interception settings:", error); throw error; } }; -export const updateWebSearchInterceptionSettings = async (accessToken: string, settings: Record) => { +export const updateWebSearchInterceptionSettings = async ( + accessToken: string, + settings: WebSearchInterceptionSettings, +) => { try { return await apiClient.patch(`/update/websearch_interception_settings`, { accessToken, body: settings }); } catch (error) { diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts index 393f7a048ce..7e725da3f46 100644 --- a/ui/litellm-dashboard/src/lib/http/schema.d.ts +++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts @@ -38068,7 +38068,7 @@ export interface components { * Use in general_settings.supported_db_objects to specify which objects to load from DB. * @enum {string} */ - SupportedDBObjectType: "models" | "mcp" | "guardrails" | "policies" | "vector_stores" | "pass_through_endpoints" | "prompts" | "model_cost_map" | "tools" | "config_overrides"; + SupportedDBObjectType: "models" | "mcp" | "guardrails" | "policies" | "vector_stores" | "pass_through_endpoints" | "prompts" | "model_cost_map" | "tools" | "config_overrides" | "websearch_interception_settings"; /** SupportedEndpoint */ SupportedEndpoint: { /** Endpoint */