ScrapeGraphAI / Scrapegraph-ai

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

SearchGraph error while follwing the example #425

Closed dwk601 closed 2 months ago

dwk601 commented 3 months ago
from search_graph import SearchGraph

# Define the prompt and configuration
prompt = "What is Chioggia famous for?"
config = {
    "llm": {"model": "gpt-3.5-turbo"}
}

# Create the search graph
search_graph = SearchGraph(prompt, config)

# Run the search graph
result = search_graph.run()

print(result)

this gives this error even I didn't modified the code. any idea how to fix this error?

Exception has occurred: OutputParserException
Invalid json output: {
    "answer": {
        "Chioggia is famous for offering a more authentic Italian experience compared to Venice, having a significant fishing industry and a rich history tied to the Venetian Republic, featuring a must-visit fish market with a wide variety of fresh seafood, and providing an excellent dining experience at Baia dei Porci with a focus on local seafood dishes."
    }
}
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 4 column 5 (char 382)

The above exception was the direct cause of the following exception:

  File "/home/dongwook/Project/auto_crawl/toy.py", line 18, in <module>
    raw_result = search_graph.run()
langchain_core.exceptions.OutputParserException: Invalid json output: {
    "answer": {
        "Chioggia is famous for offering a more authentic Italian experience compared to Venice, having a significant fishing industry and a rich history tied to the Venetian Republic, featuring a must-visit fish market with a wide variety of fresh seafood, and providing an excellent dining experience at Baia dei Porci with a focus on local seafood dishes."
    }
}
f-aguzzi commented 3 months ago

GPT 3.5 is outputting invalid JSON and it causes issues with the LangChain response parser.

Try manually changing the temperature of the model:

config = {
    "llm": {
        "model": "gpt-3.5-turbo",
        "temperature": 0
    }
}

If this doesn't work, try raising it slightly, to something like 0.01 or 0.05.

dwk601 commented 3 months ago

It still didn't fix the issue, even I change the temperature of the llm

Exception has occurred: OutputParserException
Invalid json output: {
    "answer": {
        "Chioggia is famous for being an alternative to Venice for a more authentic Italian experience, with fewer tourists and genuine locals, having a significant fishing industry and a rich history tied to the Venetian Republic, hosting the largest fish market in the Adriatic offering a wide variety of fresh seafood, featuring the recommended restaurant Baia dei Porci for its atmosphere and delicious food at reasonable prices, and being located near Sottomarina which has a long beach and historical sea defenses."
    }
}
json.decoder.JSONDecodeError: Expecting ':' delimiter: line 4 column 5 (char 544)

The above exception was the direct cause of the following exception:

  File "/home/dongwook/Project/auto_crawl/toy.py", line 21, in <module>
    raw_result = search_graph.run()
langchain_core.exceptions.OutputParserException: Invalid json output: {
    "answer": {
        "Chioggia is famous for being an alternative to Venice for a more authentic Italian experience, with fewer tourists and genuine locals, having a significant fishing industry and a rich history tied to the Venetian Republic, hosting the largest fish market in the Adriatic offering a wide variety of fresh seafood, featuring the recommended restaurant Baia dei Porci for its atmosphere and delicious food at reasonable prices, and being located near Sottomarina which has a long beach and historical sea defenses."
    }
}
VinciGit00 commented 2 months ago

hi, have you tried with other models?

VinciGit00 commented 2 months ago
Screenshot 2024-07-23 alle 18 28 58

because on ollama works