Templates: Migrate to class

Having many utility functions for initialization doesn't make much sense.
Instead, handle anything regarding template creation inside the
class which reduces the amount of function imports.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2024-04-21 23:28:14 -04:00
parent 9f93505bc1
commit cab789e685
4 changed files with 122 additions and 132 deletions

View File

@@ -15,7 +15,6 @@ from common.networking import (
handle_request_disconnect,
handle_request_error,
)
from common.templating import get_prompt_from_template
from common.utils import unwrap
from endpoints.OAI.types.chat_completion import (
ChatCompletionLogprobs,
@@ -150,8 +149,8 @@ def format_prompt_with_template(data: ChatCompletionRequest):
}
)
prompt, template_stop_strings = get_prompt_from_template(
model.container.prompt_template, data.template_vars
prompt, template_stop_strings = model.container.prompt_template.render(
data.template_vars
)
# Append template stop strings