| 11789 | ) |
| 11790 | |
| 11791 | def _apply_lora_adapters(self, ctx: Any, context_name: str) -> None: |
| 11792 | if not self._lora_adapters: |
| 11793 | return |
| 11794 | if self._lora_adapter_array is None or self._lora_scales_array is None: |
| 11795 | raise RuntimeError("LoRA adapter arrays are not initialized") |
| 11796 | result = llama_cpp.llama_set_adapters_lora( |
| 11797 | ctx, |
| 11798 | self._lora_adapter_array, |
| 11799 | len(self._lora_adapters), |
| 11800 | self._lora_scales_array, |
| 11801 | ) |
| 11802 | if result: |
| 11803 | raise RuntimeError(f"failed to apply LoRA adapters to {context_name} context") |
| 11804 | |
| 11805 | def _free_lora_adapters(self) -> None: |
| 11806 | while self._lora_adapters: |