Skip to content

Commit 2b5bd80

Browse files
committed
fix: Schema parameter type
1 parent aa6a76e commit 2b5bd80

25 files changed

+102
-52
lines changed

scrapegraphai/graphs/abstract_graph.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 7 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 6 additions & 2 deletions
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

0 commit comments

Comments
 (0)