Skip to content

Commit fe9570b

Browse files
authored
Merge pull request #895 from Telsho/main
fix: Schema parameter type
2 parents 67de52a + 2b5bd80 commit fe9570b

25 files changed

+102
-52
lines changed

scrapegraphai/graphs/abstract_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import uuid
77
import warnings
88
from abc import ABC, abstractmethod
9-
from typing import Optional
9+
from typing import Optional, Type
1010

1111
from langchain.chat_models import init_chat_model
1212
from langchain_core.rate_limiters import InMemoryRateLimiter
@@ -51,7 +51,7 @@ def __init__(
5151
prompt: str,
5252
config: dict,
5353
source: Optional[str] = None,
54-
schema: Optional[BaseModel] = None,
54+
schema: Optional[Type[BaseModel]] = None,
5555
):
5656
if config.get("llm").get("temperature") is None:
5757
config["llm"]["temperature"] = 0

scrapegraphai/graphs/code_generator_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SmartScraperGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -56,7 +56,11 @@ class CodeGeneratorGraph(AbstractGraph):
5656
"""
5757

5858
def __init__(
59-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
59+
self,
60+
prompt: str,
61+
source: str,
62+
config: dict,
63+
schema: Optional[Type[BaseModel]] = None,
6064
):
6165
super().__init__(prompt, config, source, schema)
6266

scrapegraphai/graphs/csv_scraper_graph.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module for creating the smart scraper
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -22,7 +22,7 @@ class CSVScraperGraph(AbstractGraph):
2222
config (dict): Additional configuration parameters needed by some nodes in the graph.
2323
2424
Methods:
25-
__init__ (prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None):
25+
__init__ (prompt: str, source: str, config: dict, schema: Optional[Type[BaseModel]] = None):
2626
Initializes the CSVScraperGraph with a prompt, source, and configuration.
2727
2828
__init__ initializes the CSVScraperGraph class. It requires the user's prompt as input,
@@ -49,7 +49,11 @@ class CSVScraperGraph(AbstractGraph):
4949
"""
5050

5151
def __init__(
52-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
52+
self,
53+
prompt: str,
54+
source: str,
55+
config: dict,
56+
schema: Optional[Type[BaseModel]] = None,
5357
):
5458
"""
5559
Initializes the CSVScraperGraph with a prompt, source, and configuration.

scrapegraphai/graphs/csv_scraper_multi_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import List, Optional
6+
from typing import List, Optional, Type
77

88
from pydantic import BaseModel
99

@@ -47,7 +47,7 @@ def __init__(
4747
prompt: str,
4848
source: List[str],
4949
config: dict,
50-
schema: Optional[BaseModel] = None,
50+
schema: Optional[Type[BaseModel]] = None,
5151
):
5252

5353
self.copy_config = safe_deepcopy(config)

scrapegraphai/graphs/depth_search_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
depth search graph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -54,7 +54,11 @@ class DepthSearchGraph(AbstractGraph):
5454
"""
5555

5656
def __init__(
57-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
57+
self,
58+
prompt: str,
59+
source: str,
60+
config: dict,
61+
schema: Optional[Type[BaseModel]] = None,
5862
):
5963
super().__init__(prompt, config, source, schema)
6064

scrapegraphai/graphs/document_scraper_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This module implements the Document Scraper Graph for the ScrapeGraphAI application.
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -44,7 +44,11 @@ class DocumentScraperGraph(AbstractGraph):
4444
"""
4545

4646
def __init__(
47-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
47+
self,
48+
prompt: str,
49+
source: str,
50+
config: dict,
51+
schema: Optional[Type[BaseModel]] = None,
4852
):
4953
super().__init__(prompt, config, source, schema)
5054

scrapegraphai/graphs/document_scraper_multi_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import List, Optional
6+
from typing import List, Optional, Type
77

88
from pydantic import BaseModel
99

@@ -47,7 +47,7 @@ def __init__(
4747
prompt: str,
4848
source: List[str],
4949
config: dict,
50-
schema: Optional[BaseModel] = None,
50+
schema: Optional[Type[BaseModel]] = None,
5151
):
5252
self.copy_config = safe_deepcopy(config)
5353
self.copy_schema = deepcopy(schema)

scrapegraphai/graphs/json_scraper_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
JSONScraperGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -42,7 +42,11 @@ class JSONScraperGraph(AbstractGraph):
4242
"""
4343

4444
def __init__(
45-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
45+
self,
46+
prompt: str,
47+
source: str,
48+
config: dict,
49+
schema: Optional[Type[BaseModel]] = None,
4650
):
4751
super().__init__(prompt, config, source, schema)
4852

scrapegraphai/graphs/json_scraper_multi_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import List, Optional
6+
from typing import List, Optional, Type
77

88
from pydantic import BaseModel
99

@@ -47,7 +47,7 @@ def __init__(
4747
prompt: str,
4848
source: List[str],
4949
config: dict,
50-
schema: Optional[BaseModel] = None,
50+
schema: Optional[Type[BaseModel]] = None,
5151
):
5252

5353
self.copy_config = safe_deepcopy(config)

scrapegraphai/graphs/omni_scraper_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
This module implements the Omni Scraper Graph for the ScrapeGraphAI application.
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -47,7 +47,11 @@ class OmniScraperGraph(AbstractGraph):
4747
"""
4848

4949
def __init__(
50-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
50+
self,
51+
prompt: str,
52+
source: str,
53+
config: dict,
54+
schema: Optional[Type[BaseModel]] = None,
5155
):
5256
self.max_images = 5 if config is None else config.get("max_images", 5)
5357

scrapegraphai/graphs/omni_search_graph.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import Optional
6+
from typing import Optional, Type
77

88
from pydantic import BaseModel
99

@@ -41,7 +41,9 @@ class OmniSearchGraph(AbstractGraph):
4141
>>> result = search_graph.run()
4242
"""
4343

44-
def __init__(self, prompt: str, config: dict, schema: Optional[BaseModel] = None):
44+
def __init__(
45+
self, prompt: str, config: dict, schema: Optional[Type[BaseModel]] = None
46+
):
4547

4648
self.max_results = config.get("max_results", 3)
4749

scrapegraphai/graphs/screenshot_scraper_graph.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ScreenshotScraperGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -21,7 +21,7 @@ class ScreenshotScraperGraph(AbstractGraph):
2121
source (str): The source URL or image link to scrape from.
2222
2323
Methods:
24-
__init__(prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None)
24+
__init__(prompt: str, source: str, config: dict, schema: Optional[Type[BaseModel]] = None)
2525
Initializes the ScreenshotScraperGraph instance with the given prompt,
2626
source, and configuration parameters.
2727
@@ -33,7 +33,11 @@ class ScreenshotScraperGraph(AbstractGraph):
3333
"""
3434

3535
def __init__(
36-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
36+
self,
37+
prompt: str,
38+
source: str,
39+
config: dict,
40+
schema: Optional[Type[BaseModel]] = None,
3741
):
3842
super().__init__(prompt, config, source, schema)
3943

scrapegraphai/graphs/script_creator_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ScriptCreatorGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -44,7 +44,11 @@ class ScriptCreatorGraph(AbstractGraph):
4444
"""
4545

4646
def __init__(
47-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
47+
self,
48+
prompt: str,
49+
source: str,
50+
config: dict,
51+
schema: Optional[Type[BaseModel]] = None,
4852
):
4953
self.library = config["library"]
5054

scrapegraphai/graphs/script_creator_multi_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import List, Optional
6+
from typing import List, Optional, Type
77

88
from pydantic import BaseModel
99

@@ -46,7 +46,7 @@ def __init__(
4646
prompt: str,
4747
source: List[str],
4848
config: dict,
49-
schema: Optional[BaseModel] = None,
49+
schema: Optional[Type[BaseModel]] = None,
5050
):
5151

5252
self.copy_config = safe_deepcopy(config)

scrapegraphai/graphs/search_graph.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from copy import deepcopy
6-
from typing import List, Optional
6+
from typing import List, Optional, Type
77

88
from pydantic import BaseModel
99

@@ -42,7 +42,9 @@ class SearchGraph(AbstractGraph):
4242
>>> print(search_graph.get_considered_urls())
4343
"""
4444

45-
def __init__(self, prompt: str, config: dict, schema: Optional[BaseModel] = None):
45+
def __init__(
46+
self, prompt: str, config: dict, schema: Optional[Type[BaseModel]] = None
47+
):
4648
self.max_results = config.get("max_results", 3)
4749

4850
self.copy_config = safe_deepcopy(config)

scrapegraphai/graphs/search_link_graph.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SearchLinkGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -36,7 +36,9 @@ class SearchLinkGraph(AbstractGraph):
3636
3737
"""
3838

39-
def __init__(self, source: str, config: dict, schema: Optional[BaseModel] = None):
39+
def __init__(
40+
self, source: str, config: dict, schema: Optional[Type[BaseModel]] = None
41+
):
4042
super().__init__("", config, source, schema)
4143

4244
self.input_key = "url" if source.startswith("http") else "local_dir"

scrapegraphai/graphs/smart_scraper_graph.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SmartScraperGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -52,7 +52,11 @@ class SmartScraperGraph(AbstractGraph):
5252
"""
5353

5454
def __init__(
55-
self, prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None
55+
self,
56+
prompt: str,
57+
source: str,
58+
config: dict,
59+
schema: Optional[Type[BaseModel]] = None,
5660
):
5761
super().__init__(prompt, config, source, schema)
5862

scrapegraphai/graphs/smart_scraper_lite_graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SmartScraperGraph Module
33
"""
44

5-
from typing import Optional
5+
from typing import Optional, Type
66

77
from pydantic import BaseModel
88

@@ -44,7 +44,7 @@ def __init__(
4444
source: str,
4545
config: dict,
4646
prompt: str = "",
47-
schema: Optional[BaseModel] = None,
47+
schema: Optional[Type[BaseModel]] = None,
4848
):
4949
super().__init__(prompt, config, source, schema)
5050

0 commit comments

Comments
 (0)