| 798 | |
| 799 | @dataclass |
| 800 | class SerializedDOMState: |
| 801 | _root: SimplifiedNode | None |
| 802 | """Not meant to be used directly, use `llm_representation` instead""" |
| 803 | |
| 804 | selector_map: DOMSelectorMap |
| 805 | |
| 806 | @observe_debug(ignore_input=True, ignore_output=True, name='llm_representation') |
| 807 | def llm_representation( |
| 808 | self, |
| 809 | include_attributes: list[str] | None = None, |
| 810 | ) -> str: |
| 811 | """Kinda ugly, but leaving this as an internal method because include_attributes are a parameter on the agent, so we need to leave it as a 2 step process""" |
| 812 | from src.environment.browser.dom.serializer.serializer import DOMTreeSerializer |
| 813 | |
| 814 | if not self._root: |
| 815 | return 'Empty DOM tree (you might have to wait for the page to load)' |
| 816 | |
| 817 | include_attributes = include_attributes or DEFAULT_INCLUDE_ATTRIBUTES |
| 818 | |
| 819 | return DOMTreeSerializer.serialize_tree(self._root, include_attributes) |
| 820 | |
| 821 | |
| 822 | @dataclass |
no outgoing calls
no test coverage detected