Renderers
Renderers that produce HTML from the tapes used by various GUI scripts.
Modules:
-
basic
– -
camera_ready_renderer
– -
pretty
–
Functions:
-
render_agent_tree
–Renders an ASCII tree representation of an agent's hierarchical structure.
-
render_dialog_plain_text
–Renders a dialog tape into a plain text format.
-
render_tape_with_prompts
–Renders a tape with prompts using the specified renderer.
-
to_pretty_str
–Convert any Python object to a pretty formatted string representation.
render_agent_tree(agent, show_nodes=True, indent_increment=4)
Renders an ASCII tree representation of an agent's hierarchical structure.
This function creates a visual tree diagram showing the relationships between agents, their nodes, and subagents using ASCII characters. Each level is indented to show the hierarchy.
Parameters:
-
agent
(Agent
) –The root agent object to render the tree from.
-
show_nodes
(bool
, default:True
) –Whether to display the agent's nodes in the tree. Defaults to True.
-
indent_increment
(int
, default:4
) –Number of spaces to indent each level. Defaults to 4.
Returns:
-
str
(str
) –A string containing the ASCII tree representation.
Example
> The Manager
.node1
.node2
> His Assistant 1
.node1
.node2
> His Helper 2
.node1
.node2
Source code in tapeagents/renderers/__init__.py
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 |
|
render_dialog_plain_text(tape)
Renders a dialog tape into a plain text format.
Takes a DialogTape object containing conversation steps and formats them into human-readable text, with each dialog step on a new line prefixed by the speaker/action type.
Parameters:
-
tape
(Union[DialogTape, None]
) –A DialogTape object containing conversation steps, or None
Returns:
-
str
(str
) –A string containing the formatted dialog, with each step on a new line. Returns empty string if tape is None.
Source code in tapeagents/renderers/__init__.py
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 |
|
render_tape_with_prompts(tape, renderer)
Renders a tape with prompts using the specified renderer.
This function combines the tape's LLM calls with the renderer's style and rendering to produce a complete rendered output of the tape's content.
Parameters:
-
tape
(Tape
) –The tape object to be rendered
-
renderer
(BasicRenderer
) –The renderer to use for rendering the tape
Returns:
-
str
–The rendered tape content with applied styling, combining both the renderer's style and the tape's content with LLM calls
Source code in tapeagents/renderers/__init__.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
to_pretty_str(a, prefix='', indent=2)
Convert any Python object to a pretty formatted string representation.
This function recursively formats nested data structures (lists and dictionaries) with proper indentation and line breaks for improved readability.
Parameters:
-
a
(Any
) –The object to be formatted. Can be a list, dictionary, or any other type.
-
prefix
(str
, default:''
) –String to prepend to each line. Used for recursive indentation. Defaults to "".
-
indent
(int
, default:2
) –Number of spaces to use for each level of indentation. Defaults to 2.
Returns:
-
str
(str
) –A formatted string representation of the input object.
Example
data = {"foo": [1, 2, {"bar": "baz"}]}
print(to_pretty_str(data))
foo: - 1 - 2 - bar: baz
Source code in tapeagents/renderers/__init__.py
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 |
|