File tree Expand file tree Collapse file tree 8 files changed +44
-84
lines changed Expand file tree Collapse file tree 8 files changed +44
-84
lines changed Original file line number Diff line number Diff line change 77load_dotenv ()
88
99from scrapegraphai .graphs import SearchGraph
10- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
1110
1211from pydantic import BaseModel , Field
1312from typing import List
@@ -45,14 +44,3 @@ class Dishes(BaseModel):
4544
4645result = search_graph .run ()
4746print (result )
48-
49- # ************************************************
50- # Get graph execution info
51- # ************************************************
52-
53- graph_exec_info = search_graph .get_execution_info ()
54- print (prettify_exec_info (graph_exec_info ))
55-
56- # Save to json and csv
57- convert_to_csv (result , "result" )
58- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 44
55from dotenv import load_dotenv
66from scrapegraphai .graphs import SearchGraph
7- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
87
98load_dotenv ()
109
3332
3433result = search_graph .run ()
3534print (result )
36-
37- # ************************************************
38- # Get graph execution info
39- # ************************************************
40-
41- graph_exec_info = search_graph .get_execution_info ()
42- print (prettify_exec_info (graph_exec_info ))
43-
44- # Save to json and csv
45- convert_to_csv (result , "result" )
46- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 55import os
66from dotenv import load_dotenv
77from scrapegraphai .graphs import SearchGraph
8- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
98load_dotenv ()
109
1110# ************************************************
4039
4140result = search_graph .run ()
4241print (result )
43-
44- # ************************************************
45- # Get graph execution info
46- # ************************************************
47-
48- graph_exec_info = search_graph .get_execution_info ()
49- print (prettify_exec_info (graph_exec_info ))
50-
51- # Save to json and csv
52- convert_to_csv (result , "result" )
53- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 55import os
66from dotenv import load_dotenv
77from scrapegraphai .graphs import SearchGraph
8- from scrapegraphai . utils import convert_to_csv , convert_to_json , prettify_exec_info
8+
99load_dotenv ()
1010
1111# ************************************************
3434
3535result = search_graph .run ()
3636print (result )
37-
38- # ************************************************
39- # Get graph execution info
40- # ************************************************
41-
42- graph_exec_info = search_graph .get_execution_info ()
43- print (prettify_exec_info (graph_exec_info ))
44-
45- # Save to json and csv
46- convert_to_csv (result , "result" )
47- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 1+ """
2+ Example of Search Graph
3+ """
4+
5+ import os
6+ from dotenv import load_dotenv
7+ from scrapegraphai .graphs import SearchGraph
8+ from pydantic import BaseModel , Field
9+ from typing import List
10+ load_dotenv ()
11+
12+ # ************************************************
13+ # Define the configuration for the graph
14+ # ************************************************
15+ class CeoName (BaseModel ):
16+ ceo_name : str = Field (description = "The name and surname of the ceo" )
17+
18+ class Ceos (BaseModel ):
19+ names : List [CeoName ]
20+
21+ openai_key = os .getenv ("OPENAI_APIKEY" )
22+
23+ graph_config = {
24+ "llm" : {
25+ "api_key" : openai_key ,
26+ "model" : "gpt-4o" ,
27+ },
28+ "max_results" : 2 ,
29+ "verbose" : True ,
30+ }
31+
32+ # ************************************************
33+ # Create the SearchGraph instance and run it
34+ # ************************************************
35+
36+ search_graph = SearchGraph (
37+ prompt = f"Who is the ceo of Appke?" ,
38+ schema = Ceos ,
39+ config = graph_config ,
40+ )
41+
42+ result = search_graph .run ()
43+ print (result )
Original file line number Diff line number Diff line change 55import os
66from dotenv import load_dotenv
77from scrapegraphai .graphs import SearchGraph
8- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
98
109load_dotenv ()
1110
4342
4443result = search_graph .run ()
4544print (result )
46-
47- # ************************************************
48- # Get graph execution info
49- # ************************************************
50-
51- graph_exec_info = search_graph .get_execution_info ()
52- print (prettify_exec_info (graph_exec_info ))
53-
54- # Save to json and csv
55- convert_to_csv (result , "result" )
56- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 33"""
44
55from scrapegraphai .graphs import SearchGraph
6- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
76
87# ************************************************
98# Define the configuration for the graph
2928
3029result = search_graph .run ()
3130print (result )
32-
33- # ************************************************
34- # Get graph execution info
35- # ************************************************
36-
37- graph_exec_info = search_graph .get_execution_info ()
38- print (prettify_exec_info (graph_exec_info ))
39-
40- # Save to json and csv
41- convert_to_csv (result , "result" )
42- convert_to_json (result , "result" )
Original file line number Diff line number Diff line change 55import os
66from dotenv import load_dotenv
77from scrapegraphai .graphs import SearchGraph
8- from scrapegraphai .utils import convert_to_csv , convert_to_json , prettify_exec_info
98load_dotenv ()
109
1110# ************************************************
3433
3534result = search_graph .run ()
3635print (result )
37-
38- # ************************************************
39- # Get graph execution info
40- # ************************************************
41-
42- graph_exec_info = search_graph .get_execution_info ()
43- print (prettify_exec_info (graph_exec_info ))
44-
45- # Save to json and csv
46- convert_to_csv (result , "result" )
47- convert_to_json (result , "result" )
You can’t perform that action at this time.
0 commit comments