request.py 987 B

12345678910111213141516171819202122232425262728293031323334
  1. from dataclasses import dataclass
  2. from typing import Optional
  3. @dataclass
  4. class LoRARequest:
  5. """
  6. Request for a LoRA adapter.
  7. Note that this class should be be used internally. For online
  8. serving, it is recommended to not allow users to use this class but
  9. instead provide another layer of abstraction to prevent users from
  10. accessing unauthorized LoRA adapters.
  11. lora_int_id must be globally unique for a given adapter.
  12. This is currently not enforced in Aphrodite.
  13. """
  14. lora_name: str
  15. lora_int_id: int
  16. lora_local_path: str
  17. long_lora_max_len: Optional[int] = None
  18. def __post_init__(self):
  19. if self.lora_int_id < 1:
  20. raise ValueError(
  21. f"lora_int_id must be > 0, got {self.lora_int_id}")
  22. def __eq__(self, value: object) -> bool:
  23. return isinstance(
  24. value, LoRARequest) and self.lora_int_id == value.lora_int_id
  25. def __hash__(self) -> int:
  26. return self.lora_int_id