Skip to content

Commit 8b2c266

Browse files
refactoring of the code
Co-Authored-By: Matteo Vedovati <[email protected]>
1 parent d4c1a1c commit 8b2c266

38 files changed

+38
-94
lines changed

examples/local_models/smart_scraper_ollama.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@
2222
# Create the SmartScraperGraph instance and run it
2323
# ************************************************
2424
smart_scraper_graph = SmartScraperGraph(
25+
<<<<<<< Updated upstream
2526
prompt="Find some information about what does the company do, the name and a contact email.",
2627
source="https://scrapegraphai.com/",
28+
=======
29+
prompt="List all the projects with their descriptions",
30+
source="https://perinim.github.io/projects/",
31+
>>>>>>> Stashed changes
2732
config=graph_config
2833
)
2934

scrapegraphai/graphs/abstract_graph.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77
import uuid
88
import warnings
99
from pydantic import BaseModel
10-
1110
from langchain_community.chat_models import ErnieBotChat
1211
from langchain_nvidia_ai_endpoints import ChatNVIDIA
1312
from langchain.chat_models import init_chat_model
14-
1513
from ..helpers import models_tokens
1614
from ..models import (
1715
OneApi,
1816
DeepSeek
1917
)
2018
from ..utils.logging import set_verbosity_warning, set_verbosity_info
2119

22-
23-
2420
class AbstractGraph(ABC):
2521
"""
2622
Scaffolding class for creating a graph representation and executing it.

scrapegraphai/graphs/base_graph.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from typing import Tuple
77
from langchain_community.callbacks import get_openai_callback
88
from ..integrations import BurrBridge
9-
10-
# Import telemetry functions
11-
from ..telemetry import log_graph_execution, log_event
9+
from ..telemetry import log_graph_execution
1210

1311
class BaseGraph:
1412
"""

scrapegraphai/graphs/csv_scraper_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7-
87
from .base_graph import BaseGraph
98
from .abstract_graph import AbstractGraph
10-
119
from ..nodes import (
1210
FetchNode,
1311
GenerateAnswerCSVNode
1412
)
1513

16-
1714
class CSVScraperGraph(AbstractGraph):
1815
"""
1916
SmartScraper is a comprehensive web scraping tool that automates the process of extracting

scrapegraphai/graphs/csv_scraper_multi_graph.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@
44

55
from copy import copy, deepcopy
66
from typing import List, Optional
7-
87
from pydantic import BaseModel
9-
108
from .base_graph import BaseGraph
119
from .abstract_graph import AbstractGraph
1210
from .csv_scraper_graph import CSVScraperGraph
13-
1411
from ..nodes import (
1512
GraphIteratorNode,
1613
MergeAnswersNode
1714
)
1815

19-
2016
class CSVScraperMultiGraph(AbstractGraph):
2117
"""
22-
CSVScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and generates answers to a given prompt.
18+
CSVScraperMultiGraph is a scraping pipeline that
19+
scrapes a list of URLs and generates answers to a given prompt.
2320
It only requires a user prompt and a list of URLs.
2421
2522
Attributes:
@@ -44,7 +41,8 @@ class CSVScraperMultiGraph(AbstractGraph):
4441
>>> result = search_graph.run()
4542
"""
4643

47-
def __init__(self, prompt: str, source: List[str], config: dict, schema: Optional[BaseModel] = None):
44+
def __init__(self, prompt: str, source: List[str],
45+
config: dict, schema: Optional[BaseModel] = None):
4846

4947
self.max_results = config.get("max_results", 3)
5048

scrapegraphai/graphs/deep_scraper_graph.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7-
87
from .base_graph import BaseGraph
98
from .abstract_graph import AbstractGraph
10-
119
from ..nodes import (
1210
FetchNode,
1311
SearchLinkNode,
@@ -18,7 +16,6 @@
1816
MergeAnswersNode
1917
)
2018

21-
2219
class DeepScraperGraph(AbstractGraph):
2320
"""
2421
[WIP]
@@ -87,7 +84,6 @@ def _create_repeated_graph(self) -> BaseGraph:
8784
output=["relevant_chunks"],
8885
node_config={
8986
"llm_model": self.llm_model,
90-
"embedder_model": self.embedder_model
9187
}
9288
)
9389
generate_answer_node = GenerateAnswerNode(
@@ -104,7 +100,6 @@ def _create_repeated_graph(self) -> BaseGraph:
104100
output=["relevant_links"],
105101
node_config={
106102
"llm_model": self.llm_model,
107-
"embedder_model": self.embedder_model
108103
}
109104
)
110105
graph_iterator_node = GraphIteratorNode(

scrapegraphai/graphs/json_scraper_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7-
87
from .base_graph import BaseGraph
98
from .abstract_graph import AbstractGraph
10-
119
from ..nodes import (
1210
FetchNode,
1311
GenerateAnswerNode
1412
)
1513

16-
1714
class JSONScraperGraph(AbstractGraph):
1815
"""
1916
JSONScraperGraph defines a scraping pipeline for JSON files.

scrapegraphai/graphs/json_scraper_multi_graph.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,18 @@
55
from copy import copy, deepcopy
66
from typing import List, Optional
77
from pydantic import BaseModel
8-
98
from .base_graph import BaseGraph
109
from .abstract_graph import AbstractGraph
1110
from .json_scraper_graph import JSONScraperGraph
12-
1311
from ..nodes import (
1412
GraphIteratorNode,
1513
MergeAnswersNode
1614
)
1715

18-
1916
class JSONScraperMultiGraph(AbstractGraph):
2017
"""
21-
JSONScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and generates answers to a given prompt.
18+
JSONScraperMultiGraph is a scraping pipeline that scrapes a
19+
list of URLs and generates answers to a given prompt.
2220
It only requires a user prompt and a list of URLs.
2321
2422
Attributes:

scrapegraphai/graphs/markdown_scraper_multi_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
from copy import copy, deepcopy
66
from typing import List, Optional
77
from pydantic import BaseModel
8-
98
from .base_graph import BaseGraph
109
from .abstract_graph import AbstractGraph
1110
from .markdown_scraper_graph import MDScraperGraph
12-
1311
from ..nodes import (
1412
GraphIteratorNode,
1513
MergeAnswersNode
1614
)
1715

18-
1916
class MDScraperMultiGraph(AbstractGraph):
2017
"""
2118
MDScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and

scrapegraphai/graphs/omni_scraper_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7-
87
from .base_graph import BaseGraph
98
from .abstract_graph import AbstractGraph
10-
119
from ..nodes import (
1210
FetchNode,
1311
ParseNode,
1412
ImageToTextNode,
1513
GenerateAnswerOmniNode
1614
)
17-
1815
from ..models import OpenAIImageToText
1916

2017
class OmniScraperGraph(AbstractGraph):

scrapegraphai/graphs/pdf_scraper_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66
from typing import Optional
77
from pydantic import BaseModel
8-
98
from .base_graph import BaseGraph
109
from .abstract_graph import AbstractGraph
11-
1210
from ..nodes import (
1311
FetchNode,
1412
ParseNode,
1513
GenerateAnswerPDFNode
1614
)
1715

18-
1916
class PDFScraperGraph(AbstractGraph):
2017
"""
2118
PDFScraperGraph is a scraping pipeline that extracts information from pdf files using a natural

scrapegraphai/graphs/pdf_scraper_multi_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
from copy import copy, deepcopy
66
from typing import List, Optional
77
from pydantic import BaseModel
8-
98
from .base_graph import BaseGraph
109
from .abstract_graph import AbstractGraph
1110
from .pdf_scraper_graph import PDFScraperGraph
12-
1311
from ..nodes import (
1412
GraphIteratorNode,
1513
MergeAnswersNode
1614
)
1715

18-
1916
class PdfScraperMultiGraph(AbstractGraph):
2017
"""
2118
PdfScraperMultiGraph is a scraping pipeline that scrapes a

scrapegraphai/graphs/script_creator_graph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44

55
from typing import Optional
66
from pydantic import BaseModel
7-
87
from .base_graph import BaseGraph
98
from .abstract_graph import AbstractGraph
10-
119
from ..nodes import (
1210
FetchNode,
1311
ParseNode,
1412
GenerateScraperNode
1513
)
1614

17-
1815
class ScriptCreatorGraph(AbstractGraph):
1916
"""
2017
ScriptCreatorGraph defines a scraping pipeline for generating web scraping scripts.

scrapegraphai/graphs/script_creator_multi_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
MergeGeneratedScriptsNode
1717
)
1818

19-
2019
class ScriptCreatorMultiGraph(AbstractGraph):
2120
"""
22-
ScriptCreatorMultiGraph is a scraping pipeline that scrapes a list of URLs generating web scraping scripts.
21+
ScriptCreatorMultiGraph is a scraping pipeline that scrapes a list
22+
of URLs generating web scraping scripts.
2323
It only requires a user prompt and a list of URLs.
2424
Attributes:
2525
prompt (str): The user prompt to search the internet.

scrapegraphai/graphs/search_graph.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
MergeAnswersNode
1717
)
1818

19-
20-
2119
class SearchGraph(AbstractGraph):
2220
"""
2321
SearchGraph is a scraping pipeline that searches the internet for answers to a given prompt.

scrapegraphai/graphs/search_link_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
from pydantic import BaseModel
55
from .base_graph import BaseGraph
66
from .abstract_graph import AbstractGraph
7-
8-
97
from ..nodes import ( FetchNode, ParseNode, SearchLinkNode )
108

119
class SearchLinkGraph(AbstractGraph):
1210
"""
13-
SearchLinkGraph is a scraping pipeline that automates the process of extracting information from web pages using a natural language model to interpret and answer prompts.
11+
SearchLinkGraph is a scraping pipeline that automates the process of
12+
extracting information from web pages using a natural language model
13+
to interpret and answer prompts.
1414
1515
Attributes:
1616
prompt (str): The prompt for the graph.

scrapegraphai/graphs/smart_scraper_graph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
GenerateAnswerNode
1515
)
1616

17-
1817
class SmartScraperGraph(AbstractGraph):
1918
"""
2019
SmartScraper is a scraping pipeline that automates the process of

scrapegraphai/graphs/smart_scraper_multi_graph.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
MergeAnswersNode
1616
)
1717

18-
1918
class SmartScraperMultiGraph(AbstractGraph):
2019
"""
21-
SmartScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and generates answers to a given prompt.
20+
SmartScraperMultiGraph is a scraping pipeline that scrapes a
21+
list of URLs and generates answers to a given prompt.
2222
It only requires a user prompt and a list of URLs.
2323
2424
Attributes:
@@ -43,15 +43,16 @@ class SmartScraperMultiGraph(AbstractGraph):
4343
>>> result = search_graph.run()
4444
"""
4545

46-
def __init__(self, prompt: str, source: List[str], config: dict, schema: Optional[BaseModel] = None):
46+
def __init__(self, prompt: str, source: List[str],
47+
config: dict, schema: Optional[BaseModel] = None):
4748

4849
self.max_results = config.get("max_results", 3)
4950

5051
if all(isinstance(value, str) for value in config.values()):
5152
self.copy_config = copy(config)
5253
else:
5354
self.copy_config = deepcopy(config)
54-
55+
5556
self.copy_schema = deepcopy(schema)
5657

5758
super().__init__(prompt, config, source, schema)

scrapegraphai/graphs/speech_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
from ..utils.save_audio_from_bytes import save_audio_from_bytes
1919
from ..models import OpenAITextToSpeech
2020

21-
2221
class SpeechGraph(AbstractGraph):
2322
"""
24-
SpeechyGraph is a scraping pipeline that scrapes the web, provide an answer to a given prompt, and generate an audio file.
23+
SpeechyGraph is a scraping pipeline that scrapes the web, provide an answer
24+
to a given prompt, and generate an audio file.
2525
2626
Attributes:
2727
prompt (str): The prompt for the graph.

scrapegraphai/graphs/xml_scraper_graph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
GenerateAnswerNode
1414
)
1515

16-
1716
class XMLScraperGraph(AbstractGraph):
1817
"""
1918
XMLScraperGraph is a scraping pipeline that extracts information from XML files using a natural

scrapegraphai/graphs/xml_scraper_multi_graph.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
MergeAnswersNode
1616
)
1717

18-
1918
class XMLScraperMultiGraph(AbstractGraph):
2019
"""
2120
XMLScraperMultiGraph is a scraping pipeline that scrapes a list of URLs and

scrapegraphai/nodes/conditional_node.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(self,
4242
"""
4343

4444
#super().__init__(node_name, "node", input, output, 2, node_config)
45-
45+
pass
4646

4747

4848
def execute(self, state: dict) -> dict:
@@ -56,8 +56,4 @@ def execute(self, state: dict) -> dict:
5656
str: The name of the next node to execute based on the presence of the key.
5757
"""
5858

59-
if self.key_name in state and len(state[self.key_name]) > 0:
60-
state["next_node"] = 0
61-
else:
62-
state["next_node"] = 1
63-
return state
59+
pass

0 commit comments

Comments
 (0)