summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/PerplexityApi.py
blob: 85d7cc98aa65a45e9340b39fcb6e3d98ec9bd13b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import annotations

from .OpenaiAPI import OpenaiAPI
from ...typing import AsyncResult, Messages

class PerplexityApi(OpenaiAPI):
    label = "Perplexity API"
    url = "https://www.perplexity.ai"
    working = True
    default_model = "llama-3-sonar-large-32k-online"
    models = [
        "llama-3-sonar-small-32k-chat",
        "llama-3-sonar-small-32k-online",
        "llama-3-sonar-large-32k-chat",
        "llama-3-sonar-large-32k-online",
        "llama-3-8b-instruct",
        "llama-3-70b-instruct",
    ]

    @classmethod
    def create_async_generator(
        cls,
        model: str,
        messages: Messages,
        api_base: str = "https://api.perplexity.ai",
        **kwargs
    ) -> AsyncResult:
        return super().create_async_generator(
            model, messages, api_base=api_base, **kwargs
        )