Skip to content

Python scraper based on AI

handling the agent model

VinciGit009b9a9f204ce7
diff --git a/examples/benchmarks/SmartScraper/benchmark_docker.py b/examples/benchmarks/SmartScraper/benchmark_docker.py
index b38a3540..e5754c4b 100644
--- a/examples/benchmarks/SmartScraper/benchmark_docker.py
+++ b/examples/benchmarks/SmartScraper/benchmark_docker.py
@@ -2,7 +2,6 @@
Basic example of scraping pipeline using SmartScraper from text
"""
-import os
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info
diff --git a/scrapegraphai/helpers/robots.py b/scrapegraphai/helpers/robots.py
index 420a9ebd..e89d203d 100644
--- a/scrapegraphai/helpers/robots.py
+++ b/scrapegraphai/helpers/robots.py
@@ -5,7 +5,7 @@ Module for mapping the models in ai agents
robots_dictionary = {
"gpt-3.5-turbo": ["GPTBot", "ChatGPT-user"],
"gpt-4-turbo": ["GPTBot", "ChatGPT-user"],
- "claude": "Claude-Web",
+ "claude": ["Claude-Web", "ClaudeBot"],
"perplexity": "PerplexityBot",
"cohere": "cohere-ai",
"anthropic": "anthropic-ai"
diff --git a/scrapegraphai/nodes/rag_node.py b/scrapegraphai/nodes/rag_node.py
index b5d5433f..fc19c700 100644
--- a/scrapegraphai/nodes/rag_node.py
+++ b/scrapegraphai/nodes/rag_node.py
@@ -9,9 +9,9 @@ from langchain.retrievers.document_compressors import EmbeddingsFilter, Document
from langchain_community.document_transformers import EmbeddingsRedundantFilter
from langchain_community.embeddings import HuggingFaceHubEmbeddings
from langchain_community.vectorstores import FAISS
+from langchain_community.embeddings import OllamaEmbeddings
from langchain_openai import OpenAIEmbeddings, AzureOpenAIEmbeddings
from ..models import OpenAI, Ollama, AzureOpenAI, HuggingFace
-from langchain_community.embeddings import OllamaEmbeddings
from .base_node import BaseNode
@@ -97,7 +97,7 @@ class RAGNode(BaseNode):
# remove streaming and temperature
params.pop("streaming", None)
params.pop("temperature", None)
-
+
embeddings = OllamaEmbeddings(**params)
elif isinstance(embedding_model, HuggingFace):
embeddings = HuggingFaceHubEmbeddings(model=embedding_model.model)
diff --git a/scrapegraphai/nodes/robots_node.py b/scrapegraphai/nodes/robots_node.py
index 1b5178dc..1bf58206 100644
--- a/scrapegraphai/nodes/robots_node.py
+++ b/scrapegraphai/nodes/robots_node.py
@@ -102,11 +102,17 @@ class RobotsNode(BaseNode):
document = loader.load()
- # TODO: look at the agent
- agent = "TODO"
- # mandare la richiesta
- # if errore -> manda l'eccezione
- # poi faccio un return
+ model = self.llm_model["model"]
+
+ if "ollama" in model:
+ model = model.split("/", maxsplit=1)[-1]
+
+ try:
+ agent = robots_dictionary[model]
+
+ except KeyError:
+ agent = model
+
prompt = PromptTemplate(
template=template,
partial_variables={"context": document,