Debug

NAME

LLM::Chat::Debug - Optional wire-level debug log for chat backends

DESCRIPTION

Append-only file logger for raw HTTP traffic on chat backends. Gated on the LLM_CHAT_DEBUG environment variable: when set, treated as a filesystem path and every request / response chunk is appended there. When unset, every log call is a no-op so the production cost is a hash lookup per call.

The logger serialises concurrent writes through an internal lock — it's safe to call from multiple in-flight backends at once.

The Authorization header is redacted automatically when a header hash is logged via log-headers; everything else is written verbatim, so prompts, model names, generation ids, and provider-specific extras are all visible. Keep the log out of source control.

SYNOPSIS


# Enable for the lifetime of a process:
#   LLM_CHAT_DEBUG=/tmp/llm-chat.log raku script.raku
#   tail -f /tmp/llm-chat.log

use LLM::Chat::Debug;

LLM::Chat::Debug.log('REQUEST URL',  $url);
LLM::Chat::Debug.log-headers('REQUEST HEADERS', %headers);
LLM::Chat::Debug.log-json('REQUEST BODY', %body);

# In a streaming loop:
LLM::Chat::Debug.log('SSE LINE', $raw-line);

LLM::Chat::Debug.log('RESPONSE END', "done");

LLM::Chat v0.10.0

Simple framework for LLM inferencing

Authors

  • Matt Doughty

License

Artistic-2.0

Dependencies

Cro::HTTP::Client:ver<0.8.11+>:auth<zef:cro>Digest::SHA256::Native:ver<1.0.0+>:auth<zef:bduggan>JSON::Fast:ver<0.19+>:auth<cpan:TIMOTIMO>Template::Jinja2:ver<0.3.0+>:auth<zef:apogee>Tokenizers:ver<0.3.0+>:auth<zef:apogee>UUID::V4:ver<1.0.0+>:auth<zef:masukomi>

Provides

  • LLM::Chat
  • LLM::Chat::Backend
  • LLM::Chat::Backend::KoboldCpp
  • LLM::Chat::Backend::Mock
  • LLM::Chat::Backend::OpenAICommon
  • LLM::Chat::Backend::OpenRouter
  • LLM::Chat::Backend::Response
  • LLM::Chat::Backend::Response::OpenRouter
  • LLM::Chat::Backend::Response::OpenRouter::Augment
  • LLM::Chat::Backend::Response::OpenRouter::Stream
  • LLM::Chat::Backend::Response::Stream
  • LLM::Chat::Backend::Settings
  • LLM::Chat::Conversation
  • LLM::Chat::Conversation::Message
  • LLM::Chat::Debug
  • LLM::Chat::Retry
  • LLM::Chat::Retry::Exceptions
  • LLM::Chat::Template
  • LLM::Chat::Template::ChatML
  • LLM::Chat::Template::DeepSeekV4
  • LLM::Chat::Template::Gemma2
  • LLM::Chat::Template::Jinja2
  • LLM::Chat::Template::Llama3
  • LLM::Chat::Template::Llama4
  • LLM::Chat::Template::MistralV7
  • LLM::Chat::TokenCounter
  • LLM::Chat::ToolLoop

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.