Skip to content

Input to PromptTemplate is missing variables - while trying out examples #939

Open
@raiden076

Description

@raiden076

version==1.40.1

Describe the bug
i am trying to execute the SmartScraperGraph with schema defined and recieving these errors

Error during chain execution: 'Input to PromptTemplate is missing variables {'"properties"', '"foo"', '"$defs"'}. Expected: ['"$defs"', '"foo"', '"properties"', 'question'] Received: ['question']\nNote: if you intended {"properties"} to be part of the string and not a variable, please escape it with double curly braces like: '{{"properties"}}'.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT '
Traceback (most recent call last):

To Reproduce
Steps to reproduce the behavior:
follow this example https://docs-oss.scrapegraphai.com/docs/Examples/Groq/smart_scraper_schema_groq

Expected behavior
expected to recieve data as given pydantic model

detailed error

.venvarkaprav0@Book:~/salesup/icp-filter$ /home/arkaprav0/salesup/icp-filter/.venv/bin/python /home/arkaprav0/salesup/icp-filter/app-test.py
Max input tokens for model groq/llama-3.2-3b-preview not found,
                    please specify the model_tokens parameter in the llm section of the graph configuration.
                    Using default token size: 8192
Error during chain execution: 'Input to PromptTemplate is missing variables {\'"properties"\', \'"foo"\', \'"$defs"\'}.  Expected: [\'"$defs"\', \'"foo"\', \'"properties"\', \'question\'] Received: [\'question\']\nNote: if you intended {"properties"} to be part of the string and not a variable, please escape it with double curly braces like: \'{{"properties"}}\'.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT '
Traceback (most recent call last):
  File "/home/arkaprav0/salesup/icp-filter/app-test.py", line 61, in <module>
    result = smart_scraper_graph.run()
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 296, in run
    self.final_state, self.execution_info = self.graph.execute(inputs)
                                            ~~~~~~~~~~~~~~~~~~^^^^^^^^
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/graphs/base_graph.py", line 358, in execute
    return self._execute_standard(initial_state)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/graphs/base_graph.py", line 303, in _execute_standard
    raise e
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/graphs/base_graph.py", line 276, in _execute_standard
    result, node_exec_time, cb_data = self._execute_node(
                                      ~~~~~~~~~~~~~~~~~~^
        current_node, state, llm_model, llm_model_name
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/graphs/base_graph.py", line 200, in _execute_node
    result = current_node.execute(state)
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 209, in execute
    answer = self.invoke_with_timeout(
        chain, {"question": user_prompt}, self.timeout
    )
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 79, in invoke_with_timeout
    response = chain.invoke(inputs)
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 3022, in invoke
    input = context.run(step.invoke, input, config, **kwargs)
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/prompts/base.py", line 210, in invoke
    return self._call_with_config(
           ~~~~~~~~~~~~~~~~~~~~~~^
        self._format_prompt_with_error_handling,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<3 lines>...
        serialized=self._serialized,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/runnables/base.py", line 1922, in _call_with_config
    context.run(
    ~~~~~~~~~~~^
        call_func_with_variable_args,  # type: ignore[arg-type]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        **kwargs,
        ^^^^^^^^^
    ),
    ^
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/runnables/config.py", line 396, in call_func_with_variable_args
    return func(input, **kwargs)  # type: ignore[call-arg]
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/prompts/base.py", line 184, in _format_prompt_with_error_handling
    _inner_input = self._validate_input(inner_input)
  File "/home/arkaprav0/salesup/icp-filter/.venv/lib/python3.13/site-packages/langchain_core/prompts/base.py", line 178, in _validate_input
    raise KeyError(
        create_message(message=msg, error_code=ErrorCode.INVALID_PROMPT_INPUT)
    )
KeyError: 'Input to PromptTemplate is missing variables {\'"properties"\', \'"foo"\', \'"$defs"\'}.  Expected: [\'"$defs"\', \'"foo"\', \'"properties"\', \'question\'] Received: [\'question\']\nNote: if you intended {"properties"} to be part of the string and not a variable, please escape it with double curly braces like: \'{{"properties"}}\'.\nFor troubleshooting, visit: https://python.langchain.com/docs/troubleshooting/errors/INVALID_PROMPT_INPUT '
.venvarkaprav0@Book:~/salesup/icp-filter$ 

code i am using

"""
Basic example of scraping pipeline using SmartScraper with schema
"""
import os
from typing import List
from pydantic import BaseModel, Field
from dotenv import load_dotenv
from scrapegraphai.graphs import SmartScraperGraph
from scrapegraphai.utils import prettify_exec_info

load_dotenv()

# ************************************************
# Define the output schema for the graph
# ************************************************

class Project(BaseModel):
    title: str = Field(description="The title of the project")
    description: str = Field(description="The description of the project")

class Projects(BaseModel):
    projects: List[Project]

# ************************************************
# Define the configuration for the graph
# ************************************************

groq_key = os.getenv("GROQ_APIKEY")

graph_config = {
    "llm": {
        "model": "groq/llama-3.2-3b-preview",
        "api_key": groq_key,
        "temperature": 0
    },
        "loader_kwargs": {
        # https://github.com/microsoft/playwright/issues/14023
    "args": ["--disable-gpu", "--disable-dev-shm-usage"],
    },
    "headless": False
}

# ************************************************
# Create the SmartScraperGraph instance and run it
# ************************************************

smart_scraper_graph = SmartScraperGraph(
    prompt="List me all the projects with their description.",
    # also accepts a string with the already downloaded HTML code
    source="https://perinim.github.io/projects/",
    schema=Projects,
    config=graph_config
)

result = smart_scraper_graph.run()
print(result)

# ************************************************
# Get graph execution info
# ************************************************

graph_exec_info = smart_scraper_graph.get_execution_info()
print(prettify_exec_info(graph_exec_info))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions