Skip to content

Python scraper based on AI

refactoring of examples

Marco Vinciguerraa200f595de19
diff --git a/examples/anthropic/code_generator_graph_anthropic.py b/examples/anthropic/code_generator_graph_anthropic.py
index c1a41ea3..71160b8c 100644
--- a/examples/anthropic/code_generator_graph_anthropic.py
+++ b/examples/anthropic/code_generator_graph_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
import os, json
from typing import List
from dotenv import load_dotenv
diff --git a/examples/anthropic/csv_scraper_anthropic.py b/examples/anthropic/csv_scraper_anthropic.py
index 745926a3..ca4496a7 100644
--- a/examples/anthropic/csv_scraper_anthropic.py
+++ b/examples/anthropic/csv_scraper_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/anthropic/csv_scraper_graph_multi_anthropic.py b/examples/anthropic/csv_scraper_graph_multi_anthropic.py
index d574da5c..7697a169 100644
--- a/examples/anthropic/csv_scraper_graph_multi_anthropic.py
+++ b/examples/anthropic/csv_scraper_graph_multi_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/anthropic/custom_graph_anthropic.py b/examples/anthropic/custom_graph_anthropic.py
index 96115d2e..6df51108 100644
--- a/examples/anthropic/custom_graph_anthropic.py
+++ b/examples/anthropic/custom_graph_anthropic.py
@@ -1,10 +1,8 @@
"""
Example of custom graph using existing nodes
"""
-
import os
from dotenv import load_dotenv
-
from langchain_anthropic import ChatAnthropic
from scrapegraphai.graphs import BaseGraph
from scrapegraphai.nodes import FetchNode, ParseNode, GenerateAnswerNode, RobotsNode
diff --git a/examples/anthropic/json_scraper_anthropic.py b/examples/anthropic/json_scraper_anthropic.py
index 9d5fc8db..456643d2 100644
--- a/examples/anthropic/json_scraper_anthropic.py
+++ b/examples/anthropic/json_scraper_anthropic.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/anthropic/rate_limit_anthropic.py b/examples/anthropic/rate_limit_anthropic.py
index a01bff44..f9321770 100644
--- a/examples/anthropic/rate_limit_anthropic.py
+++ b/examples/anthropic/rate_limit_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper while setting an API rate limit.
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/anthropic/scrape_plain_text_anthropic.py b/examples/anthropic/scrape_plain_text_anthropic.py
index d3099026..fd8ebd1d 100644
--- a/examples/anthropic/scrape_plain_text_anthropic.py
+++ b/examples/anthropic/scrape_plain_text_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/anthropic/script_generator_anthropic.py b/examples/anthropic/script_generator_anthropic.py
index bdd0c23b..8c9333e1 100644
--- a/examples/anthropic/script_generator_anthropic.py
+++ b/examples/anthropic/script_generator_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/anthropic/script_multi_generator_anthropic.py b/examples/anthropic/script_multi_generator_anthropic.py
index bacf0bfc..d47e60e9 100644
--- a/examples/anthropic/script_multi_generator_anthropic.py
+++ b/examples/anthropic/script_multi_generator_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/anthropic/search_graph_anthropic.py b/examples/anthropic/search_graph_anthropic.py
index 97a5213d..0e1d7b45 100644
--- a/examples/anthropic/search_graph_anthropic.py
+++ b/examples/anthropic/search_graph_anthropic.py
@@ -1,11 +1,11 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/anthropic/search_graph_schema_anthropic.py b/examples/anthropic/search_graph_schema_anthropic.py
index 1158d58a..926e72ea 100644
--- a/examples/anthropic/search_graph_schema_anthropic.py
+++ b/examples/anthropic/search_graph_schema_anthropic.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from typing import List
from dotenv import load_dotenv
diff --git a/examples/anthropic/smart_scraper_anthropic.py b/examples/anthropic/smart_scraper_anthropic.py
index 51ca1bf5..7eb655d5 100644
--- a/examples/anthropic/smart_scraper_anthropic.py
+++ b/examples/anthropic/smart_scraper_anthropic.py
@@ -1,15 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper using Azure OpenAI Key
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
-
-# required environment variables in .env
-# ANTHROPIC_API_KEY
load_dotenv()
# ************************************************
diff --git a/examples/anthropic/smart_scraper_multi_anthropic.py b/examples/anthropic/smart_scraper_multi_anthropic.py
index f96de0ab..e4dc0aca 100644
--- a/examples/anthropic/smart_scraper_multi_anthropic.py
+++ b/examples/anthropic/smart_scraper_multi_anthropic.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
diff --git a/examples/anthropic/smart_scraper_multi_concat_anthropic.py b/examples/anthropic/smart_scraper_multi_concat_anthropic.py
index 5faa60c8..d5c65a14 100644
--- a/examples/anthropic/smart_scraper_multi_concat_anthropic.py
+++ b/examples/anthropic/smart_scraper_multi_concat_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/anthropic/smart_scraper_schema_anthropic.py b/examples/anthropic/smart_scraper_schema_anthropic.py
index bd447a06..3cebd257 100644
--- a/examples/anthropic/smart_scraper_schema_anthropic.py
+++ b/examples/anthropic/smart_scraper_schema_anthropic.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper using Azure OpenAI Key
"""
-
import os
from typing import List
from pydantic import BaseModel, Field
@@ -9,10 +8,6 @@ from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
-
-# required environment variables in .env
-# HUGGINGFACEHUB_API_TOKEN
-# ANTHROPIC_API_KEY
load_dotenv()
# ************************************************
diff --git a/examples/anthropic/xml_scraper_anthropic.py b/examples/anthropic/xml_scraper_anthropic.py
index 2dc4b8d2..5568f0a3 100644
--- a/examples/anthropic/xml_scraper_anthropic.py
+++ b/examples/anthropic/xml_scraper_anthropic.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/anthropic/xml_scraper_graph_multi_anthropic.py b/examples/anthropic/xml_scraper_graph_multi_anthropic.py
index 6e9bc5f8..577e2e1d 100644
--- a/examples/anthropic/xml_scraper_graph_multi_anthropic.py
+++ b/examples/anthropic/xml_scraper_graph_multi_anthropic.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/azure/code_generator_graph_azure.py b/examples/azure/code_generator_graph_azure.py
index 4bad1b0d..7dc13602 100644
--- a/examples/azure/code_generator_graph_azure.py
+++ b/examples/azure/code_generator_graph_azure.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -55,4 +54,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/azure/csv_scraper_azure.py b/examples/azure/csv_scraper_azure.py
index 272527b3..5bc9ca50 100644
--- a/examples/azure/csv_scraper_azure.py
+++ b/examples/azure/csv_scraper_azure.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/azure/csv_scraper_graph_multi_azure.py b/examples/azure/csv_scraper_graph_multi_azure.py
index cccbf88e..0c599427 100644
--- a/examples/azure/csv_scraper_graph_multi_azure.py
+++ b/examples/azure/csv_scraper_graph_multi_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/azure/json_scraper_azure.py b/examples/azure/json_scraper_azure.py
index 5ba54f7b..5224f9bb 100644
--- a/examples/azure/json_scraper_azure.py
+++ b/examples/azure/json_scraper_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper using Azure OpenAI Key
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
diff --git a/examples/azure/json_scraper_multi_azure.py b/examples/azure/json_scraper_multi_azure.py
index befc4e84..93ac02e3 100644
--- a/examples/azure/json_scraper_multi_azure.py
+++ b/examples/azure/json_scraper_multi_azure.py
@@ -2,8 +2,8 @@
Module for showing how JSONScraperMultiGraph multi works
"""
import os
-from dotenv import load_dotenv
import json
+from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperMultiGraph
load_dotenv()
diff --git a/examples/azure/pdf_scraper_azure.py b/examples/azure/pdf_scraper_azure.py
index 02b3b7e6..3a4e7e58 100644
--- a/examples/azure/pdf_scraper_azure.py
+++ b/examples/azure/pdf_scraper_azure.py
@@ -1,4 +1,5 @@
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
diff --git a/examples/azure/rate_limit_azure.py b/examples/azure/rate_limit_azure.py
index 892996c7..aa0f943d 100644
--- a/examples/azure/rate_limit_azure.py
+++ b/examples/azure/rate_limit_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/azure/scrape_plain_text_azure.py b/examples/azure/scrape_plain_text_azure.py
index 9ea18d07..0beb1526 100644
--- a/examples/azure/scrape_plain_text_azure.py
+++ b/examples/azure/scrape_plain_text_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/azure/script_generator_azure.py b/examples/azure/script_generator_azure.py
index b2bbb220..5eb40b1c 100644
--- a/examples/azure/script_generator_azure.py
+++ b/examples/azure/script_generator_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/azure/script_multi_generator_azure.py b/examples/azure/script_multi_generator_azure.py
index 8c52cb95..6bb94051 100644
--- a/examples/azure/script_multi_generator_azure.py
+++ b/examples/azure/script_multi_generator_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/azure/search_graph_azure.py b/examples/azure/search_graph_azure.py
index 949f134c..8c7d9a9e 100644
--- a/examples/azure/search_graph_azure.py
+++ b/examples/azure/search_graph_azure.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
diff --git a/examples/azure/search_graph_schema_azure.py b/examples/azure/search_graph_schema_azure.py
index e8c10093..bc22f7bc 100644
--- a/examples/azure/search_graph_schema_azure.py
+++ b/examples/azure/search_graph_schema_azure.py
@@ -1,16 +1,15 @@
"""
Example of Search Graph
"""
-
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
from pydantic import BaseModel, Field
-from typing import List
+
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/azure/smart_scraper_azure.py b/examples/azure/smart_scraper_azure.py
index 933dc5b0..11643a6d 100644
--- a/examples/azure/smart_scraper_azure.py
+++ b/examples/azure/smart_scraper_azure.py
@@ -1,24 +1,13 @@
"""
Basic example of scraping pipeline using SmartScraper using Azure OpenAI Key
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
-
-# required environment variable in .env
-# AZURE_OPENAI_ENDPOINT
-# AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
-# MODEL_NAME
-# AZURE_OPENAI_API_KEY
-# OPENAI_API_TYPE
-# AZURE_OPENAI_API_VERSION
-# AZURE_OPENAI_EMBEDDINGS_DEPLOYMENT_NAME
load_dotenv()
-
# ************************************************
# Initialize the model instances
# ************************************************
@@ -33,7 +22,8 @@ graph_config = {
}
smart_scraper_graph = SmartScraperGraph(
- prompt="""List me all the events, with the following fields: company_name, event_name, event_start_date, event_start_time,
+ prompt="""List me all the events, with the following fields:
+ company_name, event_name, event_start_date, event_start_time,
event_end_date, event_end_time, location, event_mode, event_category,
third_party_redirect, no_of_days,
time_in_hours, hosted_or_attending, refreshments_type,
diff --git a/examples/azure/smart_scraper_multi_concat_azure.py b/examples/azure/smart_scraper_multi_concat_azure.py
index 06d08b9a..072cb190 100644
--- a/examples/azure/smart_scraper_multi_concat_azure.py
+++ b/examples/azure/smart_scraper_multi_concat_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/azure/smart_scraper_schema_azure.py b/examples/azure/smart_scraper_schema_azure.py
index d2766ecb..28d8b87e 100644
--- a/examples/azure/smart_scraper_schema_azure.py
+++ b/examples/azure/smart_scraper_schema_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
import os
import json
from typing import List
diff --git a/examples/azure/xml_scraper_azure.py b/examples/azure/xml_scraper_azure.py
index 1c40f3e7..cd53242c 100644
--- a/examples/azure/xml_scraper_azure.py
+++ b/examples/azure/xml_scraper_azure.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper using Azure OpenAI Key
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
diff --git a/examples/azure/xml_scraper_graph_multi_azure.py b/examples/azure/xml_scraper_graph_multi_azure.py
index 972eb823..e7aaf382 100644
--- a/examples/azure/xml_scraper_graph_multi_azure.py
+++ b/examples/azure/xml_scraper_graph_multi_azure.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/bedrock/depth_search_graph_bedrock.py b/examples/bedrock/depth_search_graph_bedrock.py
index 2ab88291..243547a4 100644
--- a/examples/bedrock/depth_search_graph_bedrock.py
+++ b/examples/bedrock/depth_search_graph_bedrock.py
@@ -1,14 +1,8 @@
"""
depth_search_graph_opeani example
"""
-import os
-from dotenv import load_dotenv
from scrapegraphai.graphs import DepthSearchGraph
-load_dotenv()
-
-openai_key = os.getenv("OPENAI_APIKEY")
-
graph_config = {
"llm": {
"client": "client_name",
diff --git a/examples/bedrock/json_scraper_bedrock.py b/examples/bedrock/json_scraper_bedrock.py
index dc1bf769..c34cb1bd 100644
--- a/examples/bedrock/json_scraper_bedrock.py
+++ b/examples/bedrock/json_scraper_bedrock.py
@@ -1,12 +1,9 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
import json
-
from dotenv import load_dotenv
-
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
@@ -58,4 +55,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/bedrock/pdf_scraper_graph_bedrock.py b/examples/bedrock/pdf_scraper_graph_bedrock.py
index dcef848e..ba51d351 100644
--- a/examples/bedrock/pdf_scraper_graph_bedrock.py
+++ b/examples/bedrock/pdf_scraper_graph_bedrock.py
@@ -1,13 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import json
from dotenv import load_dotenv
-from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import PDFScraperGraph
-load_dotenv()
+load_dotenv()
# ************************************************
# Define the configuration for the graph
diff --git a/examples/bedrock/pdf_scraper_graph_multi_bedrock.py b/examples/bedrock/pdf_scraper_graph_multi_bedrock.py
index 37e61c42..45a71b74 100644
--- a/examples/bedrock/pdf_scraper_graph_multi_bedrock.py
+++ b/examples/bedrock/pdf_scraper_graph_multi_bedrock.py
@@ -1,9 +1,7 @@
"""
Module for showing how PDFScraper multi works
"""
-import os
import json
-from dotenv import load_dotenv
from scrapegraphai.graphs import PdfScraperMultiGraph
graph_config = {
diff --git a/examples/bedrock/rate_limit_bedrock.py b/examples/bedrock/rate_limit_bedrock.py
index 79a76a3e..98e2e3db 100644
--- a/examples/bedrock/rate_limit_bedrock.py
+++ b/examples/bedrock/rate_limit_bedrock.py
@@ -1,15 +1,12 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
-import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/bedrock/scrape_plain_text_bedrock.py b/examples/bedrock/scrape_plain_text_bedrock.py
index 0214a1e3..1a89786e 100644
--- a/examples/bedrock/scrape_plain_text_bedrock.py
+++ b/examples/bedrock/scrape_plain_text_bedrock.py
@@ -1,12 +1,9 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
import json
-
from dotenv import load_dotenv
-
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/bedrock/script_generator_bedrock.py b/examples/bedrock/script_generator_bedrock.py
index 26863193..4adb13f1 100644
--- a/examples/bedrock/script_generator_bedrock.py
+++ b/examples/bedrock/script_generator_bedrock.py
@@ -1,9 +1,7 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
from dotenv import load_dotenv
-
from scrapegraphai.graphs import ScriptCreatorGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/bedrock/script_multi_generator_bedrock.py b/examples/bedrock/script_multi_generator_bedrock.py
index ecef966d..2491a1f9 100644
--- a/examples/bedrock/script_multi_generator_bedrock.py
+++ b/examples/bedrock/script_multi_generator_bedrock.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
from scrapegraphai.graphs import ScriptCreatorMultiGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/bedrock/search_graph_bedrock.py b/examples/bedrock/search_graph_bedrock.py
index b27f6e5d..6369f647 100644
--- a/examples/bedrock/search_graph_bedrock.py
+++ b/examples/bedrock/search_graph_bedrock.py
@@ -1,12 +1,8 @@
"""
Example of Search Graph
"""
-
-from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
-load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/bedrock/search_graph_schema_bedrock.py b/examples/bedrock/search_graph_schema_bedrock.py
index a49ba730..55ad772c 100644
--- a/examples/bedrock/search_graph_schema_bedrock.py
+++ b/examples/bedrock/search_graph_schema_bedrock.py
@@ -1,12 +1,11 @@
"""
Example of Search Graph
"""
+from typing import List
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
-
# ************************************************
# Define the output schema for the graph
# ************************************************
diff --git a/examples/bedrock/search_link_graph_bedrock.py b/examples/bedrock/search_link_graph_bedrock.py
index fc1e6233..64e62710 100644
--- a/examples/bedrock/search_link_graph_bedrock.py
+++ b/examples/bedrock/search_link_graph_bedrock.py
@@ -1,8 +1,6 @@
"""
Example of Search Graph
"""
-import os
-from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
diff --git a/examples/bedrock/smart_scraper_bedrock.py b/examples/bedrock/smart_scraper_bedrock.py
index 9c747c00..d63f1ece 100644
--- a/examples/bedrock/smart_scraper_bedrock.py
+++ b/examples/bedrock/smart_scraper_bedrock.py
@@ -1,8 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/bedrock/smart_scraper_multi_bedrock.py b/examples/bedrock/smart_scraper_multi_bedrock.py
index bbff3d12..9de097b0 100644
--- a/examples/bedrock/smart_scraper_multi_bedrock.py
+++ b/examples/bedrock/smart_scraper_multi_bedrock.py
@@ -4,7 +4,6 @@ Basic example of scraping pipeline using SmartScraper
import json
from scrapegraphai.graphs import SmartScraperMultiGraph
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/bedrock/xml_scraper_bedrock.py b/examples/bedrock/xml_scraper_bedrock.py
index 5f81fbf6..2110fc9f 100644
--- a/examples/bedrock/xml_scraper_bedrock.py
+++ b/examples/bedrock/xml_scraper_bedrock.py
@@ -4,7 +4,6 @@ Basic example of scraping pipeline using XMLScraperGraph from XML documents
import os
import json
-
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
diff --git a/examples/bedrock/xml_scraper_graph_multi_bedrock.py b/examples/bedrock/xml_scraper_graph_multi_bedrock.py
index 638ce280..ab7bd4ad 100644
--- a/examples/bedrock/xml_scraper_graph_multi_bedrock.py
+++ b/examples/bedrock/xml_scraper_graph_multi_bedrock.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/deepseek/code_generator_graph_deepseek.py b/examples/deepseek/code_generator_graph_deepseek.py
index cc4670b7..f78a42b6 100644
--- a/examples/deepseek/code_generator_graph_deepseek.py
+++ b/examples/deepseek/code_generator_graph_deepseek.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -57,4 +56,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/deepseek/csv_scraper_deepseek.py b/examples/deepseek/csv_scraper_deepseek.py
index 26ff26ee..6ef0ac92 100644
--- a/examples/deepseek/csv_scraper_deepseek.py
+++ b/examples/deepseek/csv_scraper_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/deepseek/csv_scraper_graph_multi_deepseek.py b/examples/deepseek/csv_scraper_graph_multi_deepseek.py
index 88056648..95474360 100644
--- a/examples/deepseek/csv_scraper_graph_multi_deepseek.py
+++ b/examples/deepseek/csv_scraper_graph_multi_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/deepseek/json_scraper_deepseek.py b/examples/deepseek/json_scraper_deepseek.py
index 5d8bf152..9fc2f5c9 100644
--- a/examples/deepseek/json_scraper_deepseek.py
+++ b/examples/deepseek/json_scraper_deepseek.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/deepseek/pdf_scraper_graph_deepseek.py b/examples/deepseek/pdf_scraper_graph_deepseek.py
index 990e7369..5d313c2a 100644
--- a/examples/deepseek/pdf_scraper_graph_deepseek.py
+++ b/examples/deepseek/pdf_scraper_graph_deepseek.py
@@ -1,13 +1,13 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import PDFScraperGraph
-load_dotenv()
+load_dotenv()
# ************************************************
# Define the configuration for the graph
diff --git a/examples/deepseek/rate_limit_deepseek.py b/examples/deepseek/rate_limit_deepseek.py
index 36278452..16781f39 100644
--- a/examples/deepseek/rate_limit_deepseek.py
+++ b/examples/deepseek/rate_limit_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
@@ -9,7 +8,6 @@ from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/deepseek/scrape_plain_text_deepseek.py b/examples/deepseek/scrape_plain_text_deepseek.py
index 52128737..2b243d35 100644
--- a/examples/deepseek/scrape_plain_text_deepseek.py
+++ b/examples/deepseek/scrape_plain_text_deepseek.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/deepseek/script_generator_deepseek.py b/examples/deepseek/script_generator_deepseek.py
index eaec5232..899c7a35 100644
--- a/examples/deepseek/script_generator_deepseek.py
+++ b/examples/deepseek/script_generator_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/deepseek/script_multi_generator_deepseek.py b/examples/deepseek/script_multi_generator_deepseek.py
index 150298ed..48ca2d20 100644
--- a/examples/deepseek/script_multi_generator_deepseek.py
+++ b/examples/deepseek/script_multi_generator_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/deepseek/search_graph_deepseek.py b/examples/deepseek/search_graph_deepseek.py
index e7c2483c..7a3baf0d 100644
--- a/examples/deepseek/search_graph_deepseek.py
+++ b/examples/deepseek/search_graph_deepseek.py
@@ -1,10 +1,10 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
+
load_dotenv()
# ************************************************
diff --git a/examples/deepseek/search_graph_schema_deepseek.py b/examples/deepseek/search_graph_schema_deepseek.py
index 1471ede1..f5f20e25 100644
--- a/examples/deepseek/search_graph_schema_deepseek.py
+++ b/examples/deepseek/search_graph_schema_deepseek.py
@@ -1,16 +1,14 @@
"""
Example of Search Graph
"""
-
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/deepseek/smart_scraper_deepseek.py b/examples/deepseek/smart_scraper_deepseek.py
index c94a5a80..0eac94e8 100644
--- a/examples/deepseek/smart_scraper_deepseek.py
+++ b/examples/deepseek/smart_scraper_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/deepseek/smart_scraper_multi_concat_deepseek.py b/examples/deepseek/smart_scraper_multi_concat_deepseek.py
index bf6c0c53..eeb1816c 100644
--- a/examples/deepseek/smart_scraper_multi_concat_deepseek.py
+++ b/examples/deepseek/smart_scraper_multi_concat_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/deepseek/smart_scraper_multi_deepseek.py b/examples/deepseek/smart_scraper_multi_deepseek.py
index 2ef062de..5923e302 100644
--- a/examples/deepseek/smart_scraper_multi_deepseek.py
+++ b/examples/deepseek/smart_scraper_multi_deepseek.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
diff --git a/examples/deepseek/smart_scraper_schema_deepseek.py b/examples/deepseek/smart_scraper_schema_deepseek.py
index 722e02bf..fd87fbdc 100644
--- a/examples/deepseek/smart_scraper_schema_deepseek.py
+++ b/examples/deepseek/smart_scraper_schema_deepseek.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from typing import List
from pydantic import BaseModel, Field
diff --git a/examples/deepseek/xml_scraper_deepseek.py b/examples/deepseek/xml_scraper_deepseek.py
index 02178c4b..d66b0eab 100644
--- a/examples/deepseek/xml_scraper_deepseek.py
+++ b/examples/deepseek/xml_scraper_deepseek.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -34,7 +34,6 @@ graph_config = {
"verbose": True,
}
-
# ************************************************
# Create the XMLScraperGraph instance and run it
# ************************************************
diff --git a/examples/deepseek/xml_scraper_graph_multi_deepseek.py b/examples/deepseek/xml_scraper_graph_multi_deepseek.py
index ae74ba21..2d190926 100644
--- a/examples/deepseek/xml_scraper_graph_multi_deepseek.py
+++ b/examples/deepseek/xml_scraper_graph_multi_deepseek.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/ernie/code_generator_graph_ernie.py b/examples/ernie/code_generator_graph_ernie.py
index 65b25b54..65b8e4b9 100644
--- a/examples/ernie/code_generator_graph_ernie.py
+++ b/examples/ernie/code_generator_graph_ernie.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/ernie/csv_scraper_ernie.py b/examples/ernie/csv_scraper_ernie.py
index 410e300e..6f4335b6 100644
--- a/examples/ernie/csv_scraper_ernie.py
+++ b/examples/ernie/csv_scraper_ernie.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -23,7 +23,7 @@ text = pd.read_csv(file_path)
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
diff --git a/examples/ernie/custom_graph_ernie.py b/examples/ernie/custom_graph_ernie.py
index a3082cf7..a987560e 100644
--- a/examples/ernie/custom_graph_ernie.py
+++ b/examples/ernie/custom_graph_ernie.py
@@ -1,10 +1,6 @@
"""
Example of custom graph using existing nodes
"""
-
-import os
-from dotenv import load_dotenv
-
from langchain_openai import OpenAIEmbeddings
from langchain_openai import ChatOpenAI
from scrapegraphai.graphs import BaseGraph
diff --git a/examples/ernie/json_scraper_ernie.py b/examples/ernie/json_scraper_ernie.py
index e73ebc10..4010bfde 100644
--- a/examples/ernie/json_scraper_ernie.py
+++ b/examples/ernie/json_scraper_ernie.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
@@ -21,7 +20,7 @@ with open(file_path, 'r', encoding="utf-8") as file:
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
@@ -53,4 +52,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/ernie/pdf_scraper_graph_ernie.py b/examples/ernie/pdf_scraper_graph_ernie.py
index 6016da7a..3bcf46ee 100644
--- a/examples/ernie/pdf_scraper_graph_ernie.py
+++ b/examples/ernie/pdf_scraper_graph_ernie.py
@@ -1,11 +1,14 @@
-import os, json
+"""
+pds scraper module
+"""
+import json
from scrapegraphai.graphs import PDFScraperGraph
# ************************************************
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
diff --git a/examples/ernie/rate_limit_ernie.py b/examples/ernie/rate_limit_ernie.py
index 41314e87..043029a7 100644
--- a/examples/ernie/rate_limit_ernie.py
+++ b/examples/ernie/rate_limit_ernie.py
@@ -1,8 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
-import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
@@ -14,7 +12,7 @@ load_dotenv()
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
diff --git a/examples/ernie/scrape_plain_text_ernie.py b/examples/ernie/scrape_plain_text_ernie.py
index c6bb715a..dde49537 100644
--- a/examples/ernie/scrape_plain_text_ernie.py
+++ b/examples/ernie/scrape_plain_text_ernie.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/ernie/script_generator_ernie.py b/examples/ernie/script_generator_ernie.py
index 42e136ff..f518739c 100644
--- a/examples/ernie/script_generator_ernie.py
+++ b/examples/ernie/script_generator_ernie.py
@@ -1,8 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
-import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
from scrapegraphai.utils import prettify_exec_info
@@ -43,4 +41,3 @@ print(result)
graph_exec_info = script_creator_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
diff --git a/examples/ernie/script_multi_generator_ernie.py b/examples/ernie/script_multi_generator_ernie.py
index 285d491a..4b3c88f7 100644
--- a/examples/ernie/script_multi_generator_ernie.py
+++ b/examples/ernie/script_multi_generator_ernie.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
from scrapegraphai.graphs import ScriptCreatorMultiGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/ernie/search_graph_ernie.py b/examples/ernie/search_graph_ernie.py
index 0e811683..ff9b3d8b 100644
--- a/examples/ernie/search_graph_ernie.py
+++ b/examples/ernie/search_graph_ernie.py
@@ -1,8 +1,6 @@
"""
Example of Search Graph
"""
-
-import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
@@ -12,7 +10,7 @@ load_dotenv()
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
diff --git a/examples/ernie/search_link_graph_ernie.py b/examples/ernie/search_link_graph_ernie.py
index f38b2772..645dd505 100644
--- a/examples/ernie/search_link_graph_ernie.py
+++ b/examples/ernie/search_link_graph_ernie.py
@@ -8,7 +8,7 @@ from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_i
# Define the configuration for the graph
# ************************************************
-graph_config = {
+graph_config = {
"llm": {
"model": "ernie/ernie-bot-turbo",
"ernie_client_id": "<ernie_client_id>",
diff --git a/examples/ernie/smart_scraper_ernie.py b/examples/ernie/smart_scraper_ernie.py
index 9fcc7820..4bbe608a 100644
--- a/examples/ernie/smart_scraper_ernie.py
+++ b/examples/ernie/smart_scraper_ernie.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/ernie/smart_scraper_multi_ernie.py b/examples/ernie/smart_scraper_multi_ernie.py
index 6b62b685..4e44ab6a 100644
--- a/examples/ernie/smart_scraper_multi_ernie.py
+++ b/examples/ernie/smart_scraper_multi_ernie.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
diff --git a/examples/ernie/smart_scraper_schema_ernie.py b/examples/ernie/smart_scraper_schema_ernie.py
index b0fe3d7e..e9d9ab0a 100644
--- a/examples/ernie/smart_scraper_schema_ernie.py
+++ b/examples/ernie/smart_scraper_schema_ernie.py
@@ -1,24 +1,18 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
import json
import os
from typing import Dict
-
from dotenv import load_dotenv
from pydantic import BaseModel
-
from scrapegraphai.graphs import SmartScraperGraph
-
load_dotenv()
# ************************************************
# Define the output schema for the graph
# ************************************************
-
-
class Project(BaseModel):
title: str
description: str
diff --git a/examples/ernie/speech_graph_ernie.py b/examples/ernie/speech_graph_ernie.py
index cece3149..0b4ed620 100644
--- a/examples/ernie/speech_graph_ernie.py
+++ b/examples/ernie/speech_graph_ernie.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SpeechSummaryGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SpeechGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/ernie/xml_scraper_ernie.py b/examples/ernie/xml_scraper_ernie.py
index a5bf03e0..90a1230a 100644
--- a/examples/ernie/xml_scraper_ernie.py
+++ b/examples/ernie/xml_scraper_ernie.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/fireworks/code_generator_graph_fireworks.py b/examples/fireworks/code_generator_graph_fireworks.py
index aa606b1e..e38c48a1 100644
--- a/examples/fireworks/code_generator_graph_fireworks.py
+++ b/examples/fireworks/code_generator_graph_fireworks.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
+import json
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/fireworks/csv_scraper_fireworks.py b/examples/fireworks/csv_scraper_fireworks.py
index f588c4c5..c380f9bd 100644
--- a/examples/fireworks/csv_scraper_fireworks.py
+++ b/examples/fireworks/csv_scraper_fireworks.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/fireworks/csv_scraper_graph_multi_fireworks.py b/examples/fireworks/csv_scraper_graph_multi_fireworks.py
index ebc46e61..61518822 100644
--- a/examples/fireworks/csv_scraper_graph_multi_fireworks.py
+++ b/examples/fireworks/csv_scraper_graph_multi_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/fireworks/custom_graph_fireworks.py b/examples/fireworks/custom_graph_fireworks.py
index 66784d5b..518e9df3 100644
--- a/examples/fireworks/custom_graph_fireworks.py
+++ b/examples/fireworks/custom_graph_fireworks.py
@@ -1,12 +1,11 @@
"""
Example of custom graph using existing nodes
"""
-
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from scrapegraphai.graphs import BaseGraph
-from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
+from scrapegraphai.nodes import FetchNode, ParseNode, GenerateAnswerNode, RobotsNode
load_dotenv()
# ************************************************
diff --git a/examples/fireworks/json_scraper_fireworkspy.py b/examples/fireworks/json_scraper_fireworkspy.py
index a76a89c5..a8fd1d7a 100644
--- a/examples/fireworks/json_scraper_fireworkspy.py
+++ b/examples/fireworks/json_scraper_fireworkspy.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
diff --git a/examples/fireworks/pdf_scraper_fireworks.py b/examples/fireworks/pdf_scraper_fireworks.py
index 3bb3f3d4..182664d0 100644
--- a/examples/fireworks/pdf_scraper_fireworks.py
+++ b/examples/fireworks/pdf_scraper_fireworks.py
@@ -1,10 +1,13 @@
-import os, json
+"""
+pdf_scraper module
+"""
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/fireworks/rate_limit_fireworks.py b/examples/fireworks/rate_limit_fireworks.py
index b19cb770..813b6d5d 100644
--- a/examples/fireworks/rate_limit_fireworks.py
+++ b/examples/fireworks/rate_limit_fireworks.py
@@ -1,15 +1,14 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/fireworks/scrape_plain_text_fireworks.py b/examples/fireworks/scrape_plain_text_fireworks.py
index 331f05e2..c82bdf15 100644
--- a/examples/fireworks/scrape_plain_text_fireworks.py
+++ b/examples/fireworks/scrape_plain_text_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
@@ -34,8 +33,6 @@ graph_config = {
},
}
-
-
# ************************************************
# Create the SmartScraperGraph instance and run it
# ************************************************
diff --git a/examples/fireworks/script_generator_fireworks.py b/examples/fireworks/script_generator_fireworks.py
index 2ee3294c..d195cbdc 100644
--- a/examples/fireworks/script_generator_fireworks.py
+++ b/examples/fireworks/script_generator_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
@@ -46,4 +45,3 @@ print(result)
graph_exec_info = script_creator_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
diff --git a/examples/fireworks/script_generator_schema_fireworks.py b/examples/fireworks/script_generator_schema_fireworks.py
index 6355a4e8..20e46fb7 100644
--- a/examples/fireworks/script_generator_schema_fireworks.py
+++ b/examples/fireworks/script_generator_schema_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from typing import List
from dotenv import load_dotenv
diff --git a/examples/fireworks/script_multi_generator_fireworks.py b/examples/fireworks/script_multi_generator_fireworks.py
index 669f187d..c0f474dc 100644
--- a/examples/fireworks/script_multi_generator_fireworks.py
+++ b/examples/fireworks/script_multi_generator_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/fireworks/search_graph_fireworks.py b/examples/fireworks/search_graph_fireworks.py
index a091190c..72728a28 100644
--- a/examples/fireworks/search_graph_fireworks.py
+++ b/examples/fireworks/search_graph_fireworks.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
@@ -24,8 +23,6 @@ graph_config = {
"headless": False,
}
-
-
# ************************************************
# Create the SearchGraph instance and run it
# ************************************************
diff --git a/examples/fireworks/search_graph_schema_fireworks.py b/examples/fireworks/search_graph_schema_fireworks.py
index d88d991e..bd54a69a 100644
--- a/examples/fireworks/search_graph_schema_fireworks.py
+++ b/examples/fireworks/search_graph_schema_fireworks.py
@@ -3,14 +3,13 @@ Example of Search Graph
"""
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/fireworks/smart_scraper_fireworks.py b/examples/fireworks/smart_scraper_fireworks.py
index 778f1a07..2ccac269 100644
--- a/examples/fireworks/smart_scraper_fireworks.py
+++ b/examples/fireworks/smart_scraper_fireworks.py
@@ -9,7 +9,6 @@ from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/fireworks/smart_scraper_multi_fireworks.py b/examples/fireworks/smart_scraper_multi_fireworks.py
index 09e2c811..a75f9ab1 100644
--- a/examples/fireworks/smart_scraper_multi_fireworks.py
+++ b/examples/fireworks/smart_scraper_multi_fireworks.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
@@ -19,7 +18,6 @@ graph_config = {
"api_key": fireworks_api_key,
"model": "fireworks/accounts/fireworks/models/mixtral-8x7b-instruct"
},
-
"verbose": True,
"headless": False,
}
diff --git a/examples/fireworks/smart_scraper_schema_fireworks.py b/examples/fireworks/smart_scraper_schema_fireworks.py
index d71593f3..b576bc7d 100644
--- a/examples/fireworks/smart_scraper_schema_fireworks.py
+++ b/examples/fireworks/smart_scraper_schema_fireworks.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/fireworks/xml_scraper_fireworks.py b/examples/fireworks/xml_scraper_fireworks.py
index 59d9e6a3..88673cf6 100644
--- a/examples/fireworks/xml_scraper_fireworks.py
+++ b/examples/fireworks/xml_scraper_fireworks.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -56,4 +56,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/fireworks/xml_scraper_graph_multi_fireworks.py b/examples/fireworks/xml_scraper_graph_multi_fireworks.py
index 690836a4..1744325b 100644
--- a/examples/fireworks/xml_scraper_graph_multi_fireworks.py
+++ b/examples/fireworks/xml_scraper_graph_multi_fireworks.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/google_genai/code_generator_graph_gemini.py b/examples/google_genai/code_generator_graph_gemini.py
index 06b448cf..48ea9833 100644
--- a/examples/google_genai/code_generator_graph_gemini.py
+++ b/examples/google_genai/code_generator_graph_gemini.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -57,4 +56,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/google_genai/csv_scraper_gemini.py b/examples/google_genai/csv_scraper_gemini.py
index 6c48bc30..cb792169 100644
--- a/examples/google_genai/csv_scraper_gemini.py
+++ b/examples/google_genai/csv_scraper_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/google_genai/csv_scraper_graph_multi_gemini.py b/examples/google_genai/csv_scraper_graph_multi_gemini.py
index 38b40d76..a7b252ee 100644
--- a/examples/google_genai/csv_scraper_graph_multi_gemini.py
+++ b/examples/google_genai/csv_scraper_graph_multi_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/google_genai/custom_graph_gemini.py b/examples/google_genai/custom_graph_gemini.py
deleted file mode 100644
index 5999b8f9..00000000
--- a/examples/google_genai/custom_graph_gemini.py
+++ /dev/null
@@ -1,84 +0,0 @@
-"""
-Example of custom graph using Gemini Google model
-"""
-
-import os
-from dotenv import load_dotenv
-from scrapegraphai.models import Gemini
-from scrapegraphai.graphs import BaseGraph
-from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode
-load_dotenv()
-
-# ************************************************
-# Define the configuration for the graph
-# ************************************************
-
-gemini_key = os.getenv("GOOGLE_APIKEY")
-
-graph_config = {
- "llm": {
- "api_key": gemini_key,
- "model": "google_genai/gemini-pro",
- "temperature": 0,
- "streaming": True
- },
-}
-
-# ************************************************
-# Define the graph nodes
-# ************************************************
-
-llm_model = Gemini(graph_config["llm"])
-
-# define the nodes for the graph
-fetch_node = FetchNode(
- input="url | local_dir",
- output=["doc"],
-)
-parse_node = ParseNode(
- input="doc",
- output=["parsed_doc"],
- node_config={"chunk_size": 4096}
-)
-rag_node = RAGNode(
- input="user_prompt & (parsed_doc | doc)",
- output=["relevant_chunks"],
- node_config={"llm": llm_model},
-)
-generate_answer_node = GenerateAnswerNode(
- input="user_prompt & (relevant_chunks | parsed_doc | doc)",
- output=["answer"],
- node_config={"llm": llm_model},
-)
-
-# ************************************************
-# Create the graph by defining the connections
-# ************************************************
-
-graph = BaseGraph(
- nodes={
- fetch_node,
- parse_node,
- rag_node,
- generate_answer_node,
- },
- edges={
- (fetch_node, parse_node),
- (parse_node, rag_node),
- (rag_node, generate_answer_node)
- },
- entry_point=fetch_node
-)
-
-# ************************************************
-# Execute the graph
-# ************************************************
-
-result, execution_info = graph.execute({
- "user_prompt": "List me the projects with their description",
- "url": "https://perinim.github.io/projects/"
-})
-
-# get the answer from the result
-result = result.get("answer", "No answer found.")
-print(result)
diff --git a/examples/google_genai/json_scraper_gemini.py b/examples/google_genai/json_scraper_gemini.py
index 75f4dd6e..1b20a92a 100644
--- a/examples/google_genai/json_scraper_gemini.py
+++ b/examples/google_genai/json_scraper_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
diff --git a/examples/google_genai/pdf_scraper_graph_gemini.py b/examples/google_genai/pdf_scraper_graph_gemini.py
index 0b9fb67f..0af92709 100644
--- a/examples/google_genai/pdf_scraper_graph_gemini.py
+++ b/examples/google_genai/pdf_scraper_graph_gemini.py
@@ -1,15 +1,13 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
-from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import PDFScraperGraph
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/google_genai/rate_limit_gemini.py b/examples/google_genai/rate_limit_gemini.py
index f4e68f69..f3e2c555 100644
--- a/examples/google_genai/rate_limit_gemini.py
+++ b/examples/google_genai/rate_limit_gemini.py
@@ -1,13 +1,12 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import SmartScraperGraph
-load_dotenv()
+load_dotenv()
# ************************************************
# Define the configuration for the graph
diff --git a/examples/google_genai/scrape_plain_text_gemini.py b/examples/google_genai/scrape_plain_text_gemini.py
index 4048f9d0..f554cede 100644
--- a/examples/google_genai/scrape_plain_text_gemini.py
+++ b/examples/google_genai/scrape_plain_text_gemini.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/google_genai/scrape_xml_gemini.py b/examples/google_genai/scrape_xml_gemini.py
index 53f310e6..af8868ea 100644
--- a/examples/google_genai/scrape_xml_gemini.py
+++ b/examples/google_genai/scrape_xml_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/google_genai/script_generator_gemini.py b/examples/google_genai/script_generator_gemini.py
index 0ebc39bb..fdf61f87 100644
--- a/examples/google_genai/script_generator_gemini.py
+++ b/examples/google_genai/script_generator_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
@@ -9,7 +8,6 @@ from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/google_genai/script_multi_generator_gemini.py b/examples/google_genai/script_multi_generator_gemini.py
index 3fd74229..3ef0e108 100644
--- a/examples/google_genai/script_multi_generator_gemini.py
+++ b/examples/google_genai/script_multi_generator_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/google_genai/search_graph_gemini.py b/examples/google_genai/search_graph_gemini.py
index f7a7f8b8..d001b34d 100644
--- a/examples/google_genai/search_graph_gemini.py
+++ b/examples/google_genai/search_graph_gemini.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
diff --git a/examples/google_genai/search_graph_schema_gemini.py b/examples/google_genai/search_graph_schema_gemini.py
index e4b7983d..c55854c5 100644
--- a/examples/google_genai/search_graph_schema_gemini.py
+++ b/examples/google_genai/search_graph_schema_gemini.py
@@ -1,17 +1,14 @@
"""
Example of Search Graph
"""
-
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
-
+load_dotenv()
# ************************************************
# Define the output schema for the graph
# ************************************************
diff --git a/examples/google_genai/smart_scraper_multi_concat_gemini.py b/examples/google_genai/smart_scraper_multi_concat_gemini.py
index facd74c3..bf6ee544 100644
--- a/examples/google_genai/smart_scraper_multi_concat_gemini.py
+++ b/examples/google_genai/smart_scraper_multi_concat_gemini.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/google_genai/smart_scraper_multi_gemini.py b/examples/google_genai/smart_scraper_multi_gemini.py
index 4f0e1044..db721db9 100644
--- a/examples/google_genai/smart_scraper_multi_gemini.py
+++ b/examples/google_genai/smart_scraper_multi_gemini.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
diff --git a/examples/google_genai/smart_scraper_schema_gemini.py b/examples/google_genai/smart_scraper_schema_gemini.py
index 6c817e20..7037dc08 100644
--- a/examples/google_genai/smart_scraper_schema_gemini.py
+++ b/examples/google_genai/smart_scraper_schema_gemini.py
@@ -1,13 +1,13 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
import os
from typing import List
from pydantic import BaseModel, Field
from dotenv import load_dotenv
from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import SmartScraperGraph
+
load_dotenv()
# ************************************************
diff --git a/examples/google_genai/xml_scraper_gemini.py b/examples/google_genai/xml_scraper_gemini.py
index 79a57857..3c3dc342 100644
--- a/examples/google_genai/xml_scraper_gemini.py
+++ b/examples/google_genai/xml_scraper_gemini.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/google_genai/xml_scraper_graph_multi_gemini.py b/examples/google_genai/xml_scraper_graph_multi_gemini.py
index 37f98273..15bc2485 100644
--- a/examples/google_genai/xml_scraper_graph_multi_gemini.py
+++ b/examples/google_genai/xml_scraper_graph_multi_gemini.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/groq/code_generator_graph_groq.py b/examples/groq/code_generator_graph_groq.py
index c78d7c29..cf03d96c 100644
--- a/examples/groq/code_generator_graph_groq.py
+++ b/examples/groq/code_generator_graph_groq.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -58,4 +57,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/groq/csv_scraper_graph_multi_groq.py b/examples/groq/csv_scraper_graph_multi_groq.py
index 475b8cac..e0343f31 100644
--- a/examples/groq/csv_scraper_graph_multi_groq.py
+++ b/examples/groq/csv_scraper_graph_multi_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/groq/csv_scraper_groq.py b/examples/groq/csv_scraper_groq.py
index 805ce5fc..6c36b4c4 100644
--- a/examples/groq/csv_scraper_groq.py
+++ b/examples/groq/csv_scraper_groq.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/groq/custom_graph_groq.py b/examples/groq/custom_graph_groq.py
index f0d7e215..ea35137f 100644
--- a/examples/groq/custom_graph_groq.py
+++ b/examples/groq/custom_graph_groq.py
@@ -1,12 +1,11 @@
"""
Example of custom graph using existing nodes
"""
-
import os
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from scrapegraphai.graphs import BaseGraph
-from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
+from scrapegraphai.nodes import FetchNode, ParseNode, GenerateAnswerNode, RobotsNode
load_dotenv()
# ************************************************
diff --git a/examples/groq/json_scraper_groq.py b/examples/groq/json_scraper_groq.py
index a9099069..d38e1505 100644
--- a/examples/groq/json_scraper_groq.py
+++ b/examples/groq/json_scraper_groq.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/groq/pdf_scraper_graph_groq.py b/examples/groq/pdf_scraper_graph_groq.py
index 2560c11e..7cf18d33 100644
--- a/examples/groq/pdf_scraper_graph_groq.py
+++ b/examples/groq/pdf_scraper_graph_groq.py
@@ -1,7 +1,8 @@
"""
Example of pdf_scraper_graph
"""
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
@@ -22,7 +23,6 @@ graph_config = {
"verbose": True,
}
-
source = """
The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
diff --git a/examples/groq/rate_limit_groq.py b/examples/groq/rate_limit_groq.py
index 976127be..8e59115f 100644
--- a/examples/groq/rate_limit_groq.py
+++ b/examples/groq/rate_limit_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/groq/scrape_plain_text_groq.py b/examples/groq/scrape_plain_text_groq.py
index 329df51f..c4e4065d 100644
--- a/examples/groq/scrape_plain_text_groq.py
+++ b/examples/groq/scrape_plain_text_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/groq/script_generator_groq.py b/examples/groq/script_generator_groq.py
index 9e280e2b..08550044 100644
--- a/examples/groq/script_generator_groq.py
+++ b/examples/groq/script_generator_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/groq/search_graph_groq.py b/examples/groq/search_graph_groq.py
index e3044c0e..ec971e37 100644
--- a/examples/groq/search_graph_groq.py
+++ b/examples/groq/search_graph_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
diff --git a/examples/groq/search_graph_schema_groq.py b/examples/groq/search_graph_schema_groq.py
index 4cc2209d..ae0de3ee 100644
--- a/examples/groq/search_graph_schema_groq.py
+++ b/examples/groq/search_graph_schema_groq.py
@@ -1,16 +1,14 @@
"""
Example of Search Graph
"""
-
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/groq/smart_scraper_groq.py b/examples/groq/smart_scraper_groq.py
index ab38edc0..fe70464c 100644
--- a/examples/groq/smart_scraper_groq.py
+++ b/examples/groq/smart_scraper_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/groq/smart_scraper_multi_concat_groq.py b/examples/groq/smart_scraper_multi_concat_groq.py
index 038ca37c..79c262a1 100644
--- a/examples/groq/smart_scraper_multi_concat_groq.py
+++ b/examples/groq/smart_scraper_multi_concat_groq.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/groq/smart_scraper_multi_groq.py b/examples/groq/smart_scraper_multi_groq.py
index 6ead098c..fec8fbb5 100644
--- a/examples/groq/smart_scraper_multi_groq.py
+++ b/examples/groq/smart_scraper_multi_groq.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
diff --git a/examples/groq/smart_scraper_schema_groq.py b/examples/groq/smart_scraper_schema_groq.py
index f9c1a40b..bfa7ed3b 100644
--- a/examples/groq/smart_scraper_schema_groq.py
+++ b/examples/groq/smart_scraper_schema_groq.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
-import os, json
+import os
from typing import List
from pydantic import BaseModel, Field
from dotenv import load_dotenv
diff --git a/examples/groq/xml_scraper_graph_multi_groq.py b/examples/groq/xml_scraper_graph_multi_groq.py
index 62540671..09c7483f 100644
--- a/examples/groq/xml_scraper_graph_multi_groq.py
+++ b/examples/groq/xml_scraper_graph_multi_groq.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -34,7 +34,6 @@ graph_config = {
"headless": False
}
-
# ************************************************
# Create the XMLScraperMultiGraph instance and run it
# ************************************************
diff --git a/examples/groq/xml_scraper_groq.py b/examples/groq/xml_scraper_groq.py
index 2172ea77..cb1ca8d7 100644
--- a/examples/groq/xml_scraper_groq.py
+++ b/examples/groq/xml_scraper_groq.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/mistral/code_generator_graph_mistral.py b/examples/mistral/code_generator_graph_mistral.py
index b9f7bdb9..19af9aef 100644
--- a/examples/mistral/code_generator_graph_mistral.py
+++ b/examples/mistral/code_generator_graph_mistral.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -57,4 +56,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/mistral/csv_scraper_graph_multi_mistral.py b/examples/mistral/csv_scraper_graph_multi_mistral.py
index 615e59e4..608a8851 100644
--- a/examples/mistral/csv_scraper_graph_multi_mistral.py
+++ b/examples/mistral/csv_scraper_graph_multi_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
@@ -9,6 +8,7 @@ from scrapegraphai.graphs import CSVScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv()
+
# ************************************************
# Read the CSV file
# ************************************************
diff --git a/examples/mistral/csv_scraper_mistral.py b/examples/mistral/csv_scraper_mistral.py
index 195fb16a..6daa216c 100644
--- a/examples/mistral/csv_scraper_mistral.py
+++ b/examples/mistral/csv_scraper_mistral.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/mistral/custom_graph_mistral.py b/examples/mistral/custom_graph_mistral.py
index ec2878c1..bac1cd30 100644
--- a/examples/mistral/custom_graph_mistral.py
+++ b/examples/mistral/custom_graph_mistral.py
@@ -1,13 +1,12 @@
"""
Example of custom graph using existing nodes
"""
-
import os
from dotenv import load_dotenv
-
from langchain_mistralai import ChatMistralAI, MistralAIEmbeddings
from scrapegraphai.graphs import BaseGraph
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
+
load_dotenv()
# ************************************************
diff --git a/examples/mistral/json_scraper_mistral.py b/examples/mistral/json_scraper_mistral.py
index 12f55127..140ea58f 100644
--- a/examples/mistral/json_scraper_mistral.py
+++ b/examples/mistral/json_scraper_mistral.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -55,4 +55,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/mistral/md_scraper_mistral.py b/examples/mistral/md_scraper_mistral.py
index c4e3f2c7..ee3604a7 100644
--- a/examples/mistral/md_scraper_mistral.py
+++ b/examples/mistral/md_scraper_mistral.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using MDScraperGraph from MD documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import MDScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/mistral/pdf_scraper_mistral.py b/examples/mistral/pdf_scraper_mistral.py
index b006fdb8..7a36fc0c 100644
--- a/examples/mistral/pdf_scraper_mistral.py
+++ b/examples/mistral/pdf_scraper_mistral.py
@@ -1,10 +1,13 @@
-import os, json
+"""
+pdf_scraper_mistral module
+"""
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/mistral/rate_limit_mistral.py b/examples/mistral/rate_limit_mistral.py
index fbd65a1a..4bc0f6fb 100644
--- a/examples/mistral/rate_limit_mistral.py
+++ b/examples/mistral/rate_limit_mistral.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
-import os, json
+import os
+import json
from scrapegraphai.graphs import SmartScraperGraph
-from scrapegraphai.utils import prettify_exec_info
from dotenv import load_dotenv
+
load_dotenv()
# ************************************************
@@ -37,10 +37,3 @@ smart_scraper_graph = SmartScraperGraph(
result = smart_scraper_graph.run()
print(json.dumps(result, indent=4))
-
-# ************************************************
-# Get graph execution info
-# ************************************************
-
-graph_exec_info = smart_scraper_graph.get_execution_info()
-print(prettify_exec_info(graph_exec_info))
diff --git a/examples/mistral/scrape_plain_text_mistral.py b/examples/mistral/scrape_plain_text_mistral.py
index f2b38172..131747c6 100644
--- a/examples/mistral/scrape_plain_text_mistral.py
+++ b/examples/mistral/scrape_plain_text_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/mistral/script_generator_mistral.py b/examples/mistral/script_generator_mistral.py
index 4fe45773..74a81b46 100644
--- a/examples/mistral/script_generator_mistral.py
+++ b/examples/mistral/script_generator_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/mistral/script_multi_generator_mistral.py b/examples/mistral/script_multi_generator_mistral.py
index 142b5140..d5869c53 100644
--- a/examples/mistral/script_multi_generator_mistral.py
+++ b/examples/mistral/script_multi_generator_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/mistral/search_graph_mistral.py b/examples/mistral/search_graph_mistral.py
index f8573f5e..983733e0 100644
--- a/examples/mistral/search_graph_mistral.py
+++ b/examples/mistral/search_graph_mistral.py
@@ -1,10 +1,10 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
+
load_dotenv()
# ************************************************
diff --git a/examples/mistral/search_graph_schema_mistral.py b/examples/mistral/search_graph_schema_mistral.py
index 7c71c0b1..06a88ff7 100644
--- a/examples/mistral/search_graph_schema_mistral.py
+++ b/examples/mistral/search_graph_schema_mistral.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from typing import List
from dotenv import load_dotenv
diff --git a/examples/mistral/search_link_graph_mistral.py b/examples/mistral/search_link_graph_mistral.py
index 3216ff2c..45d0c5f0 100644
--- a/examples/mistral/search_link_graph_mistral.py
+++ b/examples/mistral/search_link_graph_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchLinkGraph
diff --git a/examples/mistral/smart_scraper_multi_concat_mistral.py b/examples/mistral/smart_scraper_multi_concat_mistral.py
index cef9e16e..9cef8a16 100644
--- a/examples/mistral/smart_scraper_multi_concat_mistral.py
+++ b/examples/mistral/smart_scraper_multi_concat_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/mistral/smart_scraper_multi_mistral.py b/examples/mistral/smart_scraper_multi_mistral.py
index 2654fbcb..7929f9cc 100644
--- a/examples/mistral/smart_scraper_multi_mistral.py
+++ b/examples/mistral/smart_scraper_multi_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/mistral/smart_scraper_schema_mistral.py b/examples/mistral/smart_scraper_schema_mistral.py
index 3e1e505a..3b129a89 100644
--- a/examples/mistral/smart_scraper_schema_mistral.py
+++ b/examples/mistral/smart_scraper_schema_mistral.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/mistral/xml_scraper_graph_multi_mistral.py b/examples/mistral/xml_scraper_graph_multi_mistral.py
index 0ea9d30c..6db20ebf 100644
--- a/examples/mistral/xml_scraper_graph_multi_mistral.py
+++ b/examples/mistral/xml_scraper_graph_multi_mistral.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
@@ -23,7 +22,6 @@ with open(file_path, 'r', encoding="utf-8") as file:
# Define the configuration for the graph
# ************************************************
-
mistral_key = os.getenv("MISTRAL_API_KEY")
graph_config = {
diff --git a/examples/mistral/xml_scraper_mistral.py b/examples/mistral/xml_scraper_mistral.py
index eb6036bf..6d551c22 100644
--- a/examples/mistral/xml_scraper_mistral.py
+++ b/examples/mistral/xml_scraper_mistral.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -56,4 +56,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/nemotron/code_generator_graph_nemotron.py b/examples/nemotron/code_generator_graph_nemotron.py
index c2ad8ab4..5ccd9d9f 100644
--- a/examples/nemotron/code_generator_graph_nemotron.py
+++ b/examples/nemotron/code_generator_graph_nemotron.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
@@ -55,4 +54,4 @@ code_generator_graph = CodeGeneratorGraph(
)
result = code_generator_graph.run()
-print(result)
\ No newline at end of file
+print(result)
diff --git a/examples/nemotron/csv_scraper_graph_multi_nemotron.py b/examples/nemotron/csv_scraper_graph_multi_nemotron.py
index 1dc7f9ce..d5de6039 100644
--- a/examples/nemotron/csv_scraper_graph_multi_nemotron.py
+++ b/examples/nemotron/csv_scraper_graph_multi_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
import pandas as pd
from dotenv import load_dotenv
diff --git a/examples/nemotron/csv_scraper_nemotron.py b/examples/nemotron/csv_scraper_nemotron.py
index 3fede206..2d527450 100644
--- a/examples/nemotron/csv_scraper_nemotron.py
+++ b/examples/nemotron/csv_scraper_nemotron.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/custom_graph_nemotron.py b/examples/nemotron/custom_graph_nemotron.py
deleted file mode 100644
index 22c6a4a1..00000000
--- a/examples/nemotron/custom_graph_nemotron.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""
-Example of custom graph using existing nodes
-"""
-
-import os
-from dotenv import load_dotenv
-
-from langchain_openai import OpenAIEmbeddings
-from langchain_openai import ChatOpenAI
-from scrapegraphai.graphs import BaseGraph
-from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
-load_dotenv()
-
-# ************************************************
-# Define the configuration for the graph
-# ************************************************
-
-graph_config = {
- "llm": {
- "api_key": os.getenv("NEMOTRON_KEY"),
- "model": "claude-3-haiku-20240307",
- },
-}
-
-# ************************************************
-# Define the graph nodes
-# ************************************************
-
-llm_model = OpenAI(graph_config["llm"])
-embedder = OpenAIEmbeddings(api_key=llm_model.openai_api_key)
-
-# define the nodes for the graph
-robot_node = RobotsNode(
- input="url",
- output=["is_scrapable"],
- node_config={
- "llm_model": llm_model,
- "force_scraping": True,
- "verbose": True,
- }
-)
-
-fetch_node = FetchNode(
- input="url | local_dir",
- output=["doc"],
- node_config={
- "verbose": True,
- "headless": True,
- }
-)
-parse_node = ParseNode(
- input="doc",
- output=["parsed_doc"],
- node_config={
- "chunk_size": 4096,
- "verbose": True,
- }
-)
-rag_node = RAGNode(
- input="user_prompt & (parsed_doc | doc)",
- output=["relevant_chunks"],
- node_config={
- "llm_model": llm_model,
- "embedder_model": embedder,
- "verbose": True,
- }
-)
-generate_answer_node = GenerateAnswerNode(
- input="user_prompt & (relevant_chunks | parsed_doc | doc)",
- output=["answer"],
- node_config={
- "llm_model": llm_model,
- "verbose": True,
- }
-)
-
-# ************************************************
-# Create the graph by defining the connections
-# ************************************************
-
-graph = BaseGraph(
- nodes=[
- robot_node,
- fetch_node,
- parse_node,
- rag_node,
- generate_answer_node,
- ],
- edges=[
- (robot_node, fetch_node),
- (fetch_node, parse_node),
- (parse_node, rag_node),
- (rag_node, generate_answer_node)
- ],
- entry_point=robot_node
-)
-
-# ************************************************
-# Execute the graph
-# ************************************************
-
-result, execution_info = graph.execute({
- "user_prompt": "Describe the content",
- "url": "https://example.com/"
-})
-
-# get the answer from the result
-result = result.get("answer", "No answer found.")
-print(result)
diff --git a/examples/nemotron/json_scraper_nemotron.py b/examples/nemotron/json_scraper_nemotron.py
index 7f19d15e..a5479ca7 100644
--- a/examples/nemotron/json_scraper_nemotron.py
+++ b/examples/nemotron/json_scraper_nemotron.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -55,4 +55,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/nemotron/md_scraper_nemotron.py b/examples/nemotron/md_scraper_nemotron.py
index 71073bd4..1748f8cf 100644
--- a/examples/nemotron/md_scraper_nemotron.py
+++ b/examples/nemotron/md_scraper_nemotron.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using MDScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import MDScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/pdf_scraper_nemotron.py b/examples/nemotron/pdf_scraper_nemotron.py
index b8b4482e..06b6364c 100644
--- a/examples/nemotron/pdf_scraper_nemotron.py
+++ b/examples/nemotron/pdf_scraper_nemotron.py
@@ -1,4 +1,8 @@
-import os, json
+"""
+pdf_scraper nemotron
+"""
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
diff --git a/examples/nemotron/rate_limit_nemotron.py b/examples/nemotron/rate_limit_nemotron.py
index 8b1a5eb4..934c2036 100644
--- a/examples/nemotron/rate_limit_nemotron.py
+++ b/examples/nemotron/rate_limit_nemotron.py
@@ -1,11 +1,12 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
-import os, json
+import os
+import json
+from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
-from dotenv import load_dotenv
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/scrape_plain_text_nemotron.py b/examples/nemotron/scrape_plain_text_nemotron.py
index e5e7f764..315bae8e 100644
--- a/examples/nemotron/scrape_plain_text_nemotron.py
+++ b/examples/nemotron/scrape_plain_text_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/nemotron/script_generator_nemotron.py b/examples/nemotron/script_generator_nemotron.py
index d8863214..2ff8176a 100644
--- a/examples/nemotron/script_generator_nemotron.py
+++ b/examples/nemotron/script_generator_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
@@ -43,4 +42,3 @@ print(result)
graph_exec_info = script_creator_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
diff --git a/examples/nemotron/script_generator_schema_nemotron.py b/examples/nemotron/script_generator_schema_nemotron.py
index 3f0713a4..9516521a 100644
--- a/examples/nemotron/script_generator_schema_nemotron.py
+++ b/examples/nemotron/script_generator_schema_nemotron.py
@@ -1,14 +1,12 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
-from scrapegraphai.graphs import ScriptCreatorGraph
-from scrapegraphai.utils import prettify_exec_info
-
from pydantic import BaseModel, Field
from typing import List
+from scrapegraphai.graphs import ScriptCreatorGraph
+from scrapegraphai.utils import prettify_exec_info
load_dotenv()
@@ -59,4 +57,3 @@ print(result)
graph_exec_info = script_creator_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
diff --git a/examples/nemotron/script_multi_generator_nemotron.py b/examples/nemotron/script_multi_generator_nemotron.py
index c1426e85..730fab8d 100644
--- a/examples/nemotron/script_multi_generator_nemotron.py
+++ b/examples/nemotron/script_multi_generator_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/nemotron/search_graph_nemotron.py b/examples/nemotron/search_graph_nemotron.py
index 3e6a7050..e57e9642 100644
--- a/examples/nemotron/search_graph_nemotron.py
+++ b/examples/nemotron/search_graph_nemotron.py
@@ -1,10 +1,10 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/search_graph_schema_nemotron.py b/examples/nemotron/search_graph_schema_nemotron.py
index eec72daf..64fbf047 100644
--- a/examples/nemotron/search_graph_schema_nemotron.py
+++ b/examples/nemotron/search_graph_schema_nemotron.py
@@ -3,14 +3,13 @@ Example of Search Graph
"""
import os
+from typing import List
from dotenv import load_dotenv
-load_dotenv()
-
+from pydantic import BaseModel, Field
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/nemotron/smart_scraper_multi_concat_nemotron.py b/examples/nemotron/smart_scraper_multi_concat_nemotron.py
index 0444e18e..3297fcbf 100644
--- a/examples/nemotron/smart_scraper_multi_concat_nemotron.py
+++ b/examples/nemotron/smart_scraper_multi_concat_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/nemotron/smart_scraper_multi_nemotron.py b/examples/nemotron/smart_scraper_multi_nemotron.py
index c8e167ad..00306a96 100644
--- a/examples/nemotron/smart_scraper_multi_nemotron.py
+++ b/examples/nemotron/smart_scraper_multi_nemotron.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/nemotron/smart_scraper_nemotron.py b/examples/nemotron/smart_scraper_nemotron.py
index 182a12d1..10ad42b7 100644
--- a/examples/nemotron/smart_scraper_nemotron.py
+++ b/examples/nemotron/smart_scraper_nemotron.py
@@ -2,10 +2,12 @@
Basic example of scraping pipeline using SmartScraper
"""
-import os, json
+import os
+import json
+from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
-from dotenv import load_dotenv
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/smart_scraper_schema_nemotron.py b/examples/nemotron/smart_scraper_schema_nemotron.py
index e1462e85..54dbce1f 100644
--- a/examples/nemotron/smart_scraper_schema_nemotron.py
+++ b/examples/nemotron/smart_scraper_schema_nemotron.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/nemotron/speech_graph_nemotron.py b/examples/nemotron/speech_graph_nemotron.py
index 3d46b9e2..21f0d2b1 100644
--- a/examples/nemotron/speech_graph_nemotron.py
+++ b/examples/nemotron/speech_graph_nemotron.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SpeechSummaryGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SpeechGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/xml_scraper_graph_nemotron.py b/examples/nemotron/xml_scraper_graph_nemotron.py
index 4b53e082..753b0be5 100644
--- a/examples/nemotron/xml_scraper_graph_nemotron.py
+++ b/examples/nemotron/xml_scraper_graph_nemotron.py
@@ -2,11 +2,11 @@
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/nemotron/xml_scraper_nemotron.py b/examples/nemotron/xml_scraper_nemotron.py
index a3291cce..5f7cb7d6 100644
--- a/examples/nemotron/xml_scraper_nemotron.py
+++ b/examples/nemotron/xml_scraper_nemotron.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/oneapi/code_generator_graph_oneapi.py b/examples/oneapi/code_generator_graph_oneapi.py
index aff40a3e..5f9808a3 100644
--- a/examples/oneapi/code_generator_graph_oneapi.py
+++ b/examples/oneapi/code_generator_graph_oneapi.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/oneapi/csv_scraper_graph_multi_oneapi.py b/examples/oneapi/csv_scraper_graph_multi_oneapi.py
index 890765df..7b5d8abd 100644
--- a/examples/oneapi/csv_scraper_graph_multi_oneapi.py
+++ b/examples/oneapi/csv_scraper_graph_multi_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
@@ -9,6 +8,7 @@ from scrapegraphai.graphs import CSVScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
load_dotenv()
+
# ************************************************
# Read the CSV file
# ************************************************
diff --git a/examples/oneapi/csv_scraper_oneapi.py b/examples/oneapi/csv_scraper_oneapi.py
index ec0c2c08..a9fda090 100644
--- a/examples/oneapi/csv_scraper_oneapi.py
+++ b/examples/oneapi/csv_scraper_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/oneapi/json_scraper_oneapi.py b/examples/oneapi/json_scraper_oneapi.py
index 87c7ea3c..2f89fc50 100644
--- a/examples/oneapi/json_scraper_oneapi.py
+++ b/examples/oneapi/json_scraper_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
@@ -52,4 +51,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/oneapi/pdf_scraper_graph_oneapi.py b/examples/oneapi/pdf_scraper_graph_oneapi.py
index 8fac8195..4e9214b0 100644
--- a/examples/oneapi/pdf_scraper_graph_oneapi.py
+++ b/examples/oneapi/pdf_scraper_graph_oneapi.py
@@ -1,4 +1,7 @@
-import os, json
+"""
+pdf_scraper_oneapi module
+"""
+import json
from scrapegraphai.graphs import PDFScraperGraph
# ************************************************
@@ -24,10 +27,6 @@ source = """
the Beatrice of his earlier poetry, through the celestial spheres of Paradise.
"""
-<<<<<<< Updated upstream
-
-=======
->>>>>>> Stashed changes
pdf_scraper_graph = PDFScraperGraph(
prompt="Summarize the text and find the main topics",
source=source,
diff --git a/examples/oneapi/rate_limit_oneapi.py b/examples/oneapi/rate_limit_oneapi.py
index 64a170f7..abd2f9c7 100644
--- a/examples/oneapi/rate_limit_oneapi.py
+++ b/examples/oneapi/rate_limit_oneapi.py
@@ -3,11 +3,11 @@ Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
+
# ************************************************
# Define the configuration for the graph
# ************************************************
-
graph_config = {
"llm": {
"api_key": "***************************",
diff --git a/examples/oneapi/scrape_plain_text_oneapi.py b/examples/oneapi/scrape_plain_text_oneapi.py
index 594bb32a..268d2b0d 100644
--- a/examples/oneapi/scrape_plain_text_oneapi.py
+++ b/examples/oneapi/scrape_plain_text_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/oneapi/script_generator_oneapi.py b/examples/oneapi/script_generator_oneapi.py
index 42222635..3876eb34 100644
--- a/examples/oneapi/script_generator_oneapi.py
+++ b/examples/oneapi/script_generator_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/oneapi/script_multi_generator_oneapi.py b/examples/oneapi/script_multi_generator_oneapi.py
index b9c5bfef..42328744 100644
--- a/examples/oneapi/script_multi_generator_oneapi.py
+++ b/examples/oneapi/script_multi_generator_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
from scrapegraphai.graphs import ScriptCreatorMultiGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/oneapi/search_graph_oneapi.py b/examples/oneapi/search_graph_oneapi.py
index d5b1ea44..b25cbfa6 100644
--- a/examples/oneapi/search_graph_oneapi.py
+++ b/examples/oneapi/search_graph_oneapi.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
from scrapegraphai.graphs import SearchGraph
# ************************************************
diff --git a/examples/oneapi/smart_scraper_multi_concat_oneapi.py b/examples/oneapi/smart_scraper_multi_concat_oneapi.py
index e1f5490d..bbadbcfd 100644
--- a/examples/oneapi/smart_scraper_multi_concat_oneapi.py
+++ b/examples/oneapi/smart_scraper_multi_concat_oneapi.py
@@ -2,11 +2,9 @@
Basic example of scraping pipeline using SmartScraper
"""
-import os
import json
from scrapegraphai.graphs import SmartScraperMultiConcatGraph
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/oneapi/smart_scraper_multi_oneapi.py b/examples/oneapi/smart_scraper_multi_oneapi.py
index c127567f..37b7b6e8 100644
--- a/examples/oneapi/smart_scraper_multi_oneapi.py
+++ b/examples/oneapi/smart_scraper_multi_oneapi.py
@@ -6,6 +6,8 @@ import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
+load_dotenv()
+
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/oneapi/smart_scraper_oneapi.py b/examples/oneapi/smart_scraper_oneapi.py
index 7668808b..30b12aa3 100644
--- a/examples/oneapi/smart_scraper_oneapi.py
+++ b/examples/oneapi/smart_scraper_oneapi.py
@@ -3,11 +3,11 @@ Basic example of scraping pipeline using SmartScraper
"""
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
+
# ************************************************
# Define the configuration for the graph
# ************************************************
-
graph_config = {
"llm": {
"api_key": "***************************",
diff --git a/examples/oneapi/smartscraper_oneapi.py b/examples/oneapi/smartscraper_oneapi.py
index 2b2c7335..f0783782 100644
--- a/examples/oneapi/smartscraper_oneapi.py
+++ b/examples/oneapi/smartscraper_oneapi.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/examples/oneapi/xml_scraper_oneapi.py b/examples/oneapi/xml_scraper_oneapi.py
index cb92bbf2..7ea7fad5 100644
--- a/examples/oneapi/xml_scraper_oneapi.py
+++ b/examples/oneapi/xml_scraper_oneapi.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -56,4 +56,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/openai/code_generator_graph_openai.py b/examples/openai/code_generator_graph_openai.py
index fd2b7ddb..a9a2ea56 100644
--- a/examples/openai/code_generator_graph_openai.py
+++ b/examples/openai/code_generator_graph_openai.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using Code Generator with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/openai/csv_scraper_graph_multi_openai.py b/examples/openai/csv_scraper_graph_multi_openai.py
index 5e876dcb..6ed33c90 100644
--- a/examples/openai/csv_scraper_graph_multi_openai.py
+++ b/examples/openai/csv_scraper_graph_multi_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/openai/csv_scraper_openai.py b/examples/openai/csv_scraper_openai.py
index f4410fcd..d9527b86 100644
--- a/examples/openai/csv_scraper_openai.py
+++ b/examples/openai/csv_scraper_openai.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/openai/custom_graph_openai.py b/examples/openai/custom_graph_openai.py
index a4cf9351..00fecfdd 100644
--- a/examples/openai/custom_graph_openai.py
+++ b/examples/openai/custom_graph_openai.py
@@ -1,14 +1,13 @@
"""
Example of custom graph using existing nodes
"""
-
import os
from dotenv import load_dotenv
-
from langchain_openai import OpenAIEmbeddings
from langchain_openai import ChatOpenAI
from scrapegraphai.graphs import BaseGraph
from scrapegraphai.nodes import FetchNode, ParseNode, RAGNode, GenerateAnswerNode, RobotsNode
+
load_dotenv()
# ************************************************
diff --git a/examples/openai/json_scraper_openai.py b/examples/openai/json_scraper_openai.py
index e20a5870..891ec32a 100644
--- a/examples/openai/json_scraper_openai.py
+++ b/examples/openai/json_scraper_openai.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -55,4 +55,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/openai/md_scraper_openai.py b/examples/openai/md_scraper_openai.py
index 3456c89a..76775015 100644
--- a/examples/openai/md_scraper_openai.py
+++ b/examples/openai/md_scraper_openai.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using MDScraperGraph from MD documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import MDScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/openai/omni_scraper_openai.py b/examples/openai/omni_scraper_openai.py
index 3e6e62ee..61da3b6a 100644
--- a/examples/openai/omni_scraper_openai.py
+++ b/examples/openai/omni_scraper_openai.py
@@ -1,15 +1,14 @@
"""
Basic example of scraping pipeline using OmniScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import OmniScraperGraph
from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/openai/omni_search_openai.py b/examples/openai/omni_search_openai.py
index fb967def..a6fdb266 100644
--- a/examples/openai/omni_search_openai.py
+++ b/examples/openai/omni_search_openai.py
@@ -1,11 +1,12 @@
"""
Example of OmniSearchGraph
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import OmniSearchGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -42,4 +43,3 @@ print(json.dumps(result, indent=2))
graph_exec_info = omni_search_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))
-
diff --git a/examples/openai/pdf_scraper_openai.py b/examples/openai/pdf_scraper_openai.py
index e076defe..f7b99130 100644
--- a/examples/openai/pdf_scraper_openai.py
+++ b/examples/openai/pdf_scraper_openai.py
@@ -1,10 +1,13 @@
-import os, json
+"""
+pdf_scraper_openai example module
+"""
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import PDFScraperGraph
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/openai/scrape_plain_text_openai.py b/examples/openai/scrape_plain_text_openai.py
index eb8c76e5..27a65663 100644
--- a/examples/openai/scrape_plain_text_openai.py
+++ b/examples/openai/scrape_plain_text_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
diff --git a/examples/openai/screenshot_scraper.py b/examples/openai/screenshot_scraper.py
index c72c44d1..f5576b64 100644
--- a/examples/openai/screenshot_scraper.py
+++ b/examples/openai/screenshot_scraper.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/openai/script_generator_openai.py b/examples/openai/script_generator_openai.py
index a4a39196..611acc57 100644
--- a/examples/openai/script_generator_openai.py
+++ b/examples/openai/script_generator_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/openai/script_generator_schema_openai.py b/examples/openai/script_generator_schema_openai.py
index 7611c029..adb646d1 100644
--- a/examples/openai/script_generator_schema_openai.py
+++ b/examples/openai/script_generator_schema_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from typing import List
from dotenv import load_dotenv
diff --git a/examples/openai/script_multi_generator_openai.py b/examples/openai/script_multi_generator_openai.py
index 6693ac0f..19eacf66 100644
--- a/examples/openai/script_multi_generator_openai.py
+++ b/examples/openai/script_multi_generator_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/openai/search_graph_openai.py b/examples/openai/search_graph_openai.py
index 8268f800..b8acf4f8 100644
--- a/examples/openai/search_graph_openai.py
+++ b/examples/openai/search_graph_openai.py
@@ -4,6 +4,7 @@ Example of Search Graph
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
+
load_dotenv()
# ************************************************
diff --git a/examples/openai/search_graph_schema_openai.py b/examples/openai/search_graph_schema_openai.py
index 3980db0e..3109cc79 100644
--- a/examples/openai/search_graph_schema_openai.py
+++ b/examples/openai/search_graph_schema_openai.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from typing import List
from dotenv import load_dotenv
diff --git a/examples/openai/search_link_graph_openai.py b/examples/openai/search_link_graph_openai.py
index a988731b..f7436159 100644
--- a/examples/openai/search_link_graph_openai.py
+++ b/examples/openai/search_link_graph_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchLinkGraph
diff --git a/examples/openai/smart_scraper_multi_concat_openai.py b/examples/openai/smart_scraper_multi_concat_openai.py
index c6ee88cc..650971f1 100644
--- a/examples/openai/smart_scraper_multi_concat_openai.py
+++ b/examples/openai/smart_scraper_multi_concat_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/openai/smart_scraper_multi_openai.py b/examples/openai/smart_scraper_multi_openai.py
index 8f5e648b..ba889c96 100644
--- a/examples/openai/smart_scraper_multi_openai.py
+++ b/examples/openai/smart_scraper_multi_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/openai/smart_scraper_openai.py b/examples/openai/smart_scraper_openai.py
index 2962f51b..79c2d42c 100644
--- a/examples/openai/smart_scraper_openai.py
+++ b/examples/openai/smart_scraper_openai.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
import json
from dotenv import load_dotenv
diff --git a/examples/openai/smart_scraper_schema_openai.py b/examples/openai/smart_scraper_schema_openai.py
index 1df2be7b..32e8891a 100644
--- a/examples/openai/smart_scraper_schema_openai.py
+++ b/examples/openai/smart_scraper_schema_openai.py
@@ -1,8 +1,7 @@
"""
Basic example of scraping pipeline using SmartScraper with schema
"""
-
-import os, json
+import os
from typing import List
from dotenv import load_dotenv
from pydantic import BaseModel, Field
diff --git a/examples/openai/speech_graph_openai.py b/examples/openai/speech_graph_openai.py
index 7c368df7..1890c44e 100644
--- a/examples/openai/speech_graph_openai.py
+++ b/examples/openai/speech_graph_openai.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SpeechSummaryGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SpeechGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/openai/xml_scraper_graph_multi_openai.py b/examples/openai/xml_scraper_graph_multi_openai.py
index 6610a49f..3604489b 100644
--- a/examples/openai/xml_scraper_graph_multi_openai.py
+++ b/examples/openai/xml_scraper_graph_multi_openai.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -23,7 +23,6 @@ with open(file_path, 'r', encoding="utf-8") as file:
# Define the configuration for the graph
# ************************************************
-
openai_key = os.getenv("OPENAI_APIKEY")
graph_config = {
diff --git a/examples/openai/xml_scraper_openai.py b/examples/openai/xml_scraper_openai.py
index 04b3ec9d..1d3b8d85 100644
--- a/examples/openai/xml_scraper_openai.py
+++ b/examples/openai/xml_scraper_openai.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -56,4 +56,3 @@ print(prettify_exec_info(graph_exec_info))
# Save to json or csv
convert_to_csv(result, "result")
convert_to_json(result, "result")
-
diff --git a/examples/together/csv_scraper_graph_multi_together.py b/examples/together/csv_scraper_graph_multi_together.py
index 588d2c5e..beee56c1 100644
--- a/examples/together/csv_scraper_graph_multi_together.py
+++ b/examples/together/csv_scraper_graph_multi_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using CSVScraperMultiGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
diff --git a/examples/together/csv_scraper_together.py b/examples/together/csv_scraper_together.py
index 9b1838ae..5d1a3474 100644
--- a/examples/together/csv_scraper_together.py
+++ b/examples/together/csv_scraper_together.py
@@ -1,12 +1,12 @@
"""
Basic example of scraping pipeline using CSVScraperGraph from CSV documents
"""
-
import os
from dotenv import load_dotenv
import pandas as pd
from scrapegraphai.graphs import CSVScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/together/json_scraper_together.py b/examples/together/json_scraper_together.py
index b1e646f9..a39c6ce4 100644
--- a/examples/together/json_scraper_together.py
+++ b/examples/together/json_scraper_together.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using JSONScraperGraph from JSON documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import JSONScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/together/pdf_scraper_graph_together.py b/examples/together/pdf_scraper_graph_together.py
index ee7a8c4b..c0f121c2 100644
--- a/examples/together/pdf_scraper_graph_together.py
+++ b/examples/together/pdf_scraper_graph_together.py
@@ -1,10 +1,9 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
-from scrapegraphai.utils import prettify_exec_info
from scrapegraphai.graphs import PDFScraperGraph
load_dotenv()
diff --git a/examples/together/rate_limit_together.py b/examples/together/rate_limit_together.py
index 072f8557..89e3f89f 100644
--- a/examples/together/rate_limit_together.py
+++ b/examples/together/rate_limit_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper with a custom rate limit
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
@@ -9,7 +8,6 @@ from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/together/scrape_plain_text_together.py b/examples/together/scrape_plain_text_together.py
index a0e222ae..feff1e3a 100644
--- a/examples/together/scrape_plain_text_together.py
+++ b/examples/together/scrape_plain_text_together.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using SmartScraper from text
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/together/script_generator_together.py b/examples/together/script_generator_together.py
index a1007cd9..cfe46c83 100644
--- a/examples/together/script_generator_together.py
+++ b/examples/together/script_generator_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorGraph
diff --git a/examples/together/script_multi_generator_together.py b/examples/together/script_multi_generator_together.py
index b9c46246..0596f1e2 100644
--- a/examples/together/script_multi_generator_together.py
+++ b/examples/together/script_multi_generator_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using ScriptCreatorGraph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import ScriptCreatorMultiGraph
diff --git a/examples/together/search_graph_schema_together.py b/examples/together/search_graph_schema_together.py
index b7d72250..c5954294 100644
--- a/examples/together/search_graph_schema_together.py
+++ b/examples/together/search_graph_schema_together.py
@@ -3,14 +3,13 @@ Example of Search Graph
"""
import os
+from typing import List
+from pydantic import BaseModel, Field
from dotenv import load_dotenv
-load_dotenv()
-
from scrapegraphai.graphs import SearchGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
-from pydantic import BaseModel, Field
-from typing import List
+load_dotenv()
# ************************************************
# Define the output schema for the graph
diff --git a/examples/together/search_graph_together.py b/examples/together/search_graph_together.py
index 9c48699b..e4c442c4 100644
--- a/examples/together/search_graph_together.py
+++ b/examples/together/search_graph_together.py
@@ -1,7 +1,6 @@
"""
Example of Search Graph
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SearchGraph
diff --git a/examples/together/smart_scraper_multi_together.py b/examples/together/smart_scraper_multi_together.py
index 278c4ba5..a2da7b8f 100644
--- a/examples/together/smart_scraper_multi_together.py
+++ b/examples/together/smart_scraper_multi_together.py
@@ -1,8 +1,8 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
-import os, json
+import os
+import json
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperMultiGraph
@@ -22,7 +22,6 @@ graph_config = {
"verbose": True,
}
-
# *******************************************************
# Create the SmartScraperMultiGraph instance and run it
# *******************************************************
diff --git a/examples/together/smart_scraper_schema_together.py b/examples/together/smart_scraper_schema_together.py
index f59a521f..45883ff0 100644
--- a/examples/together/smart_scraper_schema_together.py
+++ b/examples/together/smart_scraper_schema_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from typing import List
from pydantic import BaseModel, Field
diff --git a/examples/together/smart_scraper_together.py b/examples/together/smart_scraper_together.py
index 7408df20..c60656f2 100644
--- a/examples/together/smart_scraper_together.py
+++ b/examples/together/smart_scraper_together.py
@@ -1,7 +1,6 @@
"""
Basic example of scraping pipeline using SmartScraper
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
@@ -9,7 +8,6 @@ from scrapegraphai.utils import prettify_exec_info
load_dotenv()
-
# ************************************************
# Define the configuration for the graph
# ************************************************
diff --git a/examples/together/xml_scraper_graph_multi_together.py b/examples/together/xml_scraper_graph_multi_together.py
index 1fde5c53..d6d98a0d 100644
--- a/examples/together/xml_scraper_graph_multi_together.py
+++ b/examples/together/xml_scraper_graph_multi_together.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperMultiGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperMultiGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
diff --git a/examples/together/xml_scraper_together.py b/examples/together/xml_scraper_together.py
index 690d2cff..b1d39e2e 100644
--- a/examples/together/xml_scraper_together.py
+++ b/examples/together/xml_scraper_together.py
@@ -1,11 +1,11 @@
"""
Basic example of scraping pipeline using XMLScraperGraph from XML documents
"""
-
import os
from dotenv import load_dotenv
from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
+
load_dotenv()
# ************************************************
@@ -34,7 +34,6 @@ graph_config = {
"verbose": True,
}
-
# ************************************************
# Create the XMLScraperGraph instance and run it
# ************************************************
diff --git a/scrapegraphai/builders/graph_builder.py b/scrapegraphai/builders/graph_builder.py
index 1bfdab72..feb52ee3 100644
--- a/scrapegraphai/builders/graph_builder.py
+++ b/scrapegraphai/builders/graph_builder.py
@@ -1,7 +1,6 @@
"""
GraphBuilder Module
"""
-
from langchain_core.prompts import ChatPromptTemplate
from langchain.chains import create_extraction_chain
from langchain_community.chat_models import ErnieBotChat
@@ -100,7 +99,7 @@ class GraphBuilder:
LLMChain: An instance of the LLMChain class.
"""
- create_graph_prompt_template = """
+ create_graph_prompt_template ="""
You are an AI that designs direct graphs for web scraping tasks.
Your goal is to create a web scraping pipeline that is efficient and tailored to the user's requirements.
You have access to a set of default nodes, each with specific capabilities:
diff --git a/scrapegraphai/docloaders/browser_base.py b/scrapegraphai/docloaders/browser_base.py
index cc9e7e85..ec2a49ec 100644
--- a/scrapegraphai/docloaders/browser_base.py
+++ b/scrapegraphai/docloaders/browser_base.py
@@ -1,9 +1,11 @@
"""
browserbase integration module
"""
+import asyncio
from typing import List
-def browser_base_fetch(api_key: str, project_id: str, link: List[str], text_content: bool = True, async_mode: bool = False) -> List[str]:
+def browser_base_fetch(api_key: str, project_id: str, link: List[str],
+ text_content: bool = True, async_mode: bool = False) -> List[str]:
"""
BrowserBase Fetch
diff --git a/scrapegraphai/docloaders/chromium.py b/scrapegraphai/docloaders/chromium.py
index cb0cfd9a..80e67822 100644
--- a/scrapegraphai/docloaders/chromium.py
+++ b/scrapegraphai/docloaders/chromium.py
@@ -3,16 +3,12 @@ Chromium module
"""
import asyncio
from typing import Any, AsyncIterator, Iterator, List, Optional
-
from langchain_community.document_loaders.base import BaseLoader
from langchain_core.documents import Document
-
from ..utils import Proxy, dynamic_import, get_logger, parse_or_search_proxy
-
logger = get_logger("web-loader")
-
class ChromiumLoader(BaseLoader):
"""scrapes HTML pages from URLs using a (headless) instance of the
Chromium web driver with proxy protection
diff --git a/scrapegraphai/graphs/code_generator_graph.py b/scrapegraphai/graphs/code_generator_graph.py
index c0c0f52b..2d4bc0d5 100644
--- a/scrapegraphai/graphs/code_generator_graph.py
+++ b/scrapegraphai/graphs/code_generator_graph.py
@@ -18,8 +18,10 @@ from ..nodes import (
class CodeGeneratorGraph(AbstractGraph):
"""
- CodeGeneratorGraph is a script generator pipeline that generates the function extract_data(html: str) -> dict() for
- extracting the wanted information from a HTML page. The code generated is in Python and uses the library BeautifulSoup.
+ CodeGeneratorGraph is a script generator pipeline that generates
+ the function extract_data(html: str) -> dict() for
+ extracting the wanted information from a HTML page.
+ The code generated is in Python and uses the library BeautifulSoup.
It requires a user prompt, a source URL, and an output schema.
Attributes:
diff --git a/scrapegraphai/graphs/csv_scraper_multi_graph.py b/scrapegraphai/graphs/csv_scraper_multi_graph.py
index ee126e19..e7a028f3 100644
--- a/scrapegraphai/graphs/csv_scraper_multi_graph.py
+++ b/scrapegraphai/graphs/csv_scraper_multi_graph.py
@@ -45,9 +45,7 @@ class CSVScraperMultiGraph(AbstractGraph):
config: dict, schema: Optional[BaseModel] = None):
self.max_results = config.get("max_results", 3)
-
self.copy_config = safe_deepcopy(config)
-
self.copy_schema = deepcopy(schema)
super().__init__(prompt, config, source, schema)
diff --git a/scrapegraphai/graphs/depth_search_graph.py b/scrapegraphai/graphs/depth_search_graph.py
index 13b39129..56cb2f16 100644
--- a/scrapegraphai/graphs/depth_search_graph.py
+++ b/scrapegraphai/graphs/depth_search_graph.py
@@ -1,12 +1,11 @@
"""
-... Module
+depth search graph Module
"""
from typing import Optional
import logging
from pydantic import BaseModel
from .base_graph import BaseGraph
from .abstract_graph import AbstractGraph
-from ..utils.save_code_to_file import save_code_to_file
from ..nodes import (
FetchNodeLevelK,
ParseNodeDepthK,
diff --git a/scrapegraphai/graphs/screenshot_scraper_graph.py b/scrapegraphai/graphs/screenshot_scraper_graph.py
index 174e245a..8c67c85d 100644
--- a/scrapegraphai/graphs/screenshot_scraper_graph.py
+++ b/scrapegraphai/graphs/screenshot_scraper_graph.py
@@ -6,9 +6,9 @@ import logging
from pydantic import BaseModel
from .base_graph import BaseGraph
from .abstract_graph import AbstractGraph
-from ..nodes import ( FetchScreenNode, GenerateAnswerFromImageNode, )
+from ..nodes import (FetchScreenNode, GenerateAnswerFromImageNode)
-class ScreenshotScraperGraph(AbstractGraph):
+class ScreenshotScraperGraph(AbstractGraph):
"""
A graph instance representing the web scraping workflow for images.
diff --git a/scrapegraphai/graphs/script_creator_graph.py b/scrapegraphai/graphs/script_creator_graph.py
index 6f158403..f6a884a1 100644
--- a/scrapegraphai/graphs/script_creator_graph.py
+++ b/scrapegraphai/graphs/script_creator_graph.py
@@ -8,8 +8,7 @@ from .abstract_graph import AbstractGraph
from ..nodes import (
FetchNode,
ParseNode,
- GenerateScraperNode,
- ConditionalNode
+ GenerateScraperNode
)
class ScriptCreatorGraph(AbstractGraph):
diff --git a/scrapegraphai/graphs/smart_scraper_graph.py b/scrapegraphai/graphs/smart_scraper_graph.py
index 4a2a0a6a..60407624 100644
--- a/scrapegraphai/graphs/smart_scraper_graph.py
+++ b/scrapegraphai/graphs/smart_scraper_graph.py
@@ -10,8 +10,7 @@ from ..nodes import (
FetchNode,
ParseNode,
ReasoningNode,
- GenerateAnswerNode,
- ConditionalNode
+ GenerateAnswerNode
)
class SmartScraperGraph(AbstractGraph):
diff --git a/scrapegraphai/helpers/robots.py b/scrapegraphai/helpers/robots.py
index de49a98c..7d008df9 100644
--- a/scrapegraphai/helpers/robots.py
+++ b/scrapegraphai/helpers/robots.py
@@ -5,6 +5,8 @@ Module for mapping the models in ai agents
robots_dictionary = {
"gpt-3.5-turbo": ["GPTBot", "ChatGPT-user"],
"gpt-4-turbo": ["GPTBot", "ChatGPT-user"],
+ "gpt-4o": ["GPTBot", "ChatGPT-user"],
+ "gpt-4o-mini": ["GPTBot", "ChatGPT-user"],
"claude": ["Claude-Web", "ClaudeBot"],
"perplexity": "PerplexityBot",
"cohere": "cohere-ai",
diff --git a/scrapegraphai/integrations/burr_bridge.py b/scrapegraphai/integrations/burr_bridge.py
index 959634bb..a980395c 100644
--- a/scrapegraphai/integrations/burr_bridge.py
+++ b/scrapegraphai/integrations/burr_bridge.py
@@ -8,7 +8,6 @@ import uuid
from hashlib import md5
from typing import Any, Dict, List, Tuple
import inspect
-
try:
import burr
from burr import tracking
diff --git a/scrapegraphai/integrations/indexify_node.py b/scrapegraphai/integrations/indexify_node.py
index cf15cd0e..1089eee3 100644
--- a/scrapegraphai/integrations/indexify_node.py
+++ b/scrapegraphai/integrations/indexify_node.py
@@ -1,7 +1,6 @@
"""
IndexifyNode Module
"""
-
from typing import List, Optional
from ..utils.logging import get_logger
from ..nodes.base_node import BaseNode
diff --git a/scrapegraphai/nodes/base_node.py b/scrapegraphai/nodes/base_node.py
index 8ba55452..8b0f8064 100644
--- a/scrapegraphai/nodes/base_node.py
+++ b/scrapegraphai/nodes/base_node.py
@@ -148,11 +148,9 @@ class BaseNode(ABC):
ValueError: If the expression is invalid or if no state keys match the expression.
"""
- # Check for empty expression
if not expression:
raise ValueError("Empty expression.")
- # Check for adjacent state keys without an operator between them
pattern = (
r"\b("
+ "|".join(re.escape(key) for key in state.keys())
@@ -165,10 +163,8 @@ class BaseNode(ABC):
"Adjacent state keys found without an operator between them."
)
- # Remove spaces
expression = expression.replace(" ", "")
- # Check for operators with empty adjacent tokens or at the start/end
if (
expression[0] in "&|"
or expression[-1] in "&|"
@@ -179,7 +175,6 @@ class BaseNode(ABC):
):
raise ValueError("Invalid operator usage.")
- # Check for balanced parentheses and valid operator placement
open_parentheses = close_parentheses = 0
for i, char in enumerate(expression):
if char == "(":
diff --git a/scrapegraphai/prompts/generate_answer_node_prompts.py b/scrapegraphai/prompts/generate_answer_node_prompts.py
index 1b336fb4..edc4a6ef 100644
--- a/scrapegraphai/prompts/generate_answer_node_prompts.py
+++ b/scrapegraphai/prompts/generate_answer_node_prompts.py
@@ -2,7 +2,6 @@
Generate answer node prompts
"""
-
TEMPLATE_CHUNKS_MD = """
You are a website scraper and you have just scraped the
following content from a website converted in markdown format.
diff --git a/scrapegraphai/telemetry/telemetry.py b/scrapegraphai/telemetry/telemetry.py
index 91073e28..61af900c 100644
--- a/scrapegraphai/telemetry/telemetry.py
+++ b/scrapegraphai/telemetry/telemetry.py
@@ -14,7 +14,6 @@ To disable sending telemetry there are three ways:
or:
export SCRAPEGRAPHAI_TELEMETRY_ENABLED=false
"""
-
import configparser
import functools
import importlib.metadata
diff --git a/scrapegraphai/utils/1_manual.py b/scrapegraphai/utils/1_manual.py
deleted file mode 100644
index 21703b7b..00000000
--- a/scrapegraphai/utils/1_manual.py
+++ /dev/null
@@ -1,92 +0,0 @@
-import requests
-import logging
-import time
-from urllib.parse import quote, urljoin
-from typing import Optional
-from bs4 import BeautifulSoup
-from dotenv import load_dotenv
-import os
-import json
-import markdownify
-
-load_dotenv()
-
-logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
-
-def fetch_content(token: str, target_url: str, max_retries: int = 5, retry_delay: int = 3) -> Optional[str]:
- encoded_url = quote(target_url)
- url = f"http://api.scrape.do?url={encoded_url}&token={token}&render=true&waitUntil=networkidle0"
-
- for attempt in range(max_retries):
- try:
- response = requests.get(url)
- if response.status_code == 200:
- logging.info(f"Successfully fetched content from {target_url}")
- return response.text
- logging.warning(f"Failed with status {response.status_code}. Retrying in {retry_delay}s...")
- except requests.RequestException as e:
- logging.error(f"Error fetching {target_url}: {e}. Retrying in {retry_delay}s...")
- time.sleep(retry_delay)
-
- logging.error(f"Failed to fetch {target_url} after {max_retries} attempts.")
- return None
-
-def extract_links(html_content: str) -> list:
- soup = BeautifulSoup(html_content, 'html.parser')
- links = [link['href'] for link in soup.find_all('a', href=True)]
- logging.info(f"Extracted {len(links)} links.")
- return links
-
-def process_links(token: str, base_url: str, links: list, depth: int, current_depth: int = 1) -> dict:
- content_dict = {}
- for idx, link in enumerate(links, start=1):
- full_link = link if link.startswith("http") else urljoin(base_url, link)
- logging.info(f"Processing link {idx}: {full_link}")
- link_content = fetch_content(token, full_link)
- if link_content:
- markdown_content = markdownify.markdownify(link_content, heading_style="ATX")
- content_dict[full_link] = markdown_content
- save_content_to_json(content_dict, idx)
-
- if current_depth < depth:
- new_links = extract_links(link_content)
- content_dict.update(process_links(token, full_link, new_links, depth, current_depth + 1))
- else:
- logging.warning(f"Failed to fetch content for {full_link}")
- return content_dict
-
-def save_content_to_json(content_dict: dict, idx: int):
- if not os.path.exists("downloaded_pages"):
- os.makedirs("downloaded_pages")
-
- file_name = f"scraped_content_{idx}.json"
- file_path = os.path.join("downloaded_pages", file_name)
-
- with open(file_path, "w", encoding="utf-8") as json_file:
- json.dump(content_dict, json_file, ensure_ascii=False, indent=4)
-
- logging.info(f"Content saved to {file_path}")
-
-if __name__ == "__main__":
- token = os.getenv("TOKEN")
- target_url = "https://www.wired.com"
- depth = 2
-
- if not token or not target_url:
- logging.error("Please set the TOKEN and TARGET_URL environment variables.")
- exit(1)
-
- html_content = fetch_content(token, target_url)
-
- if html_content:
- links = extract_links(html_content)
- logging.info("Links found:")
- for link in links:
- logging.info(link)
-
- content_dict = process_links(token, target_url, links, depth)
- for link, content in content_dict.items():
- logging.info(f"Link: {link}")
- logging.info(f"Content: {content[:500]}...")
- else:
- logging.error("Failed to fetch the content.")
diff --git a/scrapegraphai/utils/code_error_analysis.py b/scrapegraphai/utils/code_error_analysis.py
index 62b56eb9..77c8efdf 100644
--- a/scrapegraphai/utils/code_error_analysis.py
+++ b/scrapegraphai/utils/code_error_analysis.py
@@ -1,6 +1,13 @@
"""
-This module contains the functions that are used to generate the prompts for the code error analysis.
+This module contains the functions that generate prompts for various types of code error analysis.
+
+Functions:
+- syntax_focused_analysis: Focuses on syntax-related errors in the generated code.
+- execution_focused_analysis: Focuses on execution-related errors, including generated code and HTML analysis.
+- validation_focused_analysis: Focuses on validation-related errors, considering JSON schema and execution result.
+- semantic_focused_analysis: Focuses on semantic differences in generated code based on a comparison result.
"""
+
from typing import Any, Dict
import json
from langchain.prompts import PromptTemplate
@@ -11,6 +18,16 @@ from ..prompts import (
)
def syntax_focused_analysis(state: dict, llm_model) -> str:
+ """
+ Analyzes the syntax errors in the generated code.
+
+ Args:
+ state (dict): Contains the 'generated_code' and 'errors' related to syntax.
+ llm_model: The language model used for generating the analysis.
+
+ Returns:
+ str: The result of the syntax error analysis.
+ """
prompt = PromptTemplate(template=TEMPLATE_SYNTAX_ANALYSIS,
input_variables=["generated_code", "errors"])
chain = prompt | llm_model | StrOutputParser()
@@ -20,6 +37,16 @@ def syntax_focused_analysis(state: dict, llm_model) -> str:
})
def execution_focused_analysis(state: dict, llm_model) -> str:
+ """
+ Analyzes the execution errors in the generated code and HTML code.
+
+ Args:
+ state (dict): Contains the 'generated_code', 'errors', 'html_code', and 'html_analysis'.
+ llm_model: The language model used for generating the analysis.
+
+ Returns:
+ str: The result of the execution error analysis.
+ """
prompt = PromptTemplate(template=TEMPLATE_EXECUTION_ANALYSIS,
input_variables=["generated_code", "errors",
"html_code", "html_analysis"])
@@ -32,6 +59,16 @@ def execution_focused_analysis(state: dict, llm_model) -> str:
})
def validation_focused_analysis(state: dict, llm_model) -> str:
+ """
+ Analyzes the validation errors in the generated code based on a JSON schema.
+
+ Args:
+ state (dict): Contains the 'generated_code', 'errors', 'json_schema', and 'execution_result'.
+ llm_model: The language model used for generating the analysis.
+
+ Returns:
+ str: The result of the validation error analysis.
+ """
prompt = PromptTemplate(template=TEMPLATE_VALIDATION_ANALYSIS,
input_variables=["generated_code", "errors",
"json_schema", "execution_result"])
@@ -43,7 +80,19 @@ def validation_focused_analysis(state: dict, llm_model) -> str:
"execution_result": state["execution_result"]
})
-def semantic_focused_analysis(state: dict, comparison_result: Dict[str, Any], llm_model) -> str:
+def semantic_focused_analysis(state: dict, comparison_result: Dict[str, Any], llm_model) -> str:
+ """
+ Analyzes the semantic differences in the generated code based on a comparison result.
+
+ Args:
+ state (dict): Contains the 'generated_code'.
+ comparison_result (Dict[str, Any]): Contains
+ 'differences' and 'explanation' of the comparison.
+ llm_model: The language model used for generating the analysis.
+
+ Returns:
+ str: The result of the semantic error analysis.
+ """
prompt = PromptTemplate(template=TEMPLATE_SEMANTIC_ANALYSIS,
input_variables=["generated_code",
"differences", "explanation"])
diff --git a/scrapegraphai/utils/code_error_correction.py b/scrapegraphai/utils/code_error_correction.py
index d70c4eef..98908360 100644
--- a/scrapegraphai/utils/code_error_correction.py
+++ b/scrapegraphai/utils/code_error_correction.py
@@ -1,6 +1,15 @@
"""
-This module contains the code generation functions for code correction for different types errors.
+This module contains the functions for code generation to correct different types of errors.
+
+Functions:
+- syntax_focused_code_generation: Generates corrected code based on syntax error analysis.
+- execution_focused_code_generation: Generates corrected code based on execution error analysis.
+- validation_focused_code_generation: Generates corrected code based on
+validation error analysis, considering JSON schema.
+- semantic_focused_code_generation: Generates corrected code based on semantic error analysis,
+comparing generated and reference results.
"""
+
import json
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import StrOutputParser
@@ -10,6 +19,17 @@ from ..prompts import (
)
def syntax_focused_code_generation(state: dict, analysis: str, llm_model) -> str:
+ """
+ Generates corrected code based on syntax error analysis.
+
+ Args:
+ state (dict): Contains the 'generated_code'.
+ analysis (str): The analysis of the syntax errors.
+ llm_model: The language model used for generating the corrected code.
+
+ Returns:
+ str: The corrected code.
+ """
prompt = PromptTemplate(template=TEMPLATE_SYNTAX_CODE_GENERATION,
input_variables=["analysis", "generated_code"])
chain = prompt | llm_model | StrOutputParser()
@@ -19,6 +39,17 @@ def syntax_focused_code_generation(state: dict, analysis: str, llm_model) -> str
})
def execution_focused_code_generation(state: dict, analysis: str, llm_model) -> str:
+ """
+ Generates corrected code based on execution error analysis.
+
+ Args:
+ state (dict): Contains the 'generated_code'.
+ analysis (str): The analysis of the execution errors.
+ llm_model: The language model used for generating the corrected code.
+
+ Returns:
+ str: The corrected code.
+ """
prompt = PromptTemplate(template=TEMPLATE_EXECUTION_CODE_GENERATION,
input_variables=["analysis", "generated_code"])
chain = prompt | llm_model | StrOutputParser()
@@ -28,9 +59,19 @@ def execution_focused_code_generation(state: dict, analysis: str, llm_model) ->
})
def validation_focused_code_generation(state: dict, analysis: str, llm_model) -> str:
+ """
+ Generates corrected code based on validation error analysis.
+
+ Args:
+ state (dict): Contains the 'generated_code' and 'json_schema'.
+ analysis (str): The analysis of the validation errors.
+ llm_model: The language model used for generating the corrected code.
+
+ Returns:
+ str: The corrected code.
+ """
prompt = PromptTemplate(template=TEMPLATE_VALIDATION_CODE_GENERATION,
- input_variables=["analysis", "generated_code",
- "json_schema"])
+ input_variables=["analysis", "generated_code", "json_schema"])
chain = prompt | llm_model | StrOutputParser()
return chain.invoke({
"analysis": analysis,
@@ -39,9 +80,19 @@ def validation_focused_code_generation(state: dict, analysis: str, llm_model) ->
})
def semantic_focused_code_generation(state: dict, analysis: str, llm_model) -> str:
+ """
+ Generates corrected code based on semantic error analysis.
+
+ Args:
+ state (dict): Contains the 'generated_code', 'execution_result', and 'reference_answer'.
+ analysis (str): The analysis of the semantic differences.
+ llm_model: The language model used for generating the corrected code.
+
+ Returns:
+ str: The corrected code.
+ """
prompt = PromptTemplate(template=TEMPLATE_SEMANTIC_CODE_GENERATION,
- input_variables=["analysis", "generated_code",
- "generated_result", "reference_result"])
+ input_variables=["analysis", "generated_code", "generated_result", "reference_result"])
chain = prompt | llm_model | StrOutputParser()
return chain.invoke({
"analysis": analysis,
diff --git a/scrapegraphai/utils/convert_to_csv.py b/scrapegraphai/utils/convert_to_csv.py
index 850f9416..e0664541 100644
--- a/scrapegraphai/utils/convert_to_csv.py
+++ b/scrapegraphai/utils/convert_to_csv.py
@@ -12,7 +12,8 @@ def convert_to_csv(data: dict, filename: str, position: str = None) -> None:
Args:
data (dict): The data to be converted into CSV format.
filename (str): The name of the output CSV file, without the '.csv' extension.
- position (str, optional): The file path where the CSV should be saved. Defaults to the directory of the caller script if not provided.
+ position (str, optional): The file path where the CSV should be saved.
+ Defaults to the directory of the caller script if not provided.
Returns:
None: The function does not return anything.
diff --git a/scrapegraphai/utils/dict_content_compare.py b/scrapegraphai/utils/dict_content_compare.py
index ddebbbc3..5ab4be41 100644
--- a/scrapegraphai/utils/dict_content_compare.py
+++ b/scrapegraphai/utils/dict_content_compare.py
@@ -1,9 +1,27 @@
"""
-Utility functions for comparing the content of two dictionaries.
+This module contains utility functions for comparing the content of two dictionaries.
+
+Functions:
+- normalize_dict: Recursively normalizes the values in a dictionary,
+converting strings to lowercase and stripping whitespace.
+- normalize_list: Recursively normalizes the values in a list,
+converting strings to lowercase and stripping whitespace.
+- are_content_equal: Compares two dictionaries for semantic equality after normalization.
"""
+
from typing import Any, Dict, List
def normalize_dict(d: Dict[str, Any]) -> Dict[str, Any]:
+ """
+ Recursively normalizes the values in a dictionary.
+
+ Args:
+ d (Dict[str, Any]): The dictionary to normalize.
+
+ Returns:
+ Dict[str, Any]: A normalized dictionary with strings converted
+ to lowercase and stripped of whitespace.
+ """
normalized = {}
for key, value in d.items():
if isinstance(value, str):
@@ -17,6 +35,15 @@ def normalize_dict(d: Dict[str, Any]) -> Dict[str, Any]:
return normalized
def normalize_list(lst: List[Any]) -> List[Any]:
+ """
+ Recursively normalizes the values in a list.
+
+ Args:
+ lst (List[Any]): The list to normalize.
+
+ Returns:
+ List[Any]: A normalized list with strings converted to lowercase and stripped of whitespace.
+ """
return [
normalize_dict(item) if isinstance(item, dict)
else normalize_list(item) if isinstance(item, list)
@@ -26,5 +53,14 @@ def normalize_list(lst: List[Any]) -> List[Any]:
]
def are_content_equal(generated_result: Dict[str, Any], reference_result: Dict[str, Any]) -> bool:
- """Compare two dictionaries for semantic equality."""
- return normalize_dict(generated_result) == normalize_dict(reference_result)
\ No newline at end of file
+ """
+ Compares two dictionaries for semantic equality after normalization.
+
+ Args:
+ generated_result (Dict[str, Any]): The generated result dictionary.
+ reference_result (Dict[str, Any]): The reference result dictionary.
+
+ Returns:
+ bool: True if the normalized dictionaries are equal, False otherwise.
+ """
+ return normalize_dict(generated_result) == normalize_dict(reference_result)
diff --git a/scrapegraphai/utils/llm_callback_manager.py b/scrapegraphai/utils/llm_callback_manager.py
index 86a4de83..77e66c02 100644
--- a/scrapegraphai/utils/llm_callback_manager.py
+++ b/scrapegraphai/utils/llm_callback_manager.py
@@ -1,5 +1,8 @@
"""
-This module provides a custom callback manager for the LLM models.
+This module provides a custom callback manager for LLM models.
+
+Classes:
+- CustomLLMCallbackManager: Manages exclusive access to callbacks for different types of LLM models.
"""
import threading
@@ -12,31 +15,43 @@ from .custom_callback import get_custom_callback
class CustomLLMCallbackManager:
"""
- custom LLLM calback class
+ CustomLLMCallbackManager class provides a mechanism to acquire a callback for LLM models
+ in an exclusive, thread-safe manner.
+
+ Attributes:
+ _lock (threading.Lock): Ensures that only one callback can be acquired at a time.
+
+ Methods:
+ exclusive_get_callback: A context manager that yields the appropriate callback based on
+ the LLM model and its name, ensuring exclusive access to the callback.
"""
_lock = threading.Lock()
@contextmanager
def exclusive_get_callback(self, llm_model, llm_model_name):
+ """
+ Provides an exclusive callback for the LLM model in a thread-safe manner.
+
+ Args:
+ llm_model: The LLM model instance (e.g., ChatOpenAI, AzureChatOpenAI, ChatBedrock).
+ llm_model_name (str): The name of the LLM model, used for model-specific callbacks.
+
+ Yields:
+ The appropriate callback for the LLM model, or None if the lock is unavailable.
+ """
if CustomLLMCallbackManager._lock.acquire(blocking=False):
- if isinstance(llm_model, ChatOpenAI) or isinstance(llm_model, AzureChatOpenAI):
- try:
+ try:
+ if isinstance(llm_model, ChatOpenAI) or isinstance(llm_model, AzureChatOpenAI):
with get_openai_callback() as cb:
yield cb
- finally:
- CustomLLMCallbackManager._lock.release()
- elif isinstance(llm_model, ChatBedrock) and \
- llm_model_name is not None and "claude" in llm_model_name:
- try:
+ elif isinstance(llm_model, ChatBedrock) and llm_model_name is not None \
+ and "claude" in llm_model_name:
with get_bedrock_anthropic_callback() as cb:
yield cb
- finally:
- CustomLLMCallbackManager._lock.release()
- else:
- try:
+ else:
with get_custom_callback(llm_model_name) as cb:
yield cb
- finally:
- CustomLLMCallbackManager._lock.release()
+ finally:
+ CustomLLMCallbackManager._lock.release()
else:
yield None
diff --git a/scrapegraphai/utils/schema_trasform.py b/scrapegraphai/utils/schema_trasform.py
index 49e67ee0..7a6d96de 100644
--- a/scrapegraphai/utils/schema_trasform.py
+++ b/scrapegraphai/utils/schema_trasform.py
@@ -20,7 +20,8 @@ def transform_schema(pydantic_schema):
if value['type'] == 'array':
if '$ref' in value['items']:
ref_key = value['items']['$ref'].split('/')[-1]
- result[key] = [process_properties(pydantic_schema['$defs'][ref_key]['properties'])]
+ result[key] = [process_properties(
+ pydantic_schema['$defs'][ref_key]['properties'])]
else:
result[key] = [value['items']['type']]
else:
diff --git a/scrapegraphai/utils/split_text_into_chunks.py b/scrapegraphai/utils/split_text_into_chunks.py
index 22204e40..5584bf0b 100644
--- a/scrapegraphai/utils/split_text_into_chunks.py
+++ b/scrapegraphai/utils/split_text_into_chunks.py
@@ -31,7 +31,7 @@ def split_text_into_chunks(text: str, chunk_size: int,
memoize=False)
return chunks
- else:
+ else:
tokens = num_tokens_calculus(text, model)
if tokens <= chunk_size:
diff --git a/scrapegraphai/utils/tokenizer.py b/scrapegraphai/utils/tokenizer.py
index 78006dda..f6650672 100644
--- a/scrapegraphai/utils/tokenizer.py
+++ b/scrapegraphai/utils/tokenizer.py
@@ -11,7 +11,6 @@ def num_tokens_calculus(string: str, llm_model: BaseChatModel) -> int:
"""
Returns the number of tokens in a text string.
"""
-
if isinstance(llm_model, ChatOpenAI):
from .tokenizers.tokenizer_openai import num_tokens_openai
num_tokens_fn = num_tokens_openai