nathanrchn / perplexityai

A python api to use perplexity.ai
233 stars 60 forks source link

again json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #36

Open LexiestLeszek opened 12 months ago

LexiestLeszek commented 12 months ago

I deployed flask app to vercel and once i submit a form, it returns internal server error:

[ERROR] 2023-12-09T11:10:22.812Z 2caf4f59-d74e-48db-ae5a-af1126340cad Exception on / [POST] Traceback (most recent call last): File "/var/task/flask/app.py", line 1455, in wsgi_app response = self.full_dispatch_request() File "/var/task/flask/app.py", line 869, in full_dispatch_request rv = self.handle_user_exception(e) File "/var/task/flask/app.py", line 867, in full_dispatch_request rv = self.dispatch_request() File "/var/task/flask/app.py", line 852, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "./main.py", line 26, in index perplexity = Perplexity() File "/var/task/perplexity/perplexity.py", line 28, in init self.sid: str = self._get_sid() File "/var/task/perplexity/perplexity.py", line 80, in _get_sid return loads(self.session.get( File "/var/lang/lib/python3.9/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/var/lang/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/var/lang/lib/python3.9/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)

how to fix it?

LexiestLeszek commented 12 months ago

Why does it work when i run it locally, but doesn't work when I deploy my project on Vercel?

laserman2000 commented 11 months ago

I believe this is an issue with Cloudflare. Maybe we could use some ideas from https://github.com/Erol444/gpt4-openai-api/blob/main/gpt4_openai/driver.py to bypass it?

itsklimov commented 9 months ago

I have the same