GithubHelp home page GithubHelp logo

perplexityai's People

Contributors

feidfoe avatar nathanrchn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

perplexityai's Issues

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

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?

error uuid

It's a strange thing. It worked very well yesterday, and today I started to report wrong error uuid.
I want to know what part of the problem this is
Can you help me? Thank you very much

Using uploaded files

Can you please provide some exmples how to use perplexity.upload(path) function?
For example, is it possible to upload a csv template and ask perplexity to put results into the template?

raise JSONDecodeError("Expecting value", s, err.value) from None

Traceback (most recent call last):
File "/home/runner/gp/main.py", line 3, in
perplexity = Perplexity()
File "/home/runner/gp/.pythonlibs/lib/python3.10/site-packages/perplexity/perplexity.py", line 28, in init
self.sid: str = self._get_sid()
File "/home/runner/gp/.pythonlibs/lib/python3.10/site-packages/perplexity/perplexity.py", line 80, in _get_sid
return loads(self.session.get(
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/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 1 column 1 (char 0)

Mode and search_focus

I tried different combinations of mode (concise/copilot) and search_focus (internet/scholar/youtube) but seems not working well. It does not show references (web results/extra web results) neither any URL as perplexityAI does.
For the mode, is there any modification to do? I just change mode='copilot' in perplexity.search() function

how to get a multi-turn response example

Truly an amazing project. However the examples in the Readme only shows how to get results with one question and one answer, can anyone show how to get answer from a multi-turn question.
For instance:
Q: how to cook an egg?
A: xx
Q: what about fish?
A:

Resolving Status=Pending results

Hi, I'm testing out the latest version of the code, where everything is condensed into the Perplexity.py file.
The generator that's returned from perplexity.search some times returns status=Pending with answer =''. What should we do in those scenarios to get a proper final answer?

Trying to run many queries quickly

I saw in recent commits it showed that there was a fix for making more than 9 requests, but still when I run a bunch of queries in a for-loop i get rate-limited. How to fix this? Or, what's the best way to harvest like 100-1000 requests using this?

get_sid returning 403 response

I am using the most recent update and am running into the following error when using the perplexity class:
Traceback (most recent call last):
File "/Users/panagiotis/Documents/Syft/perplexityai/script.py", line 3, in
perplexity = Perplexity()
File "/Users/panagiotis/Documents/Syft/perplexityai/Perplexity.py", line 42, in init
self.sid: str = self.get_sid()
File "/Users/panagiotis/Documents/Syft/perplexityai/Perplexity.py", line 67, in get_sid
response = loads(self.session.get(
File "/opt/anaconda3/envs/delphi/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/opt/anaconda3/envs/delphi/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/anaconda3/envs/delphi/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)

Looking at previous issues, it looks like this was previously accounted for by adding a User agent string but recently it is occurring again. I have tried providing a "real" looking user agent as well as run the requests through a proxy but no luck. Any other ideas on how to resolve this?

JSONDecodeError error (running in Colab)

JSONDecodeError Traceback (most recent call last)
in <cell line: 3>()
1 from perplexity import Perplexity
2
----> 3 perplexity = Perplexity()
4 answer = perplexity.search("how does solar energy work?")
5 for a in answer:

4 frames
/usr/lib/python3.10/json/decoder.py in raw_decode(self, s, idx)
353 obj, end = self.scan_once(s, idx)
354 except StopIteration as err:
--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None
356 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

API doesn't work

Hi,
I encountered an error again after your update. Could you please fix it?

raise TypeError(f'the JSON object must be str, bytes or bytearray, '

TypeError: the JSON object must be str, bytes or bytearray, not Response

New problems with cloudflare and user agent

It looks like Perplexity update their protection, as the same problem as #10 is back.

It looks like I am not the only one noticing this (see #27)

Error :

return loads(self.session.get(
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.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 1 column 1 (char 0)

Return from self.session.get(...).text :

<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Just a moment...</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="robots" content="noindex,nofollow"><meta name="viewport" content="width=device-width,initial-scale=1">
<link href="/cdn-cgi/styles/challenges.css" rel="stylesheet">
</head>
<body class="no-js">
<div class="main-wrapper" role="main">
<div class="main-content">
<noscript>
<div id="challenge-error-title">
<div class="h2">
<span class="icon-wrapper">
<div class="heading-icon warning-icon">
</div>
</span>
<span id="challenge-error-text">Enable JavaScript and cookies to continue
</span>
</div>
</div>
</noscript>
</div>
</div>

</body></html>

Hi, when I run the repo on service, it comes out this, how can I solve it?

`>>> from Perplexity import Perplexity

perplexity = Perplexity()
Traceback (most recent call last):
File "", line 1, in
File "/root/perplexityai/Perplexity.py", line 24, in init
self.sid: str = self.get_sid()
File "/root/perplexityai/Perplexity.py", line 48, in get_sid
response = loads(self.session.get(
File "/root/miniconda3/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/root/miniconda3/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/root/miniconda3/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)
answer = perplexity.search("What is the meaning of life?")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'perplexity' is not defined
`

requirements.txt?

cannot import name 'WebSocketApp' from 'websocket' (C:\Users\user\AppData\Roaming\Python\Python311\site-packages\websocket_init_.py)
File "C:\Users\user\V\4 python\2 telegram bot tesseract\perplexityai\Perplexity.py", line 7, in
from websocket import WebSocketApp
ImportError: cannot import name 'WebSocketApp' from 'websocket' (C:\Users\user\AppData\Roaming\Python\Python311\site-packages\websocket_init_.py)

Again JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Hi @nathanrchn! Again, I think there is the problem about cloudfare settings of perplexity and any perplexity.search() provide this error as output:

[/usr/lib/python3.10/json/decoder.py](https://localhost:8080/#) in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

How did you fix it the previous times?

Module not found utils

I get the following error after updating to the latest version (which is probably related to the new utils.py):

ModuleNotFoundError Traceback (most recent call last)
in <cell line: 1>()
----> 1 from perplexity import Perplexity
2 perplexity = Perplexity("[email protected]")

/usr/local/lib/python3.10/dist-packages/perplexity/init.py in
1 name: str = "perplexity"
2
----> 3 import utils
4 from .labs import Labs
5 from .perplexity import Perplexity

ModuleNotFoundError: No module named 'utils'

Set timeout

Sometimes the search freezes for a very long time, you need to set a timeout somehow.

Image

Add AI image generation support

websocket error: Handshake status 400 Bad Request

Hello,

I'm using jupyter lab and I got this error when I run the code :
websocket error: Handshake status 400 Bad Request

image

I also noticed that the cell keeps running forever.

I made sure to install the last version of the repository, and also websocket.

websocket error: Handshake status 400 Bad Request

from perplexity import Perplexity

perplexity = Perplexity()
answer = perplexity.search("What is the meaning of life?")
for a in answer:
print(a)
perplexity.close()

LOGS:
websocket error: Handshake status 400 Bad Request

processes not exiting.

Hi There,
Thanks for the wonderful contribution for this wrapper. I am not python person and don't know the process handeling much, Currently the program works perfectly when I run my code as $python3 mycode.py , it prints the output but doesn't exit. I am looking to run this as shell script and pipe the response to a file or to another script (non python). How do I achieve that?

I want the program to run and exit with unix process success code so the next thing in the pipe can take over.

WebSocketConnectionClosedException: socket is already closed

i followed the codes:

perplexity = Perplexity.Perplexity()
answer = perplexity.search("What is the meaning of life?")
print(answer.json_answer_text["answer"])
but i get this problem. i can visit the perplexity.ai website and i think its not the network error.

Answer makes no sense

I execute the following code:

    perplexity = Perplexity("[email protected]")
    answer = perplexity.search(q)
    for a in answer:
        wr = a["web_results"]
        print(wr[0]["snippet"])

The answer seems to have 75 yields but they are all the exact same sentence (as far of the snippet for the web result) -- it never gets completed.

Same happens without login

Multiple sessions in parallel?

Hello. I successfully authenticate with email, as described in short tutorial.
As far as I understand, ".perplexity_session" file is being created in fodedr where python script (program) resides, at least on Linux.
Is there any way to have multiple sessions on same computer, running in parallel?
Can authentication be directly with API KEY instead of email account?

get_sid is error

    def get_sid(self) -> str:
        url = f"https://www.perplexity.ai/socket.io/?EIO=4&transport=polling&t={self.t}"
        print(url)
        response = self.session.get(url=url)
        print(response.text)
        response = loads(response.text[1:])
        return response["sid"]

print(url) >> https://www.perplexity.ai/socket.io/?EIO=4&transport=polling&t=9e6f78e3
print(response.text) >> html source page,
not return 0{"sid":"mCJ2kEzFS-_QMjHEAIBk","upgrades":["websocket"],"pingTimeout":20000,"pingInterval":25000} as expected.

Failed to ask anonymous user

Thanks for building this @nathanrchn !

Is this class still usable as-is?
When running it, I get errors on the 'ask_anonymous_user' step.

Here is the error message after catching the error:

    assert self.ask_anonymous_user(), "Failed to ask anonymous user"
AssertionError: Failed to ask anonymous user

Answer format after the last committ

After the last commit (2nd October), the answer format displayed is the next one (JSON file).
The only chance to manage it is to manually access to the answer or there is any way to get the "readable" answer?

Code:

perplexity = Perplexity()
answer = perplexity.search("What is the meaning of life?")
for a in answer:
    print(a)
perplexity.close()

Answer:
{'status': 'completed', 'uuid': '022b9019-9640-4d6d-839d-55ccc85a9214', 'read_write_token': 'fd8a9036-c177-414e-ab93-cb9a1c2341b9', 'query_str': 'What is the meaning of life?', 'related_queries': ['Meaning of life examples', 'What is the meaning of life quotes', 'What is the meaning of life in psychology'], 'personalized': False, 'attachments': [], 'search_focus': 'internet', 'label': '', 'backend_uuid': '1107f7f5-ef76-4672-820a-7a258d4cc134', 'mode': 'concise', 'display_model': 'turbo', 'step_type': 'FINAL', 'gpt4': False, 'context_uuid': '80eee334-2c3d-4774-b31f-d3abfed4bdc4', 'thread_title': '', 'thread_access': 2, 'thread_url_slug': 'What-is-the-EQf39e92RnKCCnoljUzBNA', 'author_username': None, 'author_image': None, 's3_social_preview_url': 'https://ppl-ai-public.s3.amazonaws.com/static/img/pplx-default-preview.png', 'answer': 'The meaning of life pertains to the significance of living or existence in general[1]. It is a question that has been asked in many ways, such as "Why are we here?", "What is life all about?", or "What is the purpose of existence?"[1]. The meaning of life can be derived from philosophical and religious contemplation of, and scientific inquiries about, existence, social ties, consciousness, and happiness[1]. Many other issues are also involved, such as symbolic meaning, ontology, value, purpose, ethics, good and evil, free will, the existence of one or multiple gods, conceptions of God, the soul, and the afterlife[1]. \n\nWhile philosophy is often unhelpful in providing concrete answers, people who believe that they know their life’s meaning enjoy greater well-being than those who don’t[2]. One 2019 study found that agreeing with the statement “I have a philosophy of life that helps me understand who I am” was associated with fewer symptoms of depression and higher positive affect[2]. \n\nThe meaning of life is not something that exists outside of ourselves, but rather something that we create[5]. Meaning is like the water of our psychological health. Without it, our hearts and minds will shrivel and die. And like water, meaning flows through us—what is important today is not what was important years ago, and what is important tomorrow will not be the same as what is important today[5]. In a very real sense, the meaning of life is therefore to create meaning[5].', 'web_results': [{'name': 'Meaning of life', 'url': 'https://en.wikipedia.org/wiki/Meaning_of_life', 'snippet': 'The meaning of life pertains to the significance of living or existence in general. Many other related questions include: "Why are we here?", "What is life all about?", or "What is the purpose of existence?"', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': 'The Meaning of Life Is Surprisingly Simple - The Atlantic', 'url': 'https://www.theatlantic.com/family/archive/2021/10/meaning-life-macronutrients-purpose-search/620440/', 'snippet': 'Coherence: how events fit together. This is an understanding that things happen in your life for a reason. · Purpose: the existence of goals and ...', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': 'The Meaning of Life - Stanford Encyclopedia of Philosophy', 'url': 'https://plato.stanford.edu/entries/life-meaning/', 'snippet': 'A standard distinction to draw is between the meaning “in” life, where a human person is what can exhibit meaning, and the meaning “of” life in ...', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': 'What Is the Meaning of Life? - Psychology Today', 'url': 'https://www.psychologytoday.com/us/blog/hide-and-seek/201803/what-is-the-meaning-life', 'snippet': 'The meaning of life is that which we choose to give it.', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': 'What Is the Meaning of Life? | Mark Manson', 'url': 'https://markmanson.net/the-meaning-of-life', 'snippet': "Meaning is not something that exists outside of ourselves. It is not some cosmic universal truth waiting to be discovered. It is not some grand 'eureka' moment ...", 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': '4 philosophical answers to the meaning of life - Big Think', 'url': 'https://bigthink.com/thinking/four-philosophical-answers-meaning-of-life/', 'snippet': 'Having a sense of purpose in life is associated with positive health outcomes; conversely, not having one can leave a person feeling listless ...', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}], 'chunks': ['', 'The meaning of', ' life pertains to', ' the significance', ' of living or', ' existence in', ' general[1]. It', ' is a question', ' that has been', ' asked in many', ' ways, such as', ' "Why are we here', '?", "What is life', ' all about?", or', ' "What is the', ' purpose of existence', '?"[1]. The meaning', ' of life can be', ' derived from', ' philosophical', ' and religious', ' contemplation of', ', and scientific', ' inquiries about', ', existence, social', ' ties, consciousness', ', and happiness', '[1]. Many other', ' issues are also', ' involved, such', ' as symbolic meaning', ', ontology, value', ', purpose, ethics', ', good and evil', ', free will, the', ' existence of', ' one or multiple', ' gods, conceptions of', ' God, the soul', ', and the after', 'life[1]. \n\nWhile philosophy', ' is often unhelpful in', ' providing concrete', ' answers, people', ' who believe that', ' they know their', ' life’s meaning', ' enjoy greater', ' well-being than', ' those who don', '’t[2]. One 2019 study', ' found that agreeing', ' with the statement', ' “I have a philosophy', ' of life that', ' helps me understand', ' who I am” was', ' associated with', ' fewer symptoms', ' of depression', ' and higher positive', ' affect[2]. \n\nThe meaning', ' of life is not', ' something that', ' exists outside', ' of ourselves', ', but rather something', ' that we create', '[5]. Meaning', ' is like the water', ' of our psychological', ' health. Without', ' it, our hearts', ' and minds will', ' shrivel and die', '. And like water', ', meaning flows', ' through us—what is', ' important today', ' is not what was', ' important years', ' ago, and what', ' is important', ' tomorrow will', ' not be the same', ' as what is important', ' today[5]. In', ' a very real sense', ', the meaning', ' of life is therefore', ' to create meaning', '[5].'], 'extra_web_results': [{'name': 'Three Ways to See Meaning in Your Life - Greater Good Science Center', 'url': 'https://greatergood.berkeley.edu/article/item/three_ways_to_see_meaning_in_your_life', 'snippet': "Researchers' definitions of meaning in life typically incorporate three themes: the belief that your life and contributions matter to others and ...", 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}, {'name': 'Life Definition & Meaning - Merriam-Webster', 'url': 'https://www.merriam-webster.com/dictionary/life', 'snippet': '1. a. : the quality that distinguishes a vital and functional being from a dead body · 2. a · 3. : biography sense 1 · 4. : spiritual existence transcending (see ...', 'meta_data': None, 'is_attachment': False, 'is_widget': False, 'is_map': False}], 'image_metadata': []}

Avoid detection by antispam

Hello,

Something strange happens when I ask many prompts in a few seconds. My script does not crash but the AI doesn't answer as well, and my script keeps running forever. Setting timeout in search method allows to move to the next query but the problem is similar. The only way to move on is to kill script and start it again.
It always happen after 8 or 9 successful queries.

I assume that this is not a bug from this code, but probably a security from the website. Any idea about how to bypass this ? I don't have a billion queries to ask, only 15/20.

Stuck in search function

My codes are like:
"""
1 from perplexity import Perplexity
2 perplexity = Perplexity()
3 answer = perplexity.search("What is the meaning of life?")
4 for a in answer:
5 print(a)
6 perplexity.close()
"""
When I run this, it just stuck in line 3, which is "search" function. After a long time, I will get this error message: websocket error: [Errno 60] Operation timed out.
Is there any solution?

rate limit?

does anyone know how long a rate limit lasts, i have just sended like 20 messages and then it said i got rate limited?

Issues with deployment on Heroku

I'm experiencing a persistent issue with the package that somehow only manifests when I deploy the app on Heroku.
The JSOn values returned by the API seem to be generating errors during decoding, and I tried with both versions of the packages (Github and pip package from here).

Both works fine when I run it locally though, and the issue with Heroku popped up only in the last few weeks. Anyone faced similar issues and know what could be the problem?

 File "/app/unit_test11.py", line 4, in <module>
    for a in Perplexity().generate_answer(prompt):
             ^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/site-packages/perplexityai/__init__.py", line 22, in __init__
    self.sid = loads(
               ^^^^^^
  File "/app/.heroku/python/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.heroku/python/lib/python3.11/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)

can anyone solve this error

Traceback (most recent call last):
File "/home/runner/gp/main.py", line 3, in
perplexity = Perplexity()
File "/home/runner/gp/.pythonlibs/lib/python3.10/site-packages/perplexity/perplexity.py", line 28, in init
self.sid: str = self._get_sid()
File "/home/runner/gp/.pythonlibs/lib/python3.10/site-packages/perplexity/perplexity.py", line 80, in _get_sid
return loads(self.session.get(
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.decode(s)
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/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 1 column 1 (char 0)

Models used?

Is this library using the most recent Perplexity AI models? If not, how to define model(s) to be utilized?
Asking because I noticed that I get different result than when using Perplexity AI web chat...

Is this project still active?

Is this project still active? I encountered an error while running it and couldn't retrieve the answers correctly.
Traceback (most recent call last):
File "/root/perplexityai/1.py", line 5, in
perplexity = Perplexity()
File "/root/perplexityai/Perplexity.py", line 23, in init
self.sid: str = self.get_sid()
File "/root/perplexityai/Perplexity.py", line 47, in get_sid
response = loads(self.session.get(
File "/usr/lib/python3.10/json/init.py", line 346, in loads
return _default_decoder.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 1 column 1 (char 0)
Thank you

Empty result

Recently perplexity API started returning empty results. The strangest part is that it doesn't always do it, but it just randomly sometimes returns nothing. Here is my code:

from perplexity import Perplexity
def send_query_perp(query: str) -> Tuple[str, List[str]]:
    perplexity = Perplexity()
    perp_answer = perplexity.search(query)
    perp_answer_dicts = []
    sources = []
    for i in perp_answer:
        perp_answer_dicts.append(i)
    perplexity.close()
    try:
        print("web results: ", perp_answer_dicts[-1])
    except Exception as e:
        print("exc: ", e)
        print("web results: ", perp_answer_dicts)
    for source in perp_answer_dicts[-1]["web_results"]:
        sources.append(source['url'])
    return perp_answer_dicts[-1]["answer"], sources

Result (sometimes):
exc: list index out of range
web results: []

Could anyone please point out if I did something wrong, or it's an actual issue?

Error: Handshake status 400 BAD REQUEST

After setting up the env and dependencies, I got this error when I run the test code. Do you know how to fix it? I tried to modify user-agent and still had that issue. Thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.