# ClearMLCallbackHandler

> **Class** in `langchain_community`

📖 [View in docs](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler)

Callback Handler that logs to ClearML.

## Signature

```python
ClearMLCallbackHandler(
    self,
    task_type: Optional[str] = 'inference',
    project_name: Optional[str] = 'langchain_callback_demo',
    tags: Optional[Sequence] = None,
    task_name: Optional[str] = None,
    visualize: bool = False,
    complexity_metrics: bool = False,
    stream_logs: bool = False,
)
```

## Description

This handler will utilize the associated callback method and formats
the input of each callback function with metadata regarding the state of LLM run,
and adds the response to the list of records for both the {method}_records and
action. It then logs the response to the ClearML console.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `job_type` | `str` | Yes | The type of clearml task such as "inference", "testing" or "qc" |
| `project_name` | `str` | No | The clearml project name (default: `'langchain_callback_demo'`) |
| `tags` | `list` | No | Tags to add to the task (default: `None`) |
| `task_name` | `str` | No | Name of the clearml task (default: `None`) |
| `visualize` | `bool` | No | Whether to visualize the run. (default: `False`) |
| `complexity_metrics` | `bool` | No | Whether to log complexity metrics (default: `False`) |
| `stream_logs` | `bool` | No | Whether to stream callback actions to ClearML (default: `False`) |

## Extends

- `BaseMetadataCallbackHandler`
- `BaseCallbackHandler`

## Constructors

```python
__init__(
    self,
    task_type: Optional[str] = 'inference',
    project_name: Optional[str] = 'langchain_callback_demo',
    tags: Optional[Sequence] = None,
    task_name: Optional[str] = None,
    visualize: bool = False,
    complexity_metrics: bool = False,
    stream_logs: bool = False,
) -> None
```

| Name | Type |
|------|------|
| `task_type` | `Optional[str]` |
| `project_name` | `Optional[str]` |
| `tags` | `Optional[Sequence]` |
| `task_name` | `Optional[str]` |
| `visualize` | `bool` |
| `complexity_metrics` | `bool` |
| `stream_logs` | `bool` |


## Properties

- `task_type`
- `project_name`
- `tags`
- `task_name`
- `visualize`
- `complexity_metrics`
- `stream_logs`
- `temp_dir`
- `task`
- `logger`
- `callback_columns`
- `action_records`
- `nlp`

## Methods

- [`on_llm_start()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_llm_start)
- [`on_llm_new_token()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_llm_new_token)
- [`on_llm_end()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_llm_end)
- [`on_llm_error()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_llm_error)
- [`on_chain_start()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_chain_start)
- [`on_chain_end()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_chain_end)
- [`on_chain_error()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_chain_error)
- [`on_tool_start()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_tool_start)
- [`on_tool_end()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_tool_end)
- [`on_tool_error()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_tool_error)
- [`on_text()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_text)
- [`on_agent_finish()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_agent_finish)
- [`on_agent_action()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/on_agent_action)
- [`analyze_text()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/analyze_text)
- [`flush_tracker()`](https://reference.langchain.com/python/langchain-community/callbacks/clearml_callback/ClearMLCallbackHandler/flush_tracker)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-community/blob/d5ea8358933260ad48dd31f7f8076555c7b4885a/libs/community/langchain_community/callbacks/clearml_callback.py#L32)