MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / handle_parameter_cache

Function handle_parameter_cache

api_utils/model_switching.py:102–121  ·  view source on GitHub ↗
(req_id: str, context: RequestContext)

Source from the content-addressed store, hash-verified

100
101
102async def handle_parameter_cache(req_id: str, context: RequestContext) -> None:
103 set_request_id(req_id)
104 logger = context["logger"]
105 params_cache_lock = context["params_cache_lock"]
106 page_params_cache = context["page_params_cache"]
107 current_ai_studio_model_id = context["current_ai_studio_model_id"]
108 model_actually_switched = context["model_actually_switched"]
109
110 async with params_cache_lock:
111 cached_model_for_params = page_params_cache.get(
112 "last_known_model_id_for_params"
113 )
114 if model_actually_switched or (
115 current_ai_studio_model_id != cached_model_for_params
116 ):
117 logger.info(f"[{req_id}] Model changed, parameter cache invalidated.")
118 page_params_cache.clear()
119 page_params_cache["last_known_model_id_for_params"] = (
120 current_ai_studio_model_id
121 )

Calls 4

set_request_idFunction · 0.90
infoMethod · 0.80
getMethod · 0.45
clearMethod · 0.45