{"record":{"id":"ae0ea5493af0d1d3","repo":"ScrapeGraphAI/Scrapegraph-ai","slug":"langchain-google-genai-is-not-installed-please-in","errorCode":null,"errorMessage":"langchain_google_genai is not installed. Please install it using 'pip install langchain-google-genai'.","messagePattern":"langchain_google_genai is not installed\\. Please install it using 'pip install langchain-google-genai'\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"scrapegraphai/builders/graph_builder.py","lineNumber":75,"sourceCode":"\n        Returns:\n            OpenAI: An instance of the OpenAI class.\n\n        Raises:\n            ValueError: If 'api_key' is not provided in llm_config.\n        \"\"\"\n        llm_defaults = {\"temperature\": 0, \"streaming\": True}\n        llm_params = {**llm_defaults, **llm_config}\n        if \"api_key\" not in llm_params:\n            raise ValueError(\"LLM configuration must include an 'api_key'.\")\n\n        if \"gpt-\" in llm_params[\"model\"]:\n            return ChatOpenAI(llm_params)\n        elif \"gemini\" in llm_params[\"model\"]:\n            try:\n                from langchain_google_genai import ChatGoogleGenerativeAI\n            except ImportError:\n                raise ImportError(\n                    \"langchain_google_genai is not installed. Please install it using 'pip install langchain-google-genai'.\"\n                )\n            return ChatGoogleGenerativeAI(llm_params)\n        elif \"ernie\" in llm_params[\"model\"]:\n            return ErnieBotChat(llm_params)\n        raise ValueError(\"Model not supported\")\n\n    def _generate_nodes_description(self):\n        \"\"\"\n        Generates a string description of all available nodes and their arguments.\n\n        Returns:\n            str: A string description of all available nodes and their arguments.\n        \"\"\"\n\n        return \"\\n\".join(\n            [\n                f\"\"\"- {node}: {data[\"description\"]} (Type: {data[\"type\"]},","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/ScrapeGraphAI/Scrapegraph-ai/blob/532dfffbf6ee823a6c9cf8cfedc24a93bf026780/scrapegraphai/builders/graph_builder.py#L57-L93","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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'."],"exampleFix":"# before\ngraph = SmartScraperGraph(prompt=\"\", source=url, config=config)\n\n# after\ngraph = SmartScraperGraph(prompt=\"Extract all product names\", source=url, config=config)","handlingStrategy":"validation","validationCode":"assert graph.prompt and graph.prompt.strip(), \"prompt is required for answer generation\" or simply: if not prompt: raise ValueError before constructing the graph","typeGuard":"def is_valid_prompt(prompt: str | None) -> bool:\n    return isinstance(prompt, str) and bool(prompt.strip())","tryCatchPattern":"try:\n    result = graph.run()\nexcept ValueError as e:\n    if \"No user prompt\" in str(e):\n        # re-run with a default prompt\n        ...","preventionTips":["Always pass an explicit, non-empty prompt when instantiating graphs.","Fail fast at startup: validate the prompt argument before building the graph."],"tags":["prompt","state","validation","graph-pipeline"],"backgroundTag":"missing-required-parameter","analyzedSha":"532dfffbf6ee823a6c9cf8cfedc24a93bf026780","analyzedAt":"2026-08-28T15:19:38.821Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}