MCPcopy Create free account
hub / github.com/abetlen/llama-cpp-python / __call__

Method __call__

llama_cpp/server/model.py:36–54  ·  view source on GitHub ↗
(self, model: Optional[str] = None)

Source from the content-addressed store, hash-verified

34 self._current_model_alias = self._default_model_alias
35
36 def __call__(self, model: Optional[str] = None) -> llama_cpp.Llama:
37 if model is None:
38 model = self._default_model_alias
39
40 if model not in self._model_settings_dict:
41 model = self._default_model_alias
42
43 if model == self._current_model_alias:
44 if self._current_model is not None:
45 return self._current_model
46
47 if self._current_model:
48 self._current_model.close()
49 self._current_model = None
50
51 settings = self._model_settings_dict[model]
52 self._current_model = self.load_llama_from_model_settings(settings)
53 self._current_model_alias = model
54 return self._current_model
55
56 def __getitem__(self, model: str):
57 return self._model_settings_dict[model].model_dump()

Callers

nothing calls this directly

Calls 2

closeMethod · 0.45

Tested by

no test coverage detected