MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / __call__

Method __call__

llama_cpp/llama_chat_format.py:4102–4127  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

4100 )
4101
4102 def __call__(self, **kwargs):
4103 llama = kwargs["llama"]
4104
4105 # Clear state for multiple runs
4106 llama.reset()
4107 llama._ctx.kv_cache_clear()
4108 llama.n_tokens = 0
4109
4110 if hasattr(llama, "input_ids"):
4111 llama.input_ids.fill(0)
4112
4113 # Clear any handler state
4114 if hasattr(self, "_last_image_embed"):
4115 self._last_image_embed = None
4116 self._last_image_hash = None
4117
4118 if self.verbose:
4119 messages = kwargs.get("messages", [])
4120 image_count = len(self.get_image_urls(messages))
4121 print(
4122 f"Minimal - Cleared state, processing {image_count} images",
4123 file=sys.stderr,
4124 )
4125
4126 # Use parent implementation
4127 return super().__call__(**kwargs)
4128
4129
4130@register_chat_completion_handler("chatml-function-calling")

Callers

nothing calls this directly

Calls 4

kv_cache_clearMethod · 0.80
resetMethod · 0.45
get_image_urlsMethod · 0.45
__call__Method · 0.45

Tested by

no test coverage detected