API: Fix template switch endpoint

Forwards a Path instead of a string and adheres to the new pathfinding
system.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-09-10 12:22:07 -04:00
parent 810cd40016
commit 54bfb770af

View file

@ -445,7 +445,8 @@ async def switch_template(data: TemplateSwitchRequest):
raise HTTPException(400, error_message)
try:
model.container.prompt_template = PromptTemplate.from_file(data.name)
template_path = pathlib.Path("templates") / data.name
model.container.prompt_template = PromptTemplate.from_file(template_path)
except FileNotFoundError as e:
error_message = handle_request_error(
f"The template name {data.name} doesn't exist. Check the spelling?",