1+ """
2+ ScreenshotScraperGraph Module
13"""
2- ScreenshotScraperGraph Module
3- """
4-
54from typing import Optional
65import logging
76from pydantic import BaseModel
87from .base_graph import BaseGraph
98from .abstract_graph import AbstractGraph
9+ from ..nodes import ( FetchScreenNode , GenerateAnswerFromImageNode , )
1010
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.
1514
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.
2030 """
2131
2232 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
2535
2636 def _create_graph (self ) -> BaseGraph :
2737 """
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 .
2939
3040 Returns:
31- BaseGraph: A graph instance representing the web scraping workflow.
41+ BaseGraph: A graph instance representing the web scraping workflow for images .
3242 """
3343 fetch_screen_node = FetchScreenNode (
3444 input = "url" ,
@@ -38,8 +48,8 @@ def _create_graph(self) -> BaseGraph:
3848 }
3949 )
4050 generate_answer_from_image_node = GenerateAnswerFromImageNode (
41- input = "doc " ,
42- output = ["parsed_doc " ],
51+ input = "imgs " ,
52+ output = ["answer " ],
4353 node_config = {
4454 "config" : self .config
4555 }
0 commit comments