1
+ """
2
+ ScreenshotScraperGraph Module
1
3
"""
2
- ScreenshotScraperGraph Module
3
- """
4
-
5
4
from typing import Optional
6
5
import logging
7
6
from pydantic import BaseModel
8
7
from .base_graph import BaseGraph
9
8
from .abstract_graph import AbstractGraph
9
+ from ..nodes import ( FetchScreenNode , GenerateAnswerFromImageNode , )
10
10
11
- from ..nodes import (
12
- FetchScreenNode ,
13
- GenerateAnswerFromImageNode ,
14
- )
11
+ class ScreenshotScraperGraph (AbstractGraph ):
12
+ """
13
+ A graph instance representing the web scraping workflow for images.
15
14
16
- class ScreenshotScraperGraph (AbstractGraph ):
17
- """
18
- smart_scraper.run()
19
- )
15
+ Attributes:
16
+ prompt (str): The input text to be scraped.
17
+ config (dict): Configuration parameters for the graph.
18
+ source (str): The source URL or image link to scrape from.
19
+
20
+ Methods:
21
+ __init__(prompt: str, source: str, config: dict, schema: Optional[BaseModel] = None)
22
+ Initializes the ScreenshotScraperGraph instance with the given prompt,
23
+ source, and configuration parameters.
24
+
25
+ _create_graph()
26
+ Creates a graph of nodes representing the web scraping workflow for images.
27
+
28
+ run()
29
+ Executes the scraping process and returns the answer to the prompt.
20
30
"""
21
31
22
32
def __init__ (self , prompt : str , source : str , config : dict , schema : Optional [BaseModel ] = None ):
@@ -25,10 +35,10 @@ def __init__(self, prompt: str, source: str, config: dict, schema: Optional[Base
25
35
26
36
def _create_graph (self ) -> BaseGraph :
27
37
"""
28
- Creates the graph of nodes representing the workflow for web scraping.
38
+ Creates the graph of nodes representing the workflow for web scraping with images .
29
39
30
40
Returns:
31
- BaseGraph: A graph instance representing the web scraping workflow.
41
+ BaseGraph: A graph instance representing the web scraping workflow for images .
32
42
"""
33
43
fetch_screen_node = FetchScreenNode (
34
44
input = "url" ,
@@ -38,8 +48,8 @@ def _create_graph(self) -> BaseGraph:
38
48
}
39
49
)
40
50
generate_answer_from_image_node = GenerateAnswerFromImageNode (
41
- input = "doc " ,
42
- output = ["parsed_doc " ],
51
+ input = "imgs " ,
52
+ output = ["answer " ],
43
53
node_config = {
44
54
"config" : self .config
45
55
}
0 commit comments