ScrapeGraphAI / Scrapegraph-ai

Python scraper based on AI
https://scrapegraphai.com
MIT License
14.35k stars 1.17k forks source link

AttributeError: 'SmartScraperGraph' object has no attribute 'model_token' #103

Closed waqaskhan137 closed 4 months ago

waqaskhan137 commented 4 months ago

Describe the bug I just followed the instruction and ran the example and getting the following error

I have verified ollama is running and I can use the models using ollama-webui

I am using following models and those are downloaded and working in webui

ollama/gemma:2b ollama/nomic-embed-text"

image

Traceback (most recent call last):
  File "/home/leo/dev/projs/scrapegraph/main.py", line 16, in <module>
    smart_scraper_graph = SmartScraperGraph(
                          ^^^^^^^^^^^^^^^^^^
  File "/home/leo/dev/projs/scrapegraph/.venv/lib/python3.11/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 24, in __init__
    super().__init__(prompt, config, source)
  File "/home/leo/dev/projs/scrapegraph/.venv/lib/python3.11/site-packages/scrapegraphai/graphs/abstract_graph.py", line 25, in __init__
    self.graph = self._create_graph()
                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/leo/dev/projs/scrapegraph/.venv/lib/python3.11/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 39, in _create_graph
    node_config={"chunk_size": self.model_token}
                               ^^^^^^^^^^^^^^^^
AttributeError: 'SmartScraperGraph' object has no attribute 'model_token'

Process finished with exit code 1

To Reproduce Steps to reproduce the behavior:

  1. Run Ollama using docker
  2. copy paste the example
  3. install scrapegraphai
  4. See error

Expected behavior It should work seamlessly

Screenshots If applicable, add screenshots to help explain your problem. image

Desktop (please complete the following information):

VinciGit00 commented 4 months ago

Hi, we did on the branch, just wait till the deployment is done The configuration is the following: `""" Basic example of scraping pipeline using SmartScraper """ from scrapegraphai.graphs import SmartScraperGraph from scrapegraphai.utils import prettify_exec_info

****

Define the configuration for the graph

****

graph_config = { "llm": { "model": "ollama/gemma", "temperature": 0, "format": "json", # Ollama needs the format to be specified explicitly

"model_tokens": 2000, # set context length arbitrarily,

    "base_url": "http://localhost:11434",  # set ollama URL arbitrarily
},
"embeddings": {
    "model": "ollama/nomic-embed-text",
    "temperature": 0,
    "base_url": "http://localhost:11434",  # set ollama URL arbitrarily
}

}

****

Create the SmartScraperGraph instance and run it

****

smart_scraper_graph = SmartScraperGraph( prompt="List me all the news with their description.",

also accepts a string with the already downloaded HTML code

source="https://perinim.github.io/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))`, When we make the next deploy you can use it, just wait

Screenshot 2024-04-29 alle 11 05 35
waqaskhan137 commented 4 months ago

@VinciGit00 Thank for the prompt response. When will be the next deployment or version release?

if you are referring to scrapegraphai==0.4.1 this version still have the issue.

image