diff --git a/src/utils/conversation.py b/src/utils/conversation.py index cb5ea8f..e43e461 100644 --- a/src/utils/conversation.py +++ b/src/utils/conversation.py @@ -8,6 +8,8 @@ from src.utils.agi.chat_gpt import chat_gpt_request from src.utils.stt import show_voice_input from src.utils.tts import show_player +AI_ROLE = f"{st.session_state.locale.ai_role_prefix} {st.session_state.role}. {st.session_state.locale.ai_role_postfix}" + def clear_chat() -> None: st.session_state.generated = [] @@ -90,7 +92,7 @@ def show_conversation() -> None: st.session_state.messages.append({"role": "user", "content": st.session_state.user_text}) else: st.session_state.messages = [ - {"role": "system", "content": f"{st.session_state.locale.ai_role_prefix} {st.session_state.role}."}, + {"role": "system", "content": AI_ROLE}, {"role": "user", "content": st.session_state.user_text}, ] if st.session_state.model == "bard": diff --git a/src/utils/lang.py b/src/utils/lang.py index 292e37f..679936f 100644 --- a/src/utils/lang.py +++ b/src/utils/lang.py @@ -6,42 +6,13 @@ from typing import List @dataclass class Locale: ai_role_options: List[str] - ai_role_prefix: str - title: str - language: str - lang_code: str - donates: str - donates1: str - donates2: str - chat_placeholder: str - chat_run_btn: str - chat_clear_btn: str - chat_save_btn: str - speak_btn: str - input_kind: str - input_kind_1: str - input_kind_2: str - select_placeholder1: str - select_placeholder2: str - select_placeholder3: str - radio_placeholder: str - radio_text1: str - radio_text2: str - stt_placeholder: str - footer_title: str - footer_option0: str - footer_option1: str - footer_option2: str - footer_chat: str - footer_channel: str - responsibility_denial: str - donates_info: str # Child data class for English @dataclass class EnLocale(Locale): ai_role_prefix: str = "You are a female" + ai_role_postfix: str = "Answer as concisely as possible with a little humor expression." title: str = "AI Talks" language: str = "English" lang_code: str = "en" @@ -86,6 +57,7 @@ class EnLocale(Locale): @dataclass class RuLocale(Locale): ai_role_prefix: str = "Вы девушка" + ai_role_postfix: str = "Отвечай максимально лаконично, с легким налётом юмора." title: str = "Разговорчики с ИИ" language: str = "Russian" lang_code: str = "ru"