File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed 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 )
You can’t perform that action at this time.
0 commit comments