rebuild structure

This commit is contained in:
if 2023-04-23 10:38:21 +03:00
parent 01d9496841
commit 1f074699dc
10 changed files with 68 additions and 56 deletions

View File

@ -1,5 +1,5 @@
#default_language_version:
# python: python3.10.8
default_language_version:
python: python3.10.10
ci:
autofix_commit_msg: |
@ -49,6 +49,7 @@ repos:
hooks:
- id: ruff
exclude: ^tests/
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.2
@ -63,11 +64,11 @@ repos:
- id: python-check-blanket-noqa
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
- id: mypy
additional_dependencies: [ types-PyYAML==6.0.10, types_requests==2.28.8, types-ujson==5.6.0 ]
args: [ --ignore-missing-imports, --warn-no-return, --warn-redundant-casts, --disallow-incomplete-defs ]
exclude: ^setup.py
#
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.2.0
# hooks:
# - id: mypy
# additional_dependencies: [ types-PyYAML==6.0.10, types_requests==2.28.8, types-ujson==5.6.0 ]
# args: [ --ignore-missing-imports, --warn-no-return, --warn-redundant-casts, --disallow-incomplete-defs ]
# exclude: ^setup.py

2
MANIFEST.in Normal file
View File

@ -0,0 +1,2 @@
include ai_talks/assets/*
include ai_talks/src/styles/.css

View File

View File

@ -0,0 +1,35 @@
AI_ROLE_OPTIONS_EN: list[str] = [
"helpful assistant",
"code assistant",
"code reviewer",
"text improver",
"cinema expert",
"sport expert",
"online games expert",
"food recipes expert",
"English grammar expert",
"friendly and helpful teaching assistant",
"laconic assistant",
"helpful, pattern-following assistant",
"translate corporate jargon into plain English",
]
AI_ROLE_OPTIONS_RU: list[str] = [
"ассистент, который готов помочь",
"ассистент программиста",
"рецензент кода программиста",
"эксперт по улучшению текста",
"эксперт по кинематографу",
"эксперт в области спорта",
"эксперт в онлайн-играх",
"эксперт по рецептам блюд",
"эксперт по английской грамматике",
"эксперт по русской грамматике",
"дружелюбный и полезный помощник преподавателя",
"лаконичный помощник",
"полезный помощник, следующий шаблонам",
"переводчик корпоративного жаргона на простой русский",
]
README_URL: str = "https://github.com/dKosarevsky/AI-Talks#readme"
AI_TALKS_URL: str = "https://ai-talks.streamlit.app/"

View File

@ -3,10 +3,10 @@ from openai.error import InvalidRequestError, OpenAIError
from requests.exceptions import TooManyRedirects
from streamlit_chat import message
from src.utils.agi.bard import BardChat
from src.utils.agi.chat_gpt import create_gpt_completion
from src.utils.stt import show_voice_input
from src.utils.tts import show_audio_player
from ai_talks.src.utils.agi.bard import BardChat
from ai_talks.src.utils.agi.chat_gpt import create_gpt_completion
from ai_talks.src.utils.stt import show_voice_input
from ai_talks.src.utils.tts import show_audio_player
def clear_chat() -> None:

View File

@ -2,7 +2,7 @@ from pathlib import Path
import streamlit as st
from src.utils.helpers import render_svg
from ai_talks.src.utils.helpers import render_svg
def show_info(icon: Path) -> None:

View File

@ -1,6 +1,8 @@
from dataclasses import dataclass
from typing import List # NOQA: UP035
from ai_talks.src.utils.constants import AI_ROLE_OPTIONS_EN, AI_ROLE_OPTIONS_RU, AI_TALKS_URL, README_URL
@dataclass
class Locale:
@ -39,42 +41,7 @@ class Locale:
empty_api_handler: str
AI_ROLE_OPTIONS_EN = [
"helpful assistant",
"code assistant",
"code reviewer",
"text improver",
"cinema expert",
"sport expert",
"online games expert",
"food recipes expert",
"English grammar expert",
"friendly and helpful teaching assistant",
"laconic assistant",
"helpful, pattern-following assistant",
"translate corporate jargon into plain English",
]
AI_ROLE_OPTIONS_RU = [
"ассистент, который готов помочь",
"ассистент программиста",
"рецензент кода программиста",
"эксперт по улучшению текста",
"эксперт по кинематографу",
"эксперт в области спорта",
"эксперт в онлайн-играх",
"эксперт по рецептам блюд",
"эксперт по английской грамматике",
"эксперт по русской грамматике",
"дружелюбный и полезный помощник преподавателя",
"лаконичный помощник",
"полезный помощник, следующий шаблонам",
"переводчик корпоративного жаргона на простой русский",
]
readme_url = "https://github.com/dKosarevsky/AI-Talks#readme"
ai_talks_url = "https://ai-talks.streamlit.app/"
# --- LOCALE SETTINGS ---
en = Locale(
ai_role_options=AI_ROLE_OPTIONS_EN,
ai_role_prefix="You are a female",
@ -119,9 +86,10 @@ en = Locale(
""",
empty_api_handler=f"""
API key not found. Create `.streamlit/secrets.toml` with your API key.
See [README.md]({readme_url}) for instructions or use the original [AI Talks]({ai_talks_url}).
See [README.md]({README_URL}) for instructions or use the original [AI Talks]({AI_TALKS_URL}).
""",
)
ru = Locale(
ai_role_options=AI_ROLE_OPTIONS_RU,
ai_role_prefix="Вы девушка",
@ -167,6 +135,6 @@ ru = Locale(
""",
empty_api_handler=f"""
Ключ API не найден. Создайте `.streamlit/secrets.toml` с вашим ключом API.
Инструкции см. в [README.md]({readme_url}) или используйте оригинальный [AI Talks]({ai_talks_url}).
Инструкции см. в [README.md]({README_URL}) или используйте оригинальный [AI Talks]({AI_TALKS_URL}).
""",
)

View File

@ -1,3 +1,5 @@
# mypy: ignore-errors
import streamlit as st
from bokeh.models import CustomJS
from bokeh.models.widgets import Button
@ -71,7 +73,7 @@ def show_voice_input() -> None:
if result:
if "GET_TEXT" in result and (
result.get("GET_TEXT")["t"] != "" and result.get("GET_TEXT")["s"] != st.session_state.input["session"]):
st.session_state.input["text"] = result.get("GET_TEXT")["t"]
st.session_state.input["text"] = result.get("GET_TEXT")["t"] # type: ignore
tr.code(st.session_state.input["text"])
st.session_state.input["session"] = result.get("GET_TEXT")["s"]
if "GET_INTRM" in result and result.get("GET_INTRM") != "":

3
run.sh
View File

@ -1 +1,2 @@
streamlit run ai_talks/chat.py
cd ai_talks
streamlit run chat.py

View File

@ -6,8 +6,9 @@ with open("requirements.txt") as f:
setup(
name="ai-talks",
version="0.8.997",
version="0.9.1",
packages=find_packages(),
include_package_data=True,
install_requires=requirements, # Use the parsed requirements here
entry_points={
"console_scripts": [
@ -28,4 +29,6 @@ setup(
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="ai agi streamlit streamlit-component chat bot gpt llm",
python_requires=">=3.10",
)