DeepInfraChat.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from __future__ import annotations
  2. from ..typing import AsyncResult, Messages
  3. from .needs_auth.OpenaiTemplate import OpenaiTemplate
  4. class DeepInfraChat(OpenaiTemplate):
  5. label = "DeepInfraChat"
  6. url = "https://deepinfra.com/chat"
  7. api_base = "https://api.deepinfra.com/v1/openai"
  8. working = True
  9. default_model = 'meta-llama/Llama-3.3-70B-Instruct-Turbo'
  10. models = [
  11. 'meta-llama/Llama-3.3-70B-Instruct',
  12. 'meta-llama/Meta-Llama-3.1-8B-Instruct',
  13. default_model,
  14. 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',
  15. 'Qwen/QwQ-32B-Preview',
  16. 'microsoft/WizardLM-2-8x22B',
  17. 'microsoft/WizardLM-2-7B',
  18. 'Qwen/Qwen2.5-72B-Instruct',
  19. 'Qwen/Qwen2.5-Coder-32B-Instruct',
  20. 'nvidia/Llama-3.1-Nemotron-70B-Instruct',
  21. ]
  22. model_aliases = {
  23. "llama-3.3-70b": "meta-llama/Llama-3.3-70B-Instruct",
  24. "llama-3.1-8b": "meta-llama/Meta-Llama-3.1-8B-Instruct",
  25. "llama-3.3-70b": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
  26. "llama-3.1-70b": "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
  27. "qwq-32b": "Qwen/QwQ-32B-Preview",
  28. "wizardlm-2-8x22b": "microsoft/WizardLM-2-8x22B",
  29. "wizardlm-2-7b": "microsoft/WizardLM-2-7B",
  30. "qwen-2.5-72b": "Qwen/Qwen2.5-72B-Instruct",
  31. "qwen-2.5-coder-32b": "Qwen/Qwen2.5-Coder-32B-Instruct",
  32. "nemotron-70b": "nvidia/Llama-3.1-Nemotron-70B-Instruct",
  33. }
  34. @classmethod
  35. async def create_async_generator(
  36. cls,
  37. model: str,
  38. messages: Messages,
  39. headers: dict = {},
  40. **kwargs
  41. ) -> AsyncResult:
  42. headers = {
  43. 'Accept-Language': 'en-US,en;q=0.9',
  44. 'Origin': 'https://deepinfra.com',
  45. 'Referer': 'https://deepinfra.com/',
  46. 'X-Deepinfra-Source': 'web-page',
  47. **headers
  48. }
  49. async for chunk in super().create_async_generator(model, messages, headers=headers, **kwargs):
  50. yield chunk