Scrapegraph-ai icon indicating copy to clipboard operation
Scrapegraph-ai copied to clipboard

I'm executing it according to the examples provided in the document, but it will report an error.

Open gxin0426 opened this issue 11 months ago • 3 comments

--- Executing Fetch Node --- --- (Fetching HTML from: https://scrapegraphai.com/) --- --- Executing ParseNode Node --- --- Executing GenerateAnswer Node --- Error during chain execution: '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 ' Traceback (most recent call last): File "/Users/xg/project/py-project/scrape/scrape2.py", line 21, in result = smart_scraper_graph.run() ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 296, in run self.final_state, self.execution_info = self.graph.execute(inputs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 358, in execute return self._execute_standard(initial_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 303, in _execute_standard raise e File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 276, in _execute_standard result, node_exec_time, cb_data = self._execute_node( ^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 200, in _execute_node result = current_node.execute(state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 178, in execute answer = self.invoke_with_timeout( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 79, in invoke_with_timeout response = chain.invoke(inputs) ^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 3022, in invoke input = context.run(step.invoke, input, config, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/prompts/base.py", line 210, in invoke return self._call_with_config( ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1922, in _call_with_config context.run( File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable_args return func(input, **kwargs) # type: ignore[call-arg] ^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/prompts/base.py", line 184, in _format_prompt_with_error_handling _inner_input = self._validate_input(inner_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/xg/project/py-project/ENTER/envs/scrape/lib/python3.11/site-packages/langchain_core/prompts/base.py", line 178, in _validate_input raise KeyError( 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 '

gxin0426 avatar Feb 21 '25 03:02 gxin0426

Hey @gxin0426! How can I assist you today? I'm here to help you with bug fixes, answer questions, and guide you on contributing.

To resolve the "INVALID_PROMPT_INPUT" error in LangChain when executing the smart_scraper_graph, ensure that all required variables are provided to the PromptTemplate. Specifically, the error indicates that the 'content' variable is missing. You should verify that the PromptTemplate is correctly receiving both the 'content' and 'question' variables.

Here are some steps you can take:

  1. Check the PromptTemplate: Ensure that the PromptTemplate is correctly defined and that both 'content' and 'question' are included in the inputs.

  2. Provide All Required Variables: Make sure that when you are executing the graph, both 'content' and 'question' are being passed to the PromptTemplate.

  3. Escape Curly Braces: If 'content' is intended to be a part of the string and not a variable, escape it with double curly braces like {{"content"}}.

  4. Inspect Inputs: Use logging or debugging tools to inspect the inputs being passed to the PromptTemplate to ensure they are correct.

If the error persists, consider downgrading the scrapegraphai library to version 1.37.0, as this has been a solution for similar issues in the past:

pip install scrapegraphai==1.37.0

This approach should help you resolve the error and ensure that the PromptTemplate receives all necessary inputs [1].

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

dosubot[bot] avatar Feb 21 '25 03:02 dosubot[bot]

After creating a virtual environment and running in version 1.37.0, following error pops up:

File "...Scrapegraph-ai/camilo/lib/python3.11/site-packages/httpx/_transports/default.py", line 118, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 61] Connection refused

Thank you

cecabrera avatar Feb 24 '25 14:02 cecabrera

Please update to the new version

VinciGit00 avatar Mar 01 '25 20:03 VinciGit00

Hi, @gxin0426. I'm Dosu, and I'm helping the Scrapegraph-ai team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You reported an error with the GenerateAnswer Node due to a missing 'content' variable in the PromptTemplate.
  • I suggested ensuring all required variables are provided and recommended downgrading to version 1.37.0.
  • After downgrading, cecabrera encountered a connection error.
  • VinciGit00 suggested updating to a newer version as a potential solution.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of the Scrapegraph-ai repository by commenting here.
  • If there is no further activity, this issue will be automatically closed in 7 days.

Thank you for your understanding and contribution!

dosubot[bot] avatar May 31 '25 16:05 dosubot[bot]