request.py 915 B

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