TheProtaganist / gpt-j

A GPT-J API to use with python3 to generate text, blogs, code, and more
MIT License
205 stars 52 forks source link

JSONDecodeError when trying to execute basic and advanced python scripts #12

Open NamburiSrinath opened 1 year ago

NamburiSrinath commented 1 year ago

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.pyand 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

TheProtaganist commented 1 year ago

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.

kiritoyu commented 1 year ago

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

anrahman4 commented 1 year ago

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) 
NamburiSrinath commented 1 year ago

I am unable to find any fix so far!