Basic
Classes:
-
BasicRenderer
–A basic renderer for displaying tapes in HTML format.
BasicRenderer
A basic renderer for displaying tapes in HTML format.
This class provides functionality to render tapes and LLM calls in a structured HTML format with customizable styling and filtering options.
Attributes:
-
metadata_header
(str
) –HTML header for metadata section
-
context_header
(str
) –HTML header for context section
-
steps_header
(str
) –HTML header for steps section
-
agent_tape_header
(str
) –HTML header for agent tape section
-
user_tape_header
(str
) –HTML header for user tapes section
-
annotator_tape_header
(str
) –HTML header for annotator tapes section
Parameters:
-
filter_steps
(Optional[tuple[Type, ...]]
, default:None
) –Types of steps to include in rendering. If None, all steps are rendered.
-
render_llm_calls
(bool
, default:True
) –Whether to render LLM calls. Defaults to True.
-
render_agent_node
(bool
, default:False
) –Whether to render agent node information. Defaults to False.
Example
renderer = BasicRenderer(render_llm_calls=True)
html_output = renderer.render_tape(tape)
The renderer supports:
- Tape rendering with metadata, context, and steps
- Episode rendering with user, agent, and annotator columns
- LLM call rendering with prompts and outputs
- Custom styling through CSS
- Step filtering
- Collapsible sections using HTML details tags
Methods:
-
render_episode
–Renders an episode into HTML format.
-
render_llm_call
–Renders an LLM call into HTML format.
-
render_step
–Renders a single step in the process.
-
render_steps
–Renders a sequence of steps from a tape into an HTML string representation.
-
render_tape
–Render a tape object into HTML representation.
Source code in tapeagents/renderers/basic.py
12 13 14 15 16 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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
render_episode(episode)
Renders an episode into HTML format.
Takes an Episode object and converts it into an HTML string representation with three columns: user, agent, and annotator. The rendering includes headers, context, and sequential steps organized in rows.
Parameters:
-
episode
(Episode
) –Episode object containing the interaction sequence to be rendered
Returns:
-
str
(str
) –HTML string representation of the episode with formatted columns and rows
Source code in tapeagents/renderers/basic.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
render_llm_call(llm_call)
Renders an LLM call into HTML format.
This method generates HTML representation of an LLM call, including both the prompt and output (if available). The HTML includes expandable details sections for both the prompt and response.
Parameters:
-
llm_call
(Union[LLMCall, None]
) –An LLM call object containing prompt and output information. If None, returns an empty string.
Returns:
-
str
(str
) –HTML string representation of the LLM call. The HTML contains:
-
str
–- Prompt section with:
- Summary showing token/character count and cache status
- Expandable details with prompt messages
-
str
–- Output section (if output exists) with:
- Summary showing token count
- Expandable details with LLM response
The rendered HTML uses collapsible details elements and basic styling for readability, with a light yellow background color.
Source code in tapeagents/renderers/basic.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
|
render_step(step, index, **kwargs)
Renders a single step in the process.
Parameters:
-
step
(Step
) –The step object containing the data to be rendered
-
index
(int
) –The index of the current step
-
**kwargs
(dict
, default:{}
) –Additional keyword arguments for rendering customization
Returns:
-
str
(str
) –The rendered step as a formatted string in box format
Note
The step is first converted to a dictionary using model_dump() before rendering. The rendering is done using the render_as_box method.
Source code in tapeagents/renderers/basic.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
render_steps(tape, llm_calls={})
Renders a sequence of steps from a tape into an HTML string representation.
This method processes each step in the tape and generates HTML chunks based on various rendering options. It can show agent nodes, LLM calls, and individual steps based on configuration.
Parameters:
-
tape
(Tape
) –The tape object containing the sequence of steps to render
-
llm_calls
(dict[str, LLMCall]
, default:{}
) –Dictionary mapping prompt IDs to LLM calls. Defaults to {}.
Returns:
-
str
(str
) –A concatenated HTML string containing all rendered chunks
Notes
- If filter_steps is set, only steps matching those types will be rendered
- Agent nodes are rendered as dividers with agent/node names if render_agent_node is True
- LLM calls are rendered for each unique prompt_id if render_llm_calls is True
- Steps from UserStep and Observation are treated as "Environment" agent
Source code in tapeagents/renderers/basic.py
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 |
|
render_tape(tape, llm_calls={})
Render a tape object into HTML representation.
Parameters:
-
tape
(Tape
) –The tape object to render.
-
llm_calls
(dict[str, LLMCall]
, default:{}
) –Dictionary of LLM calls associated with the tape. Defaults to {}.
Returns:
-
str
(str
) –HTML representation of the tape including metadata, context (if present), and steps.
The rendered HTML includes:
- Metadata section with tape metadata
- Context section (if tape.context exists)
- Steps section with tape execution steps
Source code in tapeagents/renderers/basic.py
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 |
|