mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-15 23:31:29 +00:00
fix: cache openapi registry, make oauth optional, reset preset auto-select on new preset
This commit is contained in:
parent
691ecc685b
commit
a2537d2ed2
3 changed files with 13 additions and 1 deletions
|
|
@ -15,6 +15,7 @@ Endpoints here:
|
|||
|
||||
"""
|
||||
|
||||
import functools
|
||||
import importlib
|
||||
import json
|
||||
import os
|
||||
|
|
@ -1370,6 +1371,7 @@ if MCP_AVAILABLE:
|
|||
"openapi_registry.json",
|
||||
)
|
||||
|
||||
@functools.lru_cache(maxsize=1)
|
||||
def _load_openapi_registry() -> Dict[str, Any]:
|
||||
try:
|
||||
with open(_OPENAPI_REGISTRY_PATH, "r") as f:
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface OpenAPIRegistryEntry {
|
|||
description: string;
|
||||
icon_url: string;
|
||||
spec_url: string;
|
||||
oauth: {
|
||||
oauth?: {
|
||||
authorization_url: string;
|
||||
token_url: string;
|
||||
pkce: boolean;
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ const MCPToolConfiguration: React.FC<MCPToolConfigurationProps> = ({
|
|||
const previousToolsRef = useRef<ToolEntry[]>([]);
|
||||
const [toolSearchTerm, setToolSearchTerm] = useState("");
|
||||
const hasInitializedRef = useRef(false);
|
||||
const previousSuggestedToolNamesRef = useRef<string>("");
|
||||
const [expandedTools, setExpandedTools] = useState<Set<string>>(new Set());
|
||||
|
||||
const { tools, isLoadingTools, toolsError, canFetchTools } = useTestMCPConnection({
|
||||
|
|
@ -223,6 +224,15 @@ const MCPToolConfiguration: React.FC<MCPToolConfigurationProps> = ({
|
|||
const previousToolNames = previousToolsRef.current.map((tool) => tool.name).sort().join(",");
|
||||
const toolsListChanged = currentToolNames !== previousToolNames;
|
||||
|
||||
// Reset initialization when a new preset is selected (suggestedTools fingerprint changes)
|
||||
const currentSuggestedNames = suggestedTools.map((t) => t.name).sort().join(",");
|
||||
if (currentSuggestedNames !== previousSuggestedToolNamesRef.current) {
|
||||
previousSuggestedToolNamesRef.current = currentSuggestedNames;
|
||||
if (currentSuggestedNames !== "") {
|
||||
hasInitializedRef.current = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (tools.length > 0 && toolsListChanged) {
|
||||
const availableToolNames = tools.map((tool) => tool.name);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue