Skip to content

Python scraper based on AI

Merge pull request #126 from VinciGit00/bedrock_support

Marco Vinciguerra579a27faf976
diff --cc scrapegraphai/graphs/abstract_graph.py
index 7949c114,12c3c39a..b8a9efe9
--- a/scrapegraphai/graphs/abstract_graph.py
+++ b/scrapegraphai/graphs/abstract_graph.py
@@@ -1,10 -1,10 +1,11 @@@
"""
-Module having abstract class for creating all the graphs
+AbstractGraph Module
"""
+
from abc import ABC, abstractmethod
from typing import Optional
- from ..models import OpenAI, Gemini, Ollama, AzureOpenAI, HuggingFace, Groq
+
+ from ..models import OpenAI, Gemini, Ollama, AzureOpenAI, HuggingFace, Groq, Bedrock
from ..helpers import models_tokens
diff --cc scrapegraphai/helpers/models_tokens.py
index 73a3999f,28d1af14..3105929c
--- a/scrapegraphai/helpers/models_tokens.py
+++ b/scrapegraphai/helpers/models_tokens.py
@@@ -46,6 -43,22 +46,23 @@@ models_tokens =
"claude2": 9000,
"claude2.1": 200000,
"claude3": 200000
+ },
+ "bedrock": {
+ "anthropic.claude-3-haiku-20240307-v1:0": 200000,
+ "anthropic.claude-3-sonnet-20240229-v1:0": 200000,
+ "anthropic.claude-3-opus-20240229-v1:0": 200000,
+ "anthropic.claude-v2:1": 200000,
+ "anthropic.claude-v2": 100000,
+ "anthropic.claude-instant-v1": 100000,
+ "meta.llama3-8b-instruct-v1:0": 8192,
+ "meta.llama3-70b-instruct-v1:0": 8192,
+ "meta.llama2-13b-chat-v1": 4096,
+ "meta.llama2-70b-chat-v1": 4096,
+ "mistral.mistral-7b-instruct-v0:2": 32768,
+ "mistral.mixtral-8x7b-instruct-v0:1": 32768,
+ "mistral.mistral-large-2402-v1:0": 32768,
+ "cohere.embed-english-v3": 512,
+ "cohere.embed-multilingual-v3": 512
}
}
+
diff --cc scrapegraphai/nodes/rag_node.py
index d3842742,64221743..92e7011f
--- a/scrapegraphai/nodes/rag_node.py
+++ b/scrapegraphai/nodes/rag_node.py
@@@ -35,15 -38,18 +37,16 @@@ class RAGNode(BaseNode)
"""
def __init__(self, input: str, output: List[str], node_config: dict, node_name: str = "RAG"):
- """
- Initializes the ParseHTMLNode with a node name.
- """
super().__init__(node_name, "node", input, output, 2, node_config)
+
self.llm_model = node_config["llm"]
self.embedder_model = node_config.get("embedder_model", None)
- self.verbose = True if node_config is None else node_config.get("verbose", False)
+ self.verbose = True if node_config is None else node_config.get(
+ "verbose", False)
- def execute(self, state):
+ def execute(self, state: dict) -> dict:
"""
- Executes the node's logic to implement RAG (Retrieval-Augmented Generation)
+ Executes the node's logic to implement RAG (Retrieval-Augmented Generation).
The method updates the state with relevant chunks of the document.
Args: