fix context_length_exceeded

This commit is contained in:
if 2023-03-28 03:22:21 +03:00
parent 424fa164ba
commit 8e9ac262be
2 changed files with 17 additions and 9 deletions

View File

@ -58,11 +58,16 @@ def main() -> None:
show_conversation(st.session_state.user_text, st.session_state.model, st.session_state.role) show_conversation(st.session_state.user_text, st.session_state.model, st.session_state.role)
st.session_state.user_text = "" st.session_state.user_text = ""
c1, c2 = st.columns(2) c1, c2, c3 = st.columns(3)
with c1, c2: with c1, c2:
c1.selectbox(label=st.session_state.locale.select_placeholder1, key="model", options=AI_MODEL_OPTIONS) c1.selectbox(label=st.session_state.locale.select_placeholder1, key="model", options=AI_MODEL_OPTIONS)
c2.selectbox(label=st.session_state.locale.select_placeholder2, key="role", role_kind = c2.radio("Role Kind", ("Select", "Create"), horizontal=True)
match role_kind:
case "Select":
c3.selectbox(label=st.session_state.locale.select_placeholder2, key="role",
options=st.session_state.locale.ai_role_options) options=st.session_state.locale.ai_role_options)
case "Create":
c3.text_input(label=st.session_state.locale.select_placeholder3, key="role")
get_user_input() get_user_input()
show_chat_buttons() show_chat_buttons()

View File

@ -19,6 +19,7 @@ class Locale:
chat_save_btn: str chat_save_btn: str
select_placeholder1: str select_placeholder1: str
select_placeholder2: str select_placeholder2: str
select_placeholder3: str
stt_placeholder: str stt_placeholder: str
footer_title: str footer_title: str
footer_option1: str footer_option1: str
@ -43,6 +44,7 @@ class EnLocale(Locale):
chat_save_btn: str = "Save" chat_save_btn: str = "Save"
select_placeholder1: str = "Select AI Model" select_placeholder1: str = "Select AI Model"
select_placeholder2: str = "Select AI Role" select_placeholder2: str = "Select AI Role"
select_placeholder3: str = "Create AI Role"
stt_placeholder: str = "To Hear The Voice Of AI Press Play" stt_placeholder: str = "To Hear The Voice Of AI Press Play"
footer_title: str = "Support & Feedback" footer_title: str = "Support & Feedback"
footer_option1: str = "Info" footer_option1: str = "Info"
@ -67,6 +69,7 @@ class RuLocale(Locale):
chat_save_btn: str = "Сохранить" chat_save_btn: str = "Сохранить"
select_placeholder1: str = "Выберите Модель ИИ" select_placeholder1: str = "Выберите Модель ИИ"
select_placeholder2: str = "Выберите Роль ИИ" select_placeholder2: str = "Выберите Роль ИИ"
select_placeholder3: str = "Создайте Роль ИИ"
stt_placeholder: str = "Чтобы Услышать ИИ Нажми Кнопку Проигрывателя" stt_placeholder: str = "Чтобы Услышать ИИ Нажми Кнопку Проигрывателя"
footer_title: str = "Поддержка и Обратная Связь" footer_title: str = "Поддержка и Обратная Связь"
footer_option1: str = "Информация" footer_option1: str = "Информация"
@ -85,10 +88,10 @@ AI_ROLE_OPTIONS_EN = [
"online games expert", "online games expert",
"food recipes expert", "food recipes expert",
"English grammar expert", "English grammar expert",
"friendly and helpful teaching assistant. You explain concepts in great depth using simple terms, and you give examples to help people learn. At the end of each explanation, you ask a question to check for understanding", # NOQA: E501 "friendly and helpful teaching assistant",
"laconic assistant. You reply with brief, to-the-point answers with no elaboration", "laconic assistant",
"helpful, pattern-following assistant", "helpful, pattern-following assistant",
"helpful, pattern-following assistant that translates corporate jargon into plain English", "translate corporate jargon into plain English",
] ]
AI_ROLE_OPTIONS_RU = [ AI_ROLE_OPTIONS_RU = [
@ -102,10 +105,10 @@ AI_ROLE_OPTIONS_RU = [
"эксперт по рецептам блюд", "эксперт по рецептам блюд",
"эксперт по английской грамматике", "эксперт по английской грамматике",
"эксперт по русской грамматике", "эксперт по русской грамматике",
"дружелюбный и полезный помощник преподавателя. Вы объясняете концепции в подробностях, используя простые термины, и даёте примеры, чтобы помочь людям научиться. В конце каждого объяснения вы задаете вопрос, чтобы проверить понимание", # NOQA: E501 "дружелюбный и полезный помощник преподавателя",
"лаконичный помощник. Вы отвечаете краткими, по существу ответами без лишних слов", "лаконичный помощник",
"полезный помощник, следующий шаблонам", "полезный помощник, следующий шаблонам",
"полезный помощник, следующий шаблонам, который переводит корпоративный жаргон на простой английский", "переводчик корпоративного жаргона на простой русский",
] ]
en = EnLocale(ai_role_options=AI_ROLE_OPTIONS_EN) en = EnLocale(ai_role_options=AI_ROLE_OPTIONS_EN)