Skip to content

Commit 5ae67f5

Browse files
committed
add new groq example
1 parent cf038b3 commit 5ae67f5

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

examples/groq/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
GROQ_APIKEY= "your groq key"
1+
GROQ_APIKEY= "your groq key"
2+
OPENAI_APIKEY="your openai api key"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper
3+
"""
4+
5+
import os
6+
from dotenv import load_dotenv
7+
from scrapegraphai.graphs import SmartScraperGraph
8+
from scrapegraphai.utils import prettify_exec_info
9+
10+
load_dotenv()
11+
12+
13+
# ************************************************
14+
# Define the configuration for the graph
15+
# ************************************************
16+
17+
groq_key = os.getenv("GROQ_APIKEY")
18+
openai_key = os.getenv("OPENAI_APIKEY")
19+
20+
graph_config = {
21+
"llm": {
22+
"model": "groq/gemma-7b-it",
23+
"api_key": groq_key,
24+
"temperature": 0
25+
},
26+
"embeddings": {
27+
"api_key": openai_key,
28+
"model": "gpt-3.5-turbo",
29+
},
30+
"headless": False
31+
}
32+
33+
# ************************************************
34+
# Create the SmartScraperGraph instance and run it
35+
# ************************************************
36+
37+
smart_scraper_graph = SmartScraperGraph(
38+
prompt="List me all the projects with their description.",
39+
# also accepts a string with the already downloaded HTML code
40+
source="https://perinim.github.io/projects/",
41+
config=graph_config
42+
)
43+
44+
result = smart_scraper_graph.run()
45+
print(result)
46+
47+
# ************************************************
48+
# Get graph execution info
49+
# ************************************************
50+
51+
graph_exec_info = smart_scraper_graph.get_execution_info()
52+
print(prettify_exec_info(graph_exec_info))

0 commit comments

Comments
 (0)