Skip to content

Commit c0d26d6

Browse files
committed
ad bedrocl
1 parent 28ab8da commit c0d26d6

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""
2+
Smartscraper example on bedrock
3+
"""
4+
import boto3
5+
6+
from scrapegraphai.graphs import SmartScraperGraph
7+
8+
# 0a. Initialize session
9+
# If not required delete it
10+
session = boto3.Session(
11+
aws_access_key_id="...",
12+
aws_secret_access_key="...",
13+
aws_session_token="...",
14+
region_name="us-east-1"
15+
)
16+
17+
# 0b. Initialize client
18+
client = session.client("bedrock-runtime")
19+
20+
# 1. Define graph configuration
21+
config = {
22+
"llm": {
23+
"client": client,
24+
"model": "bedrock/anthropic.claude-3-sonnet-20240229-v1:0",
25+
"temperature": 0.0,
26+
"format": "json"
27+
},
28+
"embeddings": {
29+
"client": client,
30+
"model": "bedrock/cohere.embed-multilingual-v3",
31+
},
32+
}
33+
34+
# 2. Create graph instance
35+
graph = SmartScraperGraph(
36+
prompt="List me all the articles",
37+
source="https://perinim.github.io/projects",
38+
config=config
39+
)
40+
41+
# 3. Scrape away!
42+
print(graph.run())

examples/local_models/Ollama/smart_scraper_ollama.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
graph_config = {
1111
"llm": {
12-
"model": "ollama/llama3",
12+
"model": "ollama/mistral",
1313
"temperature": 0,
1414
"format": "json", # Ollama needs the format to be specified explicitly
1515
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
@@ -27,9 +27,9 @@
2727
# ************************************************
2828

2929
smart_scraper_graph = SmartScraperGraph(
30-
prompt="List me all the projects with their description.",
30+
prompt="List me all the titles",
3131
# also accepts a string with the already downloaded HTML code
32-
source="https://perinim.github.io/projects",
32+
source="https://www.wired.com/",
3333
config=graph_config
3434
)
3535

0 commit comments

Comments
 (0)