# WandbCallbackHandler

> **Class** in `langchain_community`

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

Callback Handler that logs to Weights and Biases.

## Signature

```python
WandbCallbackHandler(
    self,
    job_type: Optional[str] = None,
    project: Optional[str] = 'langchain_callback_demo',
    entity: Optional[str] = None,
    tags: Optional[Sequence] = None,
    group: Optional[str] = None,
    name: Optional[str] = None,
    notes: Optional[str] = None,
    visualize: bool = False,
    complexity_metrics: bool = False,
    stream_logs: bool = False,
)
```

## Description

This handler will utilize the associated callback method called 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 using the run.log() method to Weights and Biases.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `job_type` | `str` | No | The type of job. (default: `None`) |
| `project` | `str` | No | The project to log to. (default: `'langchain_callback_demo'`) |
| `entity` | `str` | No | The entity to log to. (default: `None`) |
| `tags` | `list` | No | The tags to log. (default: `None`) |
| `group` | `str` | No | The group to log to. (default: `None`) |
| `name` | `str` | No | The name of the run. (default: `None`) |
| `notes` | `str` | No | The notes to log. (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 W&B (default: `False`) |

## Extends

- `BaseMetadataCallbackHandler`
- `BaseCallbackHandler`

## Constructors

```python
__init__(
    self,
    job_type: Optional[str] = None,
    project: Optional[str] = 'langchain_callback_demo',
    entity: Optional[str] = None,
    tags: Optional[Sequence] = None,
    group: Optional[str] = None,
    name: Optional[str] = None,
    notes: Optional[str] = None,
    visualize: bool = False,
    complexity_metrics: bool = False,
    stream_logs: bool = False,
) -> None
```

| Name | Type |
|------|------|
| `job_type` | `Optional[str]` |
| `project` | `Optional[str]` |
| `entity` | `Optional[str]` |
| `tags` | `Optional[Sequence]` |
| `group` | `Optional[str]` |
| `name` | `Optional[str]` |
| `notes` | `Optional[str]` |
| `visualize` | `bool` |
| `complexity_metrics` | `bool` |
| `stream_logs` | `bool` |


## Properties

- `job_type`
- `project`
- `entity`
- `tags`
- `group`
- `name`
- `notes`
- `visualize`
- `complexity_metrics`
- `stream_logs`
- `temp_dir`
- `run`
- `callback_columns`
- `action_records`
- `nlp`

## Methods

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

---

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