-
-
Notifications
You must be signed in to change notification settings - Fork 749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json.decoder.JSONDecodeError: Expecting value: line 10 column 5 (char 743) #262
Comments
Is this the complete |
i have the same problem, output actually contains json.decoder.JSONDecodeError: Expecting value: line 8 column 5 (char 703)
|
Hei @david-strejc try set the "format":"json" in the llm dict and see if you still get the error. Sometimes with local models is needed |
that works but when you crank up the max_results to more than 2, it will start throwing out some JSON errors (two is fine, prob a API issue)
|
hi, we are trying to fix it, pls install the new beta |
ok, now it should be ok. check the main please and update it |
david @ blackbox:Programming/searchgraphai $ python first_try.py
Traceback (most recent call last):
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/output_parsers/json.py", line 66, in parse_result
return parse_json_markdown(text)
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/utils/json.py", line 147, in parse_json_markdown
return _parse_json(json_str, parser=parser)
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/utils/json.py", line 160, in _parse_json
return parser(json_str)
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/utils/json.py", line 120, in parse_partial_json
return json.loads(s, strict=strict)
File "/usr/lib/python3.10/json/init.py", line 359, in loads
return cls(**kw).decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 10 column 5 (char 743)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/david/Work/Programming/searchgraphai/first_try.py", line 24, in
result = search_graph.run()
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/graphs/search_graph.py", line 120, in run
self.final_state, self.execution_info = self.graph.execute(inputs)
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/graphs/base_graph.py", line 107, in execute
result = current_node.execute(state)
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/nodes/graph_iterator_node.py", line 73, in execute
state = asyncio.run(self._async_execute(state, batchsize))
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/nodes/graph_iterator_node.py", line 128, in _async_execute
answers = await tqdm.gather(
File "/home/david/.local/lib/python3.10/site-packages/tqdm/asyncio.py", line 79, in gather
res = [await f for f in cls.as_completed(ifs, loop=loop, timeout=timeout,
File "/home/david/.local/lib/python3.10/site-packages/tqdm/asyncio.py", line 79, in
res = [await f for f in cls.as_completed(ifs, loop=loop, timeout=timeout,
File "/usr/lib/python3.10/asyncio/tasks.py", line 571, in _wait_for_one
return f.result() # May raise f.exception().
File "/home/david/.local/lib/python3.10/site-packages/tqdm/asyncio.py", line 76, in wrap_awaitable
return i, await f
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/nodes/graph_iterator_node.py", line 117, in _async_run
return await asyncio.to_thread(graph.run)
File "/usr/lib/python3.10/asyncio/threads.py", line 25, in to_thread
return await loop.run_in_executor(None, func_call)
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/graphs/smart_scraper_graph.py", line 112, in run
self.final_state, self.execution_info = self.graph.execute(inputs)
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/graphs/base_graph.py", line 107, in execute
result = current_node.execute(state)
File "/home/david/.local/lib/python3.10/site-packages/scrapegraphai/nodes/generate_answer_node.py", line 135, in execute
answer = map_chain.invoke({"question": user_prompt})
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3142, in invoke
output = {key: future.result() for key, future in zip(steps, futures)}
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 3142, in
output = {key: future.result() for key, future in zip(steps, futures)}
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 451, in result
return self.__get_result()
File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 2499, in invoke
input = step.invoke(
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/output_parsers/base.py", line 169, in invoke
return self._call_with_config(
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/runnables/base.py", line 1626, in _call_with_config
context.run(
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/runnables/config.py", line 347, in call_func_with_variable_args
return func(input, **kwargs) # type: ignore[call-arg]
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/output_parsers/base.py", line 170, in
lambda inner_input: self.parse_result(
File "/home/david/.local/lib/python3.10/site-packages/langchain_core/output_parsers/json.py", line 69, in parse_result
raise OutputParserException(msg, llm_output=text) from e
langchain_core.exceptions.OutputParserException: Invalid json output: Here is the JSON object:
david @ blackbox:Programming/searchgraphai $
david @ blackbox:Programming/searchgraphai $
david @ blackbox:Programming/searchgraphai $
david @ blackbox:Programming/searchgraphai $ cat first_try.py
from scrapegraphai.graphs import SearchGraph
Define the configuration for the graph
graph_config = {
"llm": {
"model": "groq/llama3-8b-8192",
"api_key": "",
"temperature": 0
},
"embeddings": {
"model": "ollama/nomic-embed-text",
"base_url": "http://localhost:11434", # set ollama URL arbitrarily
},
"max_results": 5,
}
Create the SearchGraph instance
search_graph = SearchGraph(
prompt="List me all the traditional recipes from Chioggia",
config=graph_config
)
Run the graph
result = search_graph.run()
print(result)
david @ blackbox:Programming/searchgraphai $
The text was updated successfully, but these errors were encountered: