Callback handler that writes to a file.
This handler supports both context manager usage (recommended) and direct instantiation (deprecated) for backwards compatibility.
When not used as a context manager, a deprecation warning will be issued on
first use. The file will be opened immediately in __init__ and closed in
__del__ or when close() is called explicitly.
Close the file if it's open.
This method is safe to call multiple times and will only close the file if it's currently open.
Print that we are entering a chain.
Print that we finished a chain.
Handle agent action by writing the action log.
Handle tool end by writing the output with optional prefixes.
Handle text output.
Handle agent finish by writing the finish log.
Whether to raise an error if an exception occurs.
Whether to ignore LLM callbacks.
Whether to ignore retry callbacks.
Whether to ignore chain callbacks.
Whether to ignore agent callbacks.
Whether to ignore retriever callbacks.
Whether to ignore chat model callbacks.
Ignore custom event.