ScrapeGraphAI/Scrapegraph-ai · error · ImportError
langchain_google_genai is not installed. Please install it u
Error message
langchain_google_genai is not installed. Please install it using 'pip install langchain-google-genai'.
What it means
GenerateAnswerNode raises this ValueError when state['user_prompt'] is empty or absent. The node needs the user's question to build the {'content': ..., 'question': ...} chain input, so a graph instantiated without a prompt (or with an empty string) fails here.
Source
Thrown at scrapegraphai/builders/graph_builder.py:75
Returns:
OpenAI: An instance of the OpenAI class.
Raises:
ValueError: If 'api_key' is not provided in llm_config.
"""
llm_defaults = {"temperature": 0, "streaming": True}
llm_params = {**llm_defaults, **llm_config}
if "api_key" not in llm_params:
raise ValueError("LLM configuration must include an 'api_key'.")
if "gpt-" in llm_params["model"]:
return ChatOpenAI(llm_params)
elif "gemini" in llm_params["model"]:
try:
from langchain_google_genai import ChatGoogleGenerativeAI
except ImportError:
raise ImportError(
"langchain_google_genai is not installed. Please install it using 'pip install langchain-google-genai'."
)
return ChatGoogleGenerativeAI(llm_params)
elif "ernie" in llm_params["model"]:
return ErnieBotChat(llm_params)
raise ValueError("Model not supported")
def _generate_nodes_description(self):
"""
Generates a string description of all available nodes and their arguments.
Returns:
str: A string description of all available nodes and their arguments.
"""
return "\n".join(
[
f"""- {node}: {data["description"]} (Type: {data["type"]},View on GitHub (pinned to 532dfffbf6)
Solutions
- Pass a non-empty prompt when instantiating the graph (e.g. SmartScraperGraph(prompt="List the products", source=..., config=...)).
- If using a custom graph, ensure the entry state or a prior node sets state['user_prompt'].
- Log/inspect the initial state to confirm the key name is exactly 'user_prompt'.
Example fix
# before graph = SmartScraperGraph(prompt="", source=url, config=config) # after graph = SmartScraperGraph(prompt="Extract all product names", source=url, config=config)
Defensive patterns
Strategy: validation
Validate before calling
assert graph.prompt and graph.prompt.strip(), "prompt is required for answer generation" or simply: if not prompt: raise ValueError before constructing the graph
Type guard
def is_valid_prompt(prompt: str | None) -> bool:
return isinstance(prompt, str) and bool(prompt.strip()) Try / catch
try:
result = graph.run()
except ValueError as e:
if "No user prompt" in str(e):
# re-run with a default prompt
... Prevention
- Always pass an explicit, non-empty prompt when instantiating graphs.
- Fail fast at startup: validate the prompt argument before building the graph.
When it happens
Trigger: Creating a graph without passing the prompt argument, passing prompt="", using a custom graph that never writes 'user_prompt' into state, or a node upstream overwriting/removing the key.
Common situations: Refactoring from positional to keyword arguments and dropping prompt; building custom graphs from nodes where the initial state template omits 'user_prompt'; dynamically generating prompts that evaluate to empty strings.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- LLM configuration must include an 'api_key'.
- The 'graphviz' library is required for this functionality. P
- The browserbase module is not installed. Please install it u
- ConditionalNode '{node.node_name}' must have exactly two out
- No audio generated from the text.
AI-assisted analysis of ScrapeGraphAI/Scrapegraph-ai@532dfffbf6 (2026-08-28).
Data as JSON: /api/errors/ae0ea5493af0d1d3.
Report an issue: GitHub.