random seed for chat emojis

This commit is contained in:
if 2023-04-23 22:33:19 +03:00
parent b40f3455f4
commit 43102a2230
4 changed files with 18 additions and 13 deletions

View File

@ -45,11 +45,11 @@ repos:
- id: debug-statements
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.261
rev: v0.0.262
hooks:
- id: ruff
exclude: ^tests/
args: [--fix, --exit-non-zero-on-fix]
# args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.2

View File

@ -1,13 +1,13 @@
from streamlit_option_menu import option_menu
from pathlib import Path
from src.styles.menu_styles import HEADER_STYLES, FOOTER_STYLES
from src.utils.lang import en, ru
from src.utils.footer import show_donates, show_info
from src.utils.helpers import get_random_img, get_files_in_dir
from src.utils.conversation import get_user_input, show_chat_buttons, show_conversation
from random import randrange
import streamlit as st
from src.styles.menu_styles import FOOTER_STYLES, HEADER_STYLES
from src.utils.conversation import get_user_input, show_chat_buttons, show_conversation
from src.utils.footer import show_donates, show_info
from src.utils.helpers import get_files_in_dir, get_random_img
from src.utils.lang import en, ru
from streamlit_option_menu import option_menu
# --- PATH SETTINGS ---
current_dir: Path = Path(__file__).parent if "__file__" in locals() else Path.cwd()
@ -33,7 +33,7 @@ st.set_page_config(page_title=PAGE_TITLE, page_icon=PAGE_ICON)
# --- LOAD CSS ---
with open(css_file) as f:
st.markdown("<style>{}</style>".format(f.read()), unsafe_allow_html=True)
st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
selected_lang = option_menu(
menu_title=None,
@ -58,6 +58,8 @@ if "user_text" not in st.session_state:
st.session_state.user_text = ""
if "input_kind" not in st.session_state:
st.session_state.input_kind = st.session_state.locale.input_kind_1
if "seed" not in st.session_state:
st.session_state.seed = randrange(10**3) # noqa: S311
def main() -> None:

View File

@ -1,3 +1,5 @@
from random import randrange
import streamlit as st
from openai.error import InvalidRequestError, OpenAIError
from requests.exceptions import TooManyRedirects
@ -14,6 +16,7 @@ def clear_chat() -> None:
st.session_state.past = []
st.session_state.messages = []
st.session_state.user_text = ""
st.session_state.seed = randrange(10**8) # noqa: S311
def show_text_input() -> None:
@ -50,8 +53,8 @@ def show_chat(ai_content: str, user_text: str) -> None:
st.session_state.generated.append(ai_content)
if st.session_state.generated:
for i in range(len(st.session_state.generated)):
message(st.session_state.past[i], is_user=True, key=str(i) + "_user", avatar_style="micah")
message("", key=str(i))
message(st.session_state.past[i], is_user=True, key=str(i) + "_user", seed=st.session_state.seed)
message("", key=str(i), seed=st.session_state.seed)
st.markdown(st.session_state.generated[i])

View File

@ -28,7 +28,7 @@ exclude = [".bzr",
".idea",
".streamlit",
]
extend-exclude = ["tests", "assets", "src/styles"]
extend-exclude = ["tests", "ai_talks/assets", "ai_talks/src/styles"]
per-file-ignores = { }
# Allow unused variables when underscore-prefixed.