PerplexityApi.py 850 B

12345678910111213141516171819202122232425262728293031
  1. from __future__ import annotations
  2. from .OpenaiAPI import OpenaiAPI
  3. from ...typing import AsyncResult, Messages
  4. class PerplexityApi(OpenaiAPI):
  5. label = "Perplexity API"
  6. url = "https://www.perplexity.ai"
  7. working = True
  8. default_model = "llama-3-sonar-large-32k-online"
  9. models = [
  10. "llama-3-sonar-small-32k-chat",
  11. "llama-3-sonar-small-32k-online",
  12. "llama-3-sonar-large-32k-chat",
  13. "llama-3-sonar-large-32k-online",
  14. "llama-3-8b-instruct",
  15. "llama-3-70b-instruct",
  16. ]
  17. @classmethod
  18. def create_async_generator(
  19. cls,
  20. model: str,
  21. messages: Messages,
  22. api_base: str = "https://api.perplexity.ai",
  23. **kwargs
  24. ) -> AsyncResult:
  25. return super().create_async_generator(
  26. model, messages, api_base=api_base, **kwargs
  27. )