Skip to content

Commit 62f5165

Browse files
committed
Create serch_graph_scehma.py
1 parent 8bd8fb0 commit 62f5165

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

examples/extras/serch_graph_scehma.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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)

0 commit comments

Comments
 (0)