22SmartScraperGraph Module
33"""
44
5+ from typing import Optional
6+
57from .base_graph import BaseGraph
8+ from .abstract_graph import AbstractGraph
9+
610from ..nodes import (
711 FetchNode ,
812 ParseNode ,
913 RAGNode ,
1014 GenerateAnswerNode
1115)
12- from .abstract_graph import AbstractGraph
1316
1417
1518class SmartScraperGraph (AbstractGraph ):
@@ -22,6 +25,7 @@ class SmartScraperGraph(AbstractGraph):
2225 prompt (str): The prompt for the graph.
2326 source (str): The source of the graph.
2427 config (dict): Configuration parameters for the graph.
28+ schema (str): The schema for the graph output.
2529 llm_model: An instance of a language model client, configured for generating answers.
2630 embedder_model: An instance of an embedding model client,
2731 configured for generating embeddings.
@@ -32,6 +36,7 @@ class SmartScraperGraph(AbstractGraph):
3236 prompt (str): The prompt for the graph.
3337 source (str): The source of the graph.
3438 config (dict): Configuration parameters for the graph.
39+ schema (str): The schema for the graph output.
3540
3641 Example:
3742 >>> smart_scraper = SmartScraperGraph(
@@ -43,8 +48,8 @@ class SmartScraperGraph(AbstractGraph):
4348 )
4449 """
4550
46- def __init__ (self , prompt : str , source : str , config : dict ):
47- super ().__init__ (prompt , config , source )
51+ def __init__ (self , prompt : str , source : str , config : dict , schema : Optional [ str ] = None ):
52+ super ().__init__ (prompt , config , source , schema )
4853
4954 self .input_key = "url" if source .startswith ("http" ) else "local_dir"
5055
@@ -81,7 +86,8 @@ def _create_graph(self) -> BaseGraph:
8186 input = "user_prompt & (relevant_chunks | parsed_doc | doc)" ,
8287 output = ["answer" ],
8388 node_config = {
84- "llm_model" : self .llm_model
89+ "llm_model" : self .llm_model ,
90+ "schema" : self .schema ,
8591 }
8692 )
8793
0 commit comments