From c75bae1a581204c8368de2df9a3b90caa620cce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Mon, 1 Jun 2026 05:17:20 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82?= =?UTF-8?q?=D1=83=D1=80=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D0=BF=D0=BB=D0=B0?= =?UTF-8?q?=D1=82=D1=84=D0=BE=D1=80=D0=BC=D1=83=20=E2=80=94=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=20=D0=B2=20site/,=20requirements.txt=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 16 ----- app.py => site/app.py | 0 site/config.py | 87 +++++++++++++++++++++++ {routes => site/routes}/__init__.py | 0 {routes => site/routes}/api.py | 0 {routes => site/routes}/pages.py | 0 {services => site/services}/__init__.py | 0 {services => site/services}/llm.py | 0 {services => site/services}/whisper.py | 0 {static => site/static}/favicon.png | Bin {static => site/static}/nubes-logo.svg | 0 {static => site/static}/style.css | 0 {templates => site/templates}/index.html | 0 13 files changed, 87 insertions(+), 16 deletions(-) delete mode 100644 Dockerfile rename app.py => site/app.py (100%) create mode 100644 site/config.py rename {routes => site/routes}/__init__.py (100%) rename {routes => site/routes}/api.py (100%) rename {routes => site/routes}/pages.py (100%) rename {services => site/services}/__init__.py (100%) rename {services => site/services}/llm.py (100%) rename {services => site/services}/whisper.py (100%) rename {static => site/static}/favicon.png (100%) rename {static => site/static}/nubes-logo.svg (100%) rename {static => site/static}/style.css (100%) rename {templates => site/templates}/index.html (100%) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a69e5d3..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM python:3.12-slim - -WORKDIR /app - -# Зависимости -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt - -# Код -COPY . . - -# Порт -EXPOSE 5000 - -# Запуск -CMD ["python", "app.py"] diff --git a/app.py b/site/app.py similarity index 100% rename from app.py rename to site/app.py diff --git a/site/config.py b/site/config.py new file mode 100644 index 0000000..4af27b7 --- /dev/null +++ b/site/config.py @@ -0,0 +1,87 @@ +""" +Централизованная конфигурация приложения Say. + +Все настройки читаются из переменных окружения с разумными значениями по умолчанию. +""" + +import os + +# ============================================================================= +# API — единый эндпоинт (aillm.ru) +# ============================================================================= + +API_BASE = os.environ.get("API_BASE", "https://api.aillm.ru") +API_KEY = os.environ.get("API_KEY", "") # ⚠️ Без ключа — только через env! + +# ============================================================================= +# Whisper (распознавание речи) +# ============================================================================= + +WHISPER_URL = os.environ.get( + "WHISPER_URL", + f"{API_BASE}/v1/audio/transcriptions", +) +WHISPER_KEY = os.environ.get("WHISPER_KEY", API_KEY) +WHISPER_MODEL = os.environ.get("WHISPER_MODEL", "whisper-large-v3") + +# ============================================================================= +# Три LLM-профиля — каждый со своим именем, моделью и системным промптом +# ============================================================================= + +LLM_PROFILES = [ + { + "id": "ddm", + "name": "DDM-120", + "description": "Быстрая модель, общие вопросы", + "url": os.environ.get("LLM_URL_DDM", f"{API_BASE}/v1/chat/completions"), + "key": os.environ.get("LLM_KEY_DDM", API_KEY), + "model": os.environ.get("LLM_MODEL_DDM", "ddm-120"), + "system_prompt": os.environ.get( + "LLM_SYSTEM_DDM", + "Ты — полезный ассистент. Отвечай кратко и по делу на том же языке, что и запрос.", + ), + "temperature": float(os.environ.get("LLM_TEMP_DDM", "0.7")), + "max_tokens": int(os.environ.get("LLM_TOKENS_DDM", "1024")), + }, + { + "id": "qwen", + "name": "Qwen", + "description": "Мощная модель, сложные задачи", + "url": os.environ.get("LLM_URL_QWEN", f"{API_BASE}/v1/chat/completions"), + "key": os.environ.get("LLM_KEY_QWEN", API_KEY), + "model": os.environ.get("LLM_MODEL_QWEN", "qwen-plus"), + "system_prompt": os.environ.get( + "LLM_SYSTEM_QWEN", + "Ты — эксперт-аналитик. Отвечай развернуто, структурированно, на языке запроса.", + ), + "temperature": float(os.environ.get("LLM_TEMP_QWEN", "0.7")), + "max_tokens": int(os.environ.get("LLM_TOKENS_QWEN", "2048")), + }, + { + "id": "deepseek", + "name": "DeepSeek", + "description": "Глубокая аналитика, код, рассуждения", + "url": os.environ.get("LLM_URL_DEEPSEEK", f"{API_BASE}/v1/chat/completions"), + "key": os.environ.get("LLM_KEY_DEEPSEEK", API_KEY), + "model": os.environ.get("LLM_MODEL_DEEPSEEK", "deepseek-chat"), + "system_prompt": os.environ.get( + "LLM_SYSTEM_DEEPSEEK", + "Ты — глубокий аналитик и программист. Думай step-by-step, отвечай на языке запроса.", + ), + "temperature": float(os.environ.get("LLM_TEMP_DEEPSEEK", "0.7")), + "max_tokens": int(os.environ.get("LLM_TOKENS_DEEPSEEK", "4096")), + }, +] + +# ============================================================================= +# Flask +# ============================================================================= + +FLASK_HOST = os.environ.get("HOST", "0.0.0.0") +FLASK_PORT = int(os.environ.get("PORT", "5000")) + +# ============================================================================= +# Логирование +# ============================================================================= + +LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO") diff --git a/routes/__init__.py b/site/routes/__init__.py similarity index 100% rename from routes/__init__.py rename to site/routes/__init__.py diff --git a/routes/api.py b/site/routes/api.py similarity index 100% rename from routes/api.py rename to site/routes/api.py diff --git a/routes/pages.py b/site/routes/pages.py similarity index 100% rename from routes/pages.py rename to site/routes/pages.py diff --git a/services/__init__.py b/site/services/__init__.py similarity index 100% rename from services/__init__.py rename to site/services/__init__.py diff --git a/services/llm.py b/site/services/llm.py similarity index 100% rename from services/llm.py rename to site/services/llm.py diff --git a/services/whisper.py b/site/services/whisper.py similarity index 100% rename from services/whisper.py rename to site/services/whisper.py diff --git a/static/favicon.png b/site/static/favicon.png similarity index 100% rename from static/favicon.png rename to site/static/favicon.png diff --git a/static/nubes-logo.svg b/site/static/nubes-logo.svg similarity index 100% rename from static/nubes-logo.svg rename to site/static/nubes-logo.svg diff --git a/static/style.css b/site/static/style.css similarity index 100% rename from static/style.css rename to site/static/style.css diff --git a/templates/index.html b/site/templates/index.html similarity index 100% rename from templates/index.html rename to site/templates/index.html