mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
API: Add template list endpoint
Fetches all template names that a user has in the templates directory for chat completions. Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
11
main.py
11
main.py
@@ -32,6 +32,7 @@ from OAI.types.model import (
|
||||
ModelLoadResponse,
|
||||
ModelCardParameters,
|
||||
)
|
||||
from OAI.types.template import TemplateList
|
||||
from OAI.types.token import (
|
||||
TokenEncodeRequest,
|
||||
TokenEncodeResponse,
|
||||
@@ -45,7 +46,7 @@ from OAI.utils_oai import (
|
||||
create_chat_completion_response,
|
||||
create_chat_completion_stream_chunk,
|
||||
)
|
||||
from templating import get_prompt_from_template
|
||||
from templating import get_all_templates, get_prompt_from_template
|
||||
from utils import get_generator_error, get_sse_packet, load_progress, unwrap
|
||||
from logger import init_logger
|
||||
|
||||
@@ -244,6 +245,14 @@ async def unload_model():
|
||||
MODEL_CONTAINER = None
|
||||
|
||||
|
||||
@app.get("/v1/templates", dependencies=[Depends(check_api_key)])
|
||||
@app.get("/v1/template/list", dependencies=[Depends(check_api_key)])
|
||||
async def get_templates():
|
||||
templates = get_all_templates()
|
||||
template_strings = list(map(lambda template: template.stem, templates))
|
||||
return TemplateList(data=template_strings)
|
||||
|
||||
|
||||
# Lora list endpoint
|
||||
@app.get("/v1/loras", dependencies=[Depends(check_api_key)])
|
||||
@app.get("/v1/lora/list", dependencies=[Depends(check_api_key)])
|
||||
|
||||
Reference in New Issue
Block a user