gpt-j icon indicating copy to clipboard operation
gpt-j copied to clipboard

JSONDecodeError when trying to execute basic and advanced python scripts

Open NamburiSrinath opened this issue 2 years ago • 4 comments

Can you update how to fix this issue?

I am working on GPT-J to generate prompts and I am unable to run the code.

During handling of the above exception, another exception occurred:

I am getting the following error when I tried running python basic_usage_template.py and python advanced_usage_template.py

Traceback (most recent call last):
  File "/hdd2/srinath/gpt-j/advanced_usage_template.py", line 58, in <module>
    response = context_setting.completion(prompt,
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/gpt_j/gptj_api.py", line 67, in completion
    self.response = generate(f"{self.new_prompt} {user}: {self.main_intention}", token_max_length=max_tokens, temperature=temperature, top_p=top_p, top_k=top_k, rep=rep)
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/gpt_j/Gptj.py", line 12, in generate
    result = URL.json()
  File "/hdd2/srinath/anaconda3/envs/SD_Aug/lib/python3.10/site-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

My python version is 3.10.6

NamburiSrinath avatar Nov 03 '22 21:11 NamburiSrinath

Try https://www.banana.dev/ I'm sorry tried to create an open source libary for python although it looks like it's very hard to find a working gptj api.

TheProtaganist avatar Nov 10 '22 14:11 TheProtaganist

how to fix it?i run demo throw the same exception.

kiritoyu avatar Mar 04 '23 03:03 kiritoyu

I am also trying to run the basic usage and also have the same error posted by @NamburiSrinath.

Is there any fix to this?

Traceback (most recent call last):
  File "C:\Users\rahmaa\PycharmProjects\chatgpt\venv\lib\site-packages\requests\models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
  File "C:\Users\rahmaa\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\rahmaa\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\rahmaa\AppData\Local\Programs\Python\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rahmaa\PycharmProjects\chatgpt\venv\test.py", line 11, in <module>
    query = simple_completion(prompt, length=max_length, temp=temperature, top_p=top_probability, top_k=top_k, rep=repetition)
  File "C:\Users\rahmaa\PycharmProjects\chatgpt\venv\lib\site-packages\gpt_j\Basic_api.py", line 13, in simple_completion
    return generate(Prompt, length, temperature=temp, top_p=top_p, top_k=top_k, rep=rep).strip() if Prompt else "Empty Prompt detected"
  File "C:\Users\rahmaa\PycharmProjects\chatgpt\venv\lib\site-packages\gpt_j\Gptj.py", line 12, in generate
    result = URL.json()
  File "C:\Users\rahmaa\PycharmProjects\chatgpt\venv\lib\site-packages\requests\models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 

anrahman4 avatar Mar 15 '23 21:03 anrahman4

I am unable to find any fix so far!

NamburiSrinath avatar May 03 '23 00:05 NamburiSrinath