MCPcopy
hub / github.com/1Panel-dev/MaxKB / get_model

Method get_model

apps/common/config/embedding_config.py:36–52  ·  view source on GitHub ↗
(_id, get_model)

Source from the content-addressed store, hash-verified

34
35 @staticmethod
36 def get_model(_id, get_model):
37 model_instance = ModelManage.cache.get(_id)
38 if model_instance is None:
39 lock = ModelManage._get_lock(_id)
40 with lock:
41 model_instance = ModelManage.cache.get(_id)
42 if model_instance is None:
43 model_instance = get_model(_id)
44 ModelManage.cache.set(_id, model_instance, timeout=60 * 60 * 8)
45 else:
46 if model_instance.is_cache_model():
47 ModelManage.cache.touch(_id, timeout=60 * 60 * 8)
48 else:
49 model_instance = get_model(_id)
50 ModelManage.cache.set(_id, model_instance, timeout=60 * 60 * 8)
51 ModelManage.clear_timeout_cache()
52 return model_instance
53
54 @staticmethod
55 def clear_timeout_cache():

Callers 15

is_workspace_manageFunction · 0.45
profileMethod · 0.45
pageMethod · 0.45
_get_user_rolesMethod · 0.45
oneMethod · 0.45
get_user_listMethod · 0.45
get_user_membersMethod · 0.45
update_user_roleFunction · 0.45
_get_workspace_idsFunction · 0.45
get_auth_settingMethod · 0.45

Calls 6

get_modelFunction · 0.85
getMethod · 0.45
_get_lockMethod · 0.45
setMethod · 0.45
is_cache_modelMethod · 0.45
clear_timeout_cacheMethod · 0.45

Tested by

no test coverage detected