> ## Documentation Index
> Fetch the complete documentation index at: https://docs.galileo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# base_handler

## GalileoBaseHandler

Callback handler for logging traces to the Galileo platform.

**Arguments**

* `_galileo_logger` (`GalileoLogger`): The Galileo logger instance.

* `_nodes` (`dict[UUID, Node]`): A dictionary of nodes, where the key is the run\_id and the value is the node.

* `_start_new_trace` (`bool`): Whether to start a new trace when a chain starts. Set this to `False` to continue using the current trace.

* `_flush_on_chain_end` (`bool`): Whether to flush the trace when a chain ends.

* `_root_node` (`Optional[Node]`): The root node of the trace, if any.

* `_nodes` (`dict[str, Node]`): A dictionary of nodes, where the key is the run\_id as a string and the value is the Node object.

* `_integration` (`INTEGRATION`): The integration type, e.g., "langchain". This is used to identify the source of the trace.

### commit

```python theme={null}
def commit(self) -> None
```

Commit the nodes to the trace using the Galileo Logger. Optionally flush the trace.

### end\_node

```python theme={null}
def end_node(self, run_id: UUID, **kwargs: Any) -> None
```

End a node in the chain. Commit the nodes to a trace if the run\_id matches the root node.

**Arguments**

* `run_id` (`UUID`): The run ID.
* `**kwargs` (`Any`): Additional parameters to update the span with.

### get\_node

```python theme={null}
def get_node(self, run_id: UUID) -> Optional[Node]
```

Get a node by its run ID.

**Arguments**

* `run_id` (`UUID`): The run ID of the node to retrieve.

**Returns**

* `Optional[Node]`: The node if found, otherwise None.

### get\_nodes

```python theme={null}
def get_nodes(self) -> dict[str, Node]
```

Get all nodes.

**Returns**

* `dict[str, Node]`: A dictionary of all nodes.

### log\_node\_tree

```python theme={null}
def log_node_tree(self, node: Node) -> None
```

Log a node and its children recursively.

**Arguments**

* `node` (`Node`): The node to log.

### start\_node

```python theme={null}
def start_node(self,
               node_type: NODE_TYPE,
               parent_run_id: Optional[UUID],
               run_id: UUID,
               **kwargs: Any) -> Node
```

Start a new node in the chain.

**Arguments**

* `node_type` (`NODE_TYPE`): The type of node.
* `parent_run_id` (`Optional[UUID]`): The parent run ID.
* `run_id` (`UUID`): The run ID.
* `**kwargs` (`Any`): Additional parameters for the span.

**Returns**

* `Node`: The created node.
