Skip to content

Commit

Permalink
ad bedrocl
Browse files Browse the repository at this point in the history
  • Loading branch information
VinciGit00 committed May 13, 2024
1 parent 28ab8da commit c0d26d6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
42 changes: 42 additions & 0 deletions examples/bedrock/smart_scraper_bedrock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Smartscraper example on bedrock
"""
import boto3

from scrapegraphai.graphs import SmartScraperGraph

# 0a. Initialize session
# If not required delete it
session = boto3.Session(
aws_access_key_id="...",
aws_secret_access_key="...",
aws_session_token="...",
region_name="us-east-1"
)

# 0b. Initialize client
client = session.client("bedrock-runtime")

# 1. Define graph configuration
config = {
"llm": {
"client": client,
"model": "bedrock/anthropic.claude-3-sonnet-20240229-v1:0",
"temperature": 0.0,
"format": "json"
},
"embeddings": {
"client": client,
"model": "bedrock/cohere.embed-multilingual-v3",
},
}

# 2. Create graph instance
graph = SmartScraperGraph(
prompt="List me all the articles",
source="https://perinim.github.io/projects",
config=config
)

# 3. Scrape away!
print(graph.run())
6 changes: 3 additions & 3 deletions examples/local_models/Ollama/smart_scraper_ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

graph_config = {
"llm": {
"model": "ollama/llama3",
"model": "ollama/mistral",
"temperature": 0,
"format": "json", # Ollama needs the format to be specified explicitly
# "base_url": "http://localhost:11434", # set ollama URL arbitrarily
Expand All @@ -27,9 +27,9 @@
# ************************************************

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

Expand Down

0 comments on commit c0d26d6

Please sign in to comment.