Skip to content
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

Empty result #33

Open
ArtDoctor opened this issue Oct 27, 2023 · 14 comments
Open

Empty result #33

ArtDoctor opened this issue Oct 27, 2023 · 14 comments

Comments

@ArtDoctor
Copy link

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?

@gmkung
Copy link

gmkung commented Nov 8, 2023

Oh I just realised you have similar issues too. Since 2-3 weeks I have unreadable responses when I deploy on Heroku and I raised this in issue #34 . @nathanrchn is this something you know about?

@ArtDoctor
Copy link
Author

Yes, it's pretty sad that it doesn't work. You could post this issue here too, maybe that author will be more approachable.

@LexiestLeszek
Copy link

any ideas on how to fix? I have exactly this error with Vercel/Render

@ArtDoctor
Copy link
Author

You don't need to use this library any more - perplexity officially released their API with mistral and llama endpoint, so you can use it instead. They are much more stable than this library.

@LexiestLeszek
Copy link

You don't need to use this library any more - perplexity officially released their API with mistral and llama endpoint, so you can use it instead. They are much more stable than this library.

But their models don't search in web

@ArtDoctor
Copy link
Author

You can see here https://docs.perplexity.ai/docs/model-cards they have pplx-7b-online and pplx-70b-online, they are online meaning they do search in web.

@LexiestLeszek
Copy link

You can see here https://docs.perplexity.ai/docs/model-cards they have pplx-7b-online and pplx-70b-online, they are online meaning they do search in web.

They don't work in web, there are even reddit threads about it.

@ArtDoctor
Copy link
Author

I am sorry then, I didn't know about it. So far I've been using it and it always gave up-to-date information. I just ran a query with its API and asked about Mixtral (was released a few days ago), it gave fully correct answer. Could you please share the threads where this topic is discussed?

@LexiestLeszek
Copy link

I am sorry then, I didn't know about it. So far I've been using it and it always gave up-to-date information. I just ran a query with its API and asked about Mixtral (was released a few days ago), it gave fully correct answer. Could you please share the threads where this topic is discussed?

Oh, really? I didn't know that, I only read threads, sorry. Can you please share a python code for API calling?

@ArtDoctor
Copy link
Author

Sure, here you go:

import requests

pplx_key = "pplx-your-key"

url = "https://api.perplexity.ai/chat/completions"

payload = {
    "model": "pplx-7b-online",
    "messages": [
        {
            "role": "system",
            "content": "Be precise and concise."
        },
        {
            "role": "user",
            "content": "What is Mixtral model?"
        }
    ]
}
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "Authorization": "Bearer " + pplx_key
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

You also have to follow their guide to get your API key if you didn't already: https://docs.perplexity.ai/docs

@LexiestLeszek
Copy link

LexiestLeszek commented Dec 19, 2023

@ArtDoctor thanks! paid one works just fine.

But I still don't understand why the one from here doesn't work only when its deployed and works perfectly when I run it from my macbook.

@ArtDoctor
Copy link
Author

Glad to help!

I'm wondering about that as well. It looks like the owner of this library isn't working on it anymore, because there are lots of open problems and no recent updates. That's sad. Maybe perplexity made some changes that broke the library, which is causing all these problems.

@nathanrchn
Copy link
Owner

I think it's because when you test it on your mac locally, cloudfare doesn't block the request, but on a server, they block it.

@LexiestLeszek
Copy link

I think it's because when you test it on your mac locally, cloudfare doesn't block the request, but on a server, they block it.

But I use ngrok and it works, shouldn't cloudfare block it in that case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants