From ba3e8088027e67ee8956ff0c54f4ffcc0438ae87 Mon Sep 17 00:00:00 2001 From: lu4nx Date: Mon, 9 Dec 2024 17:19:26 +0800 Subject: [PATCH] fix: The extract method logs output only when self.verbose is set to True. (#314) Co-authored-by: lu4nx --- crawl4ai/extraction_strategy.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crawl4ai/extraction_strategy.py b/crawl4ai/extraction_strategy.py index b79e0c43..b7eabf74 100644 --- a/crawl4ai/extraction_strategy.py +++ b/crawl4ai/extraction_strategy.py @@ -92,8 +92,10 @@ class LLMExtractionStrategy(ExtractionStrategy): def extract(self, url: str, ix:int, html: str) -> List[Dict[str, Any]]: - # print("[LOG] Extracting blocks from URL:", url) - print(f"[LOG] Call LLM for {url} - block index: {ix}") + if self.verbose: + # print("[LOG] Extracting blocks from URL:", url) + print(f"[LOG] Call LLM for {url} - block index: {ix}") + variable_values = { "URL": url, "HTML": escape_json_string(sanitize_html(html)), @@ -868,4 +870,4 @@ class JsonXPATHExtractionStrategy(ExtractionStrategy): def run(self, url: str, sections: List[str], *q, **kwargs) -> List[Dict[str, Any]]: combined_html = self.DEL.join(sections) - return self.extract(url, combined_html, **kwargs) \ No newline at end of file + return self.extract(url, combined_html, **kwargs)