Skip to content

Even a simplest request with schema doesn't work #788

@pkit

Description

@pkit
import json

from pydantic import BaseModel
from scrapegraphai.graphs import SmartScraperGraph

# Define the configuration for the scraping pipeline
graph_config = {
    "llm": {
        "api_key": "sk-key",
        "model": "openai/gpt-4o-mini",
    },
    "verbose": True,
    "headless": True,
}

class CompanyDetails(BaseModel):
    name: str
    description: str
    email: str


# Create the SmartScraperGraph instance
smart_scraper_graph = SmartScraperGraph(
    prompt="Find some information about what does the company do, the name and a contact email.",
    source="https://theraiderteam.com/",
    config=graph_config,
    schema=CompanyDetails,
)

# Run the pipeline
result = smart_scraper_graph.run()
print(json.dumps(result, indent=4))

Fails miserably with

Traceback (most recent call last):
  File "/..../test.py", line 31, in <module>
    result = smart_scraper_graph.run()
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 212, in run
    self.final_state, self.execution_info = self.graph.execute(inputs)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 327, in execute
    return self._execute_standard(initial_state)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 274, in _execute_standard
    raise e
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 247, in _execute_standard
    result, node_exec_time, cb_data = self._execute_node(
                                      ^^^^^^^^^^^^^^^^^^^
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/graphs/base_graph.py", line 172, in _execute_node
    result = current_node.execute(state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/..../.venv/lib/python3.11/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 129, in execute
    answer = output_parser.parse(raw_response.content)
             ^^^^^^^^^^^^^^^^^^^
AttributeError: 'function' object has no attribute 'parse'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions