summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/PerplexityLabs.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-23 20:08:41 +0100
committerGitHub <noreply@github.com>2024-01-23 20:08:41 +0100
commit2b140a32554c1e94d095c55599a2f93e86f957cf (patch)
treee2770d97f0242a0b99a3af68ea4fcf25227dfcc8 /g4f/Provider/PerplexityLabs.py
parent~ (diff)
parentAdd ProviderModelMixin for model selection (diff)
downloadgpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.gz
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.bz2
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.lz
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.xz
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.tar.zst
gpt4free-2b140a32554c1e94d095c55599a2f93e86f957cf.zip
Diffstat (limited to 'g4f/Provider/PerplexityLabs.py')
-rw-r--r--g4f/Provider/PerplexityLabs.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/g4f/Provider/PerplexityLabs.py b/g4f/Provider/PerplexityLabs.py
index c989b3da..90258da5 100644
--- a/g4f/Provider/PerplexityLabs.py
+++ b/g4f/Provider/PerplexityLabs.py
@@ -5,20 +5,21 @@ import json
from aiohttp import ClientSession
from ..typing import AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
API_URL = "https://labs-api.perplexity.ai/socket.io/"
WS_URL = "wss://labs-api.perplexity.ai/socket.io/"
-class PerplexityLabs(AsyncGeneratorProvider):
+class PerplexityLabs(AsyncGeneratorProvider, ProviderModelMixin):
url = "https://labs.perplexity.ai"
working = True
- supports_gpt_35_turbo = True
- models = ['pplx-7b-online', 'pplx-70b-online', 'pplx-7b-chat', 'pplx-70b-chat', 'mistral-7b-instruct',
+ models = [
+ 'pplx-7b-online', 'pplx-70b-online', 'pplx-7b-chat', 'pplx-70b-chat', 'mistral-7b-instruct',
'codellama-34b-instruct', 'llama-2-70b-chat', 'llava-7b-chat', 'mixtral-8x7b-instruct',
- 'mistral-medium', 'related']
+ 'mistral-medium', 'related'
+ ]
default_model = 'pplx-70b-online'
- model_map = {
+ model_aliases = {
"mistralai/Mistral-7B-Instruct-v0.1": "mistral-7b-instruct",
"meta-llama/Llama-2-70b-chat-hf": "llama-2-70b-chat",
"mistralai/Mixtral-8x7B-Instruct-v0.1": "mixtral-8x7b-instruct",
@@ -33,12 +34,6 @@ class PerplexityLabs(AsyncGeneratorProvider):
proxy: str = None,
**kwargs
) -> AsyncResult:
- if not model:
- model = cls.default_model
- elif model in cls.model_map:
- model = cls.model_map[model]
- elif model not in cls.models:
- raise ValueError(f"Model is not supported: {model}")
headers = {
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0",
"Accept": "*/*",
@@ -78,7 +73,7 @@ class PerplexityLabs(AsyncGeneratorProvider):
message_data = {
'version': '2.2',
'source': 'default',
- 'model': model,
+ 'model': cls.get_model(model),
'messages': messages
}
await ws.send_str('42' + json.dumps(['perplexity_playground', message_data]))