Skip to content

Python scraper based on AI

fixed embedder_model config for local models

EURAC\marperini982f142f2024
diff --git a/examples/local_models/scrape_plain_text_local.py b/examples/local_models/scrape_plain_text_local.py
index 0af0a167..13f766bb 100644
--- a/examples/local_models/scrape_plain_text_local.py
+++ b/examples/local_models/scrape_plain_text_local.py
@@ -29,6 +29,10 @@ graph_config = {
"format": "json", # Ollama needs the format to be specified explicitly
# "model_tokens": 2000, # set context length arbitrarily
},
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ }
}
# ************************************************
diff --git a/examples/local_models/scrape_xml_local.py b/examples/local_models/scrape_xml_local.py
index e647fa50..4f218617 100644
--- a/examples/local_models/scrape_xml_local.py
+++ b/examples/local_models/scrape_xml_local.py
@@ -28,6 +28,10 @@ graph_config = {
"format": "json", # Ollama needs the format to be specified explicitly
# "model_tokens": 2000, # set context length arbitrarily
},
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ }
}
# ************************************************
diff --git a/examples/local_models/search_graph_local.py b/examples/local_models/search_graph_local.py
index ed01128e..59770c11 100644
--- a/examples/local_models/search_graph_local.py
+++ b/examples/local_models/search_graph_local.py
@@ -17,6 +17,10 @@ graph_config = {
"format": "json", # Ollama needs the format to be specified explicitly
# "model_tokens": 2000, # set context length arbitrarily
},
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ }
}
# ************************************************
diff --git a/examples/local_models/smart_scraper_local.py b/examples/local_models/smart_scraper_local.py
index 0869ae48..09a18fac 100644
--- a/examples/local_models/smart_scraper_local.py
+++ b/examples/local_models/smart_scraper_local.py
@@ -23,6 +23,10 @@ graph_config = {
# "model_tokens": 2000, # set context length arbitrarily,
# "base_url": "http://ollama:11434", # set ollama URL arbitrarily
},
+ "embeddings": {
+ "model": "ollama/nomic-embed-text",
+ "temperature": 0,
+ }
}
# ************************************************
diff --git a/scrapegraphai/graphs/abstract_graph.py b/scrapegraphai/graphs/abstract_graph.py
index 621d5d13..b2117855 100644
--- a/scrapegraphai/graphs/abstract_graph.py
+++ b/scrapegraphai/graphs/abstract_graph.py
@@ -73,9 +73,10 @@ class AbstractGraph(ABC):
if "model_tokens" in llm_params:
self.model_token = llm_params["model_tokens"]
elif llm_params["model"] in models_tokens["ollama"]:
- self.model_token = models_tokens["ollama"][llm_params["model"]]
- else:
- raise ValueError("Model not supported")
+ try:
+ self.model_token = models_tokens["ollama"][llm_params["model"]]
+ except KeyError:
+ raise ValueError("Model not supported")
return Ollama(llm_params)
diff --git a/scrapegraphai/graphs/smart_scraper_graph.py b/scrapegraphai/graphs/smart_scraper_graph.py
index e4c32100..baa17171 100644
--- a/scrapegraphai/graphs/smart_scraper_graph.py
+++ b/scrapegraphai/graphs/smart_scraper_graph.py
@@ -41,7 +41,10 @@ class SmartScraperGraph(AbstractGraph):
rag_node = RAGNode(
input="user_prompt & (parsed_doc | doc)",
output=["relevant_chunks"],
- node_config={"llm": self.llm_model},
+ node_config={
+ "llm": self.llm_model,
+ "embedder_model": self.embedder_model
+ }
)
generate_answer_node = GenerateAnswerNode(
input="user_prompt & (relevant_chunks | parsed_doc | doc)",
diff --git a/scrapegraphai/graphs/speech_graph.py b/scrapegraphai/graphs/speech_graph.py
index a34fa2f1..42633584 100644
--- a/scrapegraphai/graphs/speech_graph.py
+++ b/scrapegraphai/graphs/speech_graph.py
@@ -44,7 +44,10 @@ class SpeechGraph(AbstractGraph):
rag_node = RAGNode(
input="user_prompt & (parsed_doc | doc)",
output=["relevant_chunks"],
- node_config={"llm": self.llm_model},
+ node_config={
+ "llm": self.llm_model,
+ "embedder_model": self.embedder_model
+ }
)
generate_answer_node = GenerateAnswerNode(
input="user_prompt & (relevant_chunks | parsed_doc | doc)",