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):

0 commit comments

Comments
 (0)