Llama debug
LlamaDebugHandler #
Bases: PythonicallyPrintingBaseHandler
Callback handler that keeps track of debug info.
NOTE: this is a beta feature. The usage within our codebase, and the interface may change.
This handler simply keeps track of event starts/ends, separated by event types. You can use this callback handler to keep track of and debug events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_starts_to_ignore
|
Optional[List[CBEventType]]
|
list of event types to ignore when tracking event starts. |
None
|
event_ends_to_ignore
|
Optional[List[CBEventType]]
|
list of event types to ignore when tracking event ends. |
None
|
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
on_event_start #
on_event_start(event_type: CBEventType, payload: Optional[Dict[str, Any]] = None, event_id: str = '', parent_id: str = '', **kwargs: Any) -> str
Store event start data by event type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
CBEventType
|
event type to store. |
required |
payload
|
Optional[Dict[str, Any]]
|
payload to store. |
None
|
event_id
|
str
|
event id to store. |
''
|
parent_id
|
str
|
parent event id. |
''
|
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
on_event_end #
on_event_end(event_type: CBEventType, payload: Optional[Dict[str, Any]] = None, event_id: str = '', **kwargs: Any) -> None
Store event end data by event type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
CBEventType
|
event type to store. |
required |
payload
|
Optional[Dict[str, Any]]
|
payload to store. |
None
|
event_id
|
str
|
event id to store. |
''
|
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
|
get_events #
get_events(event_type: Optional[CBEventType] = None) -> List[CBEvent]
Get all events for a specific event type.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
102 103 104 105 106 107 |
|
get_event_pairs #
get_event_pairs(event_type: Optional[CBEventType] = None) -> List[List[CBEvent]]
Pair events by ID, either all events or a specific type.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
136 137 138 139 140 141 142 143 |
|
get_llm_inputs_outputs #
get_llm_inputs_outputs() -> List[List[CBEvent]]
Get the exact LLM inputs and outputs.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
145 146 147 |
|
flush_event_logs #
flush_event_logs() -> None
Clear all events from memory.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
155 156 157 158 159 |
|
start_trace #
start_trace(trace_id: Optional[str] = None) -> None
Launch a trace.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
161 162 163 164 |
|
end_trace #
end_trace(trace_id: Optional[str] = None, trace_map: Optional[Dict[str, List[str]]] = None) -> None
Shutdown the current trace.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
166 167 168 169 170 171 172 173 174 |
|
print_trace_map #
print_trace_map() -> None
Print simple trace map to terminal for debugging of the most recent trace.
Source code in llama-index-core/llama_index/core/callbacks/llama_debug.py
190 191 192 193 194 195 |
|