Scrapegraph-ai: KeyError: 'Input to PromptTemplate is missing variables
Describe the bug
I am trying to run the code example in your README but I always encounter the following error:
KeyError: 'Input to PromptTemplate is missing variables {\'"content"\'}. Expected: [\'"content"\', \'question\'] Received: [\'question\']\nNote: if you intended {"content"} to be part of the string and not a variable, please escape it with double curly braces like: \'{{"content"}}\'.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT '
To Reproduce Steps to reproduce the behavior: Copy the code example in the README and run it.
Expected behavior Not getting an error.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: WSL
- Browser Chromium
- Version 155
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
I am running with
scrapegraphai==1.39.0
from scrapegraphai.graphs import SmartScraperGraph
# Define the configuration for the scraping pipeline
graph_config = {
"llm": {"model": "ollama/llama3.2", "model_tokens": 8192},
"verbose": True,
"headless": False,
}
# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
prompt="Extract useful information from the webpage, including a description of what the company does, founders and social media links",
source="https://scrapegraphai.com/",
config=graph_config,
)
# Run the pipeline
result = smart_scraper_graph.run()
import json
print(json.dumps(result, indent=4))
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 19
- Comments: 17 (1 by maintainers)
Hey there, @amitschendel! I’m here to assist you with any bugs, questions, or contributions. Let’s tackle this issue together!
The error you’re encountering indicates that the
PromptTemplateis missing the"content"variable in its input. ThePromptTemplateexpects both"content"and"question"variables, but it seems only"question"is being provided.To resolve this issue, ensure that the
"content"variable is included in the input when initializing thePromptTemplate. Here’s a general approach to fix it:PromptTemplateis being initialized."content"and"question"are provided in theinput_variablesorpartial_variables.For example, if your code looks like this:
Ensure that
"content"is included in thepartial_variablesorinput_variablesas needed. If"content"is a fixed value, you can add it topartial_variableslike this:If
"content"is dynamic, ensure it is passed correctly when the template is used. Adjust your code accordingly to include the"content"variable.To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
I am facing the same issue, managed to work it out with downgrading the library to
scrapegraphai==1.37.0withpip3 install scrapegraphai==1.37.0its varsion from January, need to check what have changed since then.facing the same error, but with different attribute names, while running examples
KeyError: 'Input to PromptTemplate is missing variables {'“foo”', '“$defs”', '“properties”'}. Expected: ['“$defs”', '“foo”', '“properties”', 'question'] Received: ['question']\nNote: if you intended {“foo”} to be part of the string and not a variable, please escape it with double curly braces like: '{{“foo”}}'.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT ’