INNER CODE UNIT · Python

__get_html_elements_for_llm

handrew/browserpilot · browserpilot/agents/gpt_selenium_agent.py:226

    def __get_html_elements_for_llm(self):
        """Returns list of BeautifulSoup elements for use in GPT Index.

        First removes blacklisted elements and attributes, then removes any
        children of elements. Finally, removes any elements with no attrs.
        """
        soup = self._remove_blacklisted_elements_and_attributes()
        # Remove children of elements that have children.
        elements = soup.find_all()
        [ele.clear() if ele.contents else ele for ele in elements if ele.contents]
        # Then remove any elements that do not have attributes, e.g., <p></p>.
        elements = [ele for ele in elements if ele.attrs]
        return elements

    def __complete(self):
        """What to run when the agent is done."""
        if self.memory_folder:
            self.memory.save(self.memory_folder)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…