mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-04-20 14:28:54 +00:00
API keys are not allowed to view all the admin's models, templates, draft models, loras, etc. Basically anything that can be viewed on the filesystem outside of anything that's currently loaded is not allowed to be returned unless an admin key is present. This change helps preserve user privacy while not erroring out on list endpoints that the OAI spec requires. Signed-off-by: kingbri <bdashore3@proton.me>
31 lines
793 B
Python
31 lines
793 B
Python
import pathlib
|
|
|
|
from common import model
|
|
from endpoints.OAI.types.lora import LoraCard, LoraList
|
|
|
|
|
|
def get_lora_list(lora_path: pathlib.Path):
|
|
"""Get the list of Lora cards from the provided path."""
|
|
lora_list = LoraList()
|
|
for path in lora_path.iterdir():
|
|
if path.is_dir():
|
|
lora_card = LoraCard(id=path.name)
|
|
lora_list.data.append(lora_card)
|
|
|
|
return lora_list
|
|
|
|
|
|
def get_active_loras():
|
|
if model.container:
|
|
active_loras = [
|
|
LoraCard(
|
|
id=pathlib.Path(lora.lora_path).parent.name,
|
|
scaling=lora.lora_scaling * lora.lora_r / lora.lora_alpha,
|
|
)
|
|
for lora in model.container.get_loras()
|
|
]
|
|
else:
|
|
active_loras = []
|
|
|
|
return LoraList(data=active_loras)
|