random seed for chat emojis
This commit is contained in:
parent
b40f3455f4
commit
43102a2230
@ -45,11 +45,11 @@ repos:
|
|||||||
- id: debug-statements
|
- id: debug-statements
|
||||||
|
|
||||||
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
- repo: https://github.com/charliermarsh/ruff-pre-commit
|
||||||
rev: v0.0.261
|
rev: v0.0.262
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
exclude: ^tests/
|
exclude: ^tests/
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
# args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
||||||
- repo: https://github.com/abravalheri/validate-pyproject
|
- repo: https://github.com/abravalheri/validate-pyproject
|
||||||
rev: v0.12.2
|
rev: v0.12.2
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
from streamlit_option_menu import option_menu
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from random import randrange
|
||||||
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
|
|
||||||
|
|
||||||
import streamlit as st
|
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 ---
|
# --- PATH SETTINGS ---
|
||||||
current_dir: Path = Path(__file__).parent if "__file__" in locals() else Path.cwd()
|
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 ---
|
# --- LOAD CSS ---
|
||||||
with open(css_file) as f:
|
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(
|
selected_lang = option_menu(
|
||||||
menu_title=None,
|
menu_title=None,
|
||||||
@ -58,6 +58,8 @@ if "user_text" not in st.session_state:
|
|||||||
st.session_state.user_text = ""
|
st.session_state.user_text = ""
|
||||||
if "input_kind" not in st.session_state:
|
if "input_kind" not in st.session_state:
|
||||||
st.session_state.input_kind = st.session_state.locale.input_kind_1
|
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:
|
def main() -> None:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from random import randrange
|
||||||
|
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
from openai.error import InvalidRequestError, OpenAIError
|
from openai.error import InvalidRequestError, OpenAIError
|
||||||
from requests.exceptions import TooManyRedirects
|
from requests.exceptions import TooManyRedirects
|
||||||
@ -14,6 +16,7 @@ def clear_chat() -> None:
|
|||||||
st.session_state.past = []
|
st.session_state.past = []
|
||||||
st.session_state.messages = []
|
st.session_state.messages = []
|
||||||
st.session_state.user_text = ""
|
st.session_state.user_text = ""
|
||||||
|
st.session_state.seed = randrange(10**8) # noqa: S311
|
||||||
|
|
||||||
|
|
||||||
def show_text_input() -> None:
|
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)
|
st.session_state.generated.append(ai_content)
|
||||||
if st.session_state.generated:
|
if st.session_state.generated:
|
||||||
for i in range(len(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(st.session_state.past[i], is_user=True, key=str(i) + "_user", seed=st.session_state.seed)
|
||||||
message("", key=str(i))
|
message("", key=str(i), seed=st.session_state.seed)
|
||||||
st.markdown(st.session_state.generated[i])
|
st.markdown(st.session_state.generated[i])
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ exclude = [".bzr",
|
|||||||
".idea",
|
".idea",
|
||||||
".streamlit",
|
".streamlit",
|
||||||
]
|
]
|
||||||
extend-exclude = ["tests", "assets", "src/styles"]
|
extend-exclude = ["tests", "ai_talks/assets", "ai_talks/src/styles"]
|
||||||
per-file-ignores = { }
|
per-file-ignores = { }
|
||||||
|
|
||||||
# Allow unused variables when underscore-prefixed.
|
# Allow unused variables when underscore-prefixed.
|
||||||
|
Loading…
Reference in New Issue
Block a user