Skip to content

Commit 59594cb

Browse files
committed
add grow example
1 parent e3d0194 commit 59594cb

File tree

4 files changed

+80
-2
lines changed

4 files changed

+80
-2
lines changed

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,38 @@ result = smart_scraper_graph.run()
134134
print(result)
135135
```
136136

137-
### Case 4: Extracting information using Gemini
137+
### Case 4: Extracting information using Groq
138+
```python
139+
from scrapegraphai.graphs import SmartScraperGraph
140+
from scrapegraphai.utils import prettify_exec_info
141+
142+
groq_key = os.getenv("GROQ_APIKEY")
143+
144+
graph_config = {
145+
"llm": {
146+
"model": "groq/gemma-7b-it",
147+
"api_key": groq_key,
148+
"temperature": 0
149+
},
150+
"embeddings": {
151+
"model": "ollama/nomic-embed-text",
152+
"temperature": 0,
153+
"base_url": "http://localhost:11434",
154+
},
155+
"headless": False
156+
}
157+
158+
smart_scraper_graph = SmartScraperGraph(
159+
prompt="List me all the projects with their description and the author.",
160+
source="https://perinim.github.io/projects",
161+
config=graph_config
162+
)
163+
164+
result = smart_scraper_graph.run()
165+
print(result)
166+
```
167+
168+
### Case 5: Extracting information using Gemini
138169
```python
139170
from scrapegraphai.graphs import SmartScraperGraph
140171
GOOGLE_APIKEY = "YOUR_API_KEY"

examples/groq/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GROQ_APIKEY= "your groq key"

examples/groq/smart_scraper_groq.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
19+
graph_config = {
20+
"llm": {
21+
"api_key": groq_key,
22+
"model": "groq/gemma-7b-it",
23+
},
24+
}
25+
26+
# ************************************************
27+
# Create the SmartScraperGraph instance and run it
28+
# ************************************************
29+
30+
smart_scraper_graph = SmartScraperGraph(
31+
prompt="List me all the projects with their description.",
32+
# also accepts a string with the already downloaded HTML code
33+
source="https://perinim.github.io/projects/",
34+
config=graph_config
35+
)
36+
37+
result = smart_scraper_graph.run()
38+
print(result)
39+
40+
# ************************************************
41+
# Get graph execution info
42+
# ************************************************
43+
44+
graph_exec_info = smart_scraper_graph.get_execution_info()
45+
print(prettify_exec_info(graph_exec_info))

examples/mixed_models/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
OPENAI_APIKEY="your openai api key"
22
GOOGLE_APIKEY="your google api key"
33
AZURE_OPENAI_API_KEY="your azure api key"
4-
AZURE_OPENAI_ENDPOINT="https://<your-endpoint>.openai.azure.com/"
4+
AZURE_OPENAI_ENDPOINT="https://<your-endpoint>.openai.azure.com/"
5+
GROQ_APIKEY= "your groq key"

0 commit comments

Comments
 (0)