From 424062d75f542240a82cc8d0f06b2a2d28705aad Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 22 Oct 2024 11:23:38 -0700 Subject: [PATCH] fix: emoji generation --- backend/open_webui/main.py | 3 ++- backend/open_webui/utils/task.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 3f5cab660..8c5348762 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -122,6 +122,7 @@ from open_webui.utils.task import ( moa_response_generation_template, tags_generation_template, search_query_generation_template, + emoji_generation_template, title_generation_template, tools_function_calling_generation_template, ) @@ -1718,7 +1719,7 @@ Your task is to reflect the speaker's likely facial expression through a fitting Message: """{{prompt}}""" ''' - content = title_generation_template( + content = emoji_generation_template( template, form_data["prompt"], { diff --git a/backend/open_webui/utils/task.py b/backend/open_webui/utils/task.py index 2c8ec462e..799cca11a 100644 --- a/backend/open_webui/utils/task.py +++ b/backend/open_webui/utils/task.py @@ -147,6 +147,22 @@ def tags_generation_template( return template +def emoji_generation_template( + template: str, prompt: str, user: Optional[dict] = None +) -> str: + template = replace_prompt_variable(template, prompt) + template = prompt_template( + template, + **( + {"user_name": user.get("name"), "user_location": user.get("location")} + if user + else {} + ), + ) + + return template + + def search_query_generation_template( template: str, messages: list[dict], user: Optional[dict] = None ) -> str: