1+ """
2+ document_scraper example
3+ """
4+ import os
5+ import json
6+ from dotenv import load_dotenv
7+ from scrapegraphai .graphs import DocumentScraperGraph
8+
9+ load_dotenv ()
10+
11+
12+ # ************************************************
13+ # Define the configuration for the graph
14+ # ************************************************
15+ deepseek_key = os .getenv ("DEEPSEEK_APIKEY" )
16+
17+ graph_config = {
18+ "llm" : {
19+ "model" : "deepseek/deepseek-chat" ,
20+ "api_key" : deepseek_key ,
21+ },
22+ "verbose" : True ,
23+ }
24+
25+
26+ source = """
27+ The Divine Comedy, Italian La Divina Commedia, original name La commedia, long narrative poem written in Italian
28+ circa 1308/21 by Dante. It is usually held to be one of the world s great works of literature.
29+ Divided into three major sections—Inferno, Purgatorio, and Paradiso—the narrative traces the journey of Dante
30+ from darkness and error to the revelation of the divine light, culminating in the Beatific Vision of God.
31+ Dante is guided by the Roman poet Virgil, who represents the epitome of human knowledge, from the dark wood
32+ through the descending circles of the pit of Hell (Inferno). He then climbs the mountain of Purgatory, guided
33+ by the Roman poet Statius, who represents the fulfilment of human knowledge, and is finally led by his lifelong love,
34+ the Beatrice of his earlier poetry, through the celestial spheres of Paradise.
35+ """
36+
37+ pdf_scraper_graph = DocumentScraperGraph (
38+ prompt = "Summarize the text and find the main topics" ,
39+ source = source ,
40+ config = graph_config ,
41+ )
42+ result = pdf_scraper_graph .run ()
43+
44+ print (json .dumps (result , indent = 4 ))
0 commit comments