DocumentationAPI ReferenceRelease Notes
DocumentationLog In
API Reference

DeepchecksCallbackHandler

DeepchecksCallbackHandler

class DeepchecksCallbackHandler(BaseCallbackHandler)

LangChain callback handler that streams chain, LLM, and tool events to the Deepchecks LLM platform.

Attach this handler to a LangChain runnable to automatically capture each step
of an interaction (prompts, responses, tool invocations, errors) and log it as
a Deepchecks interaction under the configured application/version.

Attributes

AttributeDescription
information_retrievalDocuments or context passages retrieved during the current interaction.
inputThe input prompt captured at the start of the current interaction.
outputThe model output captured at the end of the current interaction.
started_atUTC timestamp marking when the current interaction began.
stepsIntermediate steps recorded during the current interaction, one per LangChain run.
user_interaction_idThe user-supplied identifier for the current interaction, as a string.

Methods

MethodDescription
on_chain_endRun when chain ends running.
on_chain_startRun when chain starts running.
on_chat_model_startRun when ChatModel starts running.
on_llm_endRun when LLM ends running.
on_llm_errorRun when LLM errors.
on_llm_startRun when LLM starts running.
on_retriever_endRun when Retriever ends running.
on_retriever_errorRun when Retriever errors.
on_retriever_startRun when Retriever starts running.

information_retrieval

@property
def information_retrieval() -> list[str]

Documents or context passages retrieved during the current interaction.

Returns

input

@property
def input() -> str

The input prompt captured at the start of the current interaction.

Returns

output

@property
def output() -> str

The model output captured at the end of the current interaction.

Returns

started_at

@property
def started_at() -> Union[datetime, None]

UTC timestamp marking when the current interaction began.

Returns

steps

@property
def steps() -> List[Step]

Intermediate steps recorded during the current interaction, one per LangChain run.

Returns

user_interaction_id

@property
def user_interaction_id() -> Union[str, None]

The user-supplied identifier for the current interaction, as a string.

Returns

on_chain_end

def on_chain_end(outputs: Dict[str, Any], **kwargs: Any) -> Any

Run when chain ends running.

Parameters
Returns

on_chain_start

def on_chain_start(serialized: Dict[str, Any],
                   inputs: Dict[str, Any],
                   *,
                   run_id: UUID,
                   parent_run_id: Optional[UUID] = None,
                   tags: Optional[List[str]] = None,
                   metadata: Optional[Dict[str, Any]] = None,
                   **kwargs: Any) -> None

Run when chain starts running.

Parameters
Returns

on_chat_model_start

def on_chat_model_start(serialized: Dict[str, Any],
                        messages: List[List[BaseMessage]],
                        *,
                        run_id: UUID,
                        parent_run_id: Optional[UUID] = None,
                        tags: Optional[List[str]] = None,
                        metadata: Optional[Dict[str, Any]] = None,
                        **kwargs: Any) -> Any

Run when ChatModel starts running.

Parameters
Returns

on_llm_end

def on_llm_end(response: LLMResult, **kwargs: Any) -> Any

Run when LLM ends running.

Parameters
Returns

on_llm_error

def on_llm_error(error: Union[Exception, KeyboardInterrupt], **kwargs: Any) -> Any

Run when LLM errors.

Parameters
Returns

on_llm_start

def on_llm_start(serialized: Dict[str, Any], prompts: List[str], **kwargs: Any) -> Any

Run when LLM starts running.

Parameters
Returns

on_retriever_end

def on_retriever_end(documents: Sequence[Document],
                     *,
                     run_id: UUID,
                     parent_run_id: Optional[UUID] = None,
                     **kwargs: Any) -> Any

Run when Retriever ends running.

Parameters
Returns

on_retriever_error

def on_retriever_error(error: BaseException,
                       *,
                       run_id: UUID,
                       parent_run_id: Optional[UUID] = None,
                       **kwargs: Any) -> Any

Run when Retriever errors.

Parameters
Returns

on_retriever_start

def on_retriever_start(serialized: Dict[str, Any],
                       query: str,
                       *,
                       run_id: UUID,
                       parent_run_id: Optional[UUID] = None,
                       tags: Optional[List[str]] = None,
                       metadata: Optional[Dict[str, Any]] = None,
                       **kwargs: Any) -> Any

Run when Retriever starts running.

Parameters
Returns