wildedge-python icon indicating copy to clipboard operation
wildedge-python copied to clipboard

gguf integration does not track create_chat_completion or create_completion

Open piotrekno1 opened this issue 1 month ago • 0 comments

What happens

The gguf integration only tracks Llama.__call__. Llama.create_chat_completion is not tracked: llama-cpp-python's chat handlers call llama.create_completion(...) directly (llama_chat_format.py), so they never go through the patched __call__. create_completion called directly is missed too.

Chat completion is the usual way to run an instruct model, so an app using it gets the model load event and nothing else. It has to register the model with auto_instrument=False and build track_inference itself: TextInputMeta, GenerationOutputMeta from usage and finish_reason, and GenerationConfig from the call's keyword arguments.

Expected

Track create_completion and create_chat_completion (streaming and non-streaming), once per call:

  • tokens in and out, tokens per second and stop reason from the result's usage and choices[0].finish_reason
  • GenerationConfig from temperature, top_p, max_tokens and repeat_penalty
  • TextInputMeta with prompt_type="chat" and the number of user turns, for chat calls
  • when attachments are enabled, the messages as input and the reply as output

__call__ delegates to create_completion, so patching create_completion would cover all three without double counting.

Found in evil-jarvis, which tracks this by hand today (src/evil_jarvis/telemetry.py, track_generation). SDK 0.2.2, llama-cpp-python 0.3.x.

🤖 Generated with Claude Code

piotrekno1 avatar Oct 19 '26 21:10 piotrekno1