smart-bot-factory 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of smart-bot-factory might be problematic. Click here for more details.
- smart_bot_factory/admin/__init__.py +2 -0
- smart_bot_factory/admin/admin_events.py +757 -0
- smart_bot_factory/admin/admin_logic.py +54 -12
- smart_bot_factory/aiogram_calendar/__init__.py +6 -0
- smart_bot_factory/aiogram_calendar/common.py +70 -0
- smart_bot_factory/aiogram_calendar/dialog_calendar.py +197 -0
- smart_bot_factory/aiogram_calendar/schemas.py +78 -0
- smart_bot_factory/aiogram_calendar/simple_calendar.py +180 -0
- smart_bot_factory/analytics/analytics_manager.py +42 -5
- smart_bot_factory/cli.py +1 -1
- smart_bot_factory/core/bot_utils.py +17 -16
- smart_bot_factory/core/decorators.py +215 -4
- smart_bot_factory/core/states.py +12 -0
- smart_bot_factory/creation/bot_builder.py +54 -2
- smart_bot_factory/handlers/handlers.py +388 -4
- smart_bot_factory/integrations/openai_client.py +29 -1
- smart_bot_factory/integrations/supabase_client.py +413 -37
- smart_bot_factory/utm_link_generator.py +13 -3
- {smart_bot_factory-0.3.1.dist-info → smart_bot_factory-0.3.3.dist-info}/METADATA +26 -17
- {smart_bot_factory-0.3.1.dist-info → smart_bot_factory-0.3.3.dist-info}/RECORD +23 -19
- smart_bot_factory/table/database_structure.sql +0 -57
- smart_bot_factory/table/schema.sql +0 -1094
- {smart_bot_factory-0.3.1.dist-info → smart_bot_factory-0.3.3.dist-info}/WHEEL +0 -0
- {smart_bot_factory-0.3.1.dist-info → smart_bot_factory-0.3.3.dist-info}/entry_points.txt +0 -0
- {smart_bot_factory-0.3.1.dist-info → smart_bot_factory-0.3.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: smart-bot-factory
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Библиотека для создания умных чат-ботов
|
|
5
5
|
Author-email: Kopatych <eserov73@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -25,6 +25,7 @@ Requires-Dist: aiogram>=3.4.1
|
|
|
25
25
|
Requires-Dist: click>=8.0.0
|
|
26
26
|
Requires-Dist: openai>=1.12.0
|
|
27
27
|
Requires-Dist: project-root-finder>=1.9
|
|
28
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
28
29
|
Requires-Dist: python-dotenv>=1.0.1
|
|
29
30
|
Requires-Dist: pytz>=2023.3
|
|
30
31
|
Requires-Dist: pyyaml>=6.0.2
|
|
@@ -33,27 +34,27 @@ Description-Content-Type: text/markdown
|
|
|
33
34
|
|
|
34
35
|
# Smart Bot Factory
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
## Библиотека для создания умных Telegram ботов с AI, аналитикой и гибкой архитектурой
|
|
37
38
|
|
|
38
39
|
## 📋 Содержание
|
|
39
40
|
|
|
40
|
-
- [Установка](
|
|
41
|
-
- [Быстрый старт](
|
|
42
|
-
- [CLI Команды](
|
|
43
|
-
- [Декораторы](
|
|
41
|
+
- [Установка](#-установка)
|
|
42
|
+
- [Быстрый старт](#-быстрый-старт)
|
|
43
|
+
- [CLI Команды](#-cli-команды)
|
|
44
|
+
- [Декораторы](#-декораторы)
|
|
44
45
|
- [event_handler](#event_handler---обработчики-событий)
|
|
45
46
|
- [schedule_task](#schedule_task---запланированные-задачи)
|
|
46
47
|
- [global_handler](#global_handler---глобальные-обработчики)
|
|
47
|
-
- [Хуки для кастомизации](
|
|
48
|
-
- [Telegram роутеры](
|
|
49
|
-
- [Расширенные возможности](
|
|
48
|
+
- [Хуки для кастомизации](#-хуки-для-кастомизации)
|
|
49
|
+
- [Telegram роутеры](#-telegram-роутеры)
|
|
50
|
+
- [Расширенные возможности](#-расширенные-возможности)
|
|
50
51
|
|
|
51
52
|
---
|
|
52
53
|
|
|
53
54
|
## 🚀 Установка
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
|
-
pip install
|
|
57
|
+
pip install smart_bot_factory
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
## ⚡ Быстрый старт
|
|
@@ -112,10 +113,18 @@ if __name__ == "__main__":
|
|
|
112
113
|
# Создать нового бота из базового шаблона
|
|
113
114
|
sbf create my-bot
|
|
114
115
|
|
|
115
|
-
#
|
|
116
|
-
sbf
|
|
116
|
+
# Скопировать существующего бота
|
|
117
|
+
sbf copy best-valera new-valera
|
|
118
|
+
|
|
117
119
|
```
|
|
118
120
|
|
|
121
|
+
**💡 Команда `copy` - создает нового бота на основе существующего:**
|
|
122
|
+
|
|
123
|
+
- ✅ Копирует код бота с автозаменой `bot_id`
|
|
124
|
+
- ✅ Копирует все промпты
|
|
125
|
+
- ✅ Копирует тесты и файлы
|
|
126
|
+
- ✅ Создает новый `.env` (не копирует токены)
|
|
127
|
+
|
|
119
128
|
### Управление ботами
|
|
120
129
|
|
|
121
130
|
```bash
|
|
@@ -268,7 +277,7 @@ async def handler(user_id: int, user_data: str):
|
|
|
268
277
|
|
|
269
278
|
**Формула времени с `event_type`:**
|
|
270
279
|
|
|
271
|
-
```
|
|
280
|
+
```text
|
|
272
281
|
reminder_time = event_datetime - delay
|
|
273
282
|
```
|
|
274
283
|
|
|
@@ -622,8 +631,8 @@ from smart_bot_factory.message import send_message
|
|
|
622
631
|
async def send_catalog(user_id: int, event_data: str):
|
|
623
632
|
"""Отправляет каталог с файлами"""
|
|
624
633
|
from smart_bot_factory.message import get_bot
|
|
625
|
-
|
|
626
|
-
|
|
634
|
+
from smart_bot_factory.supabase import SupabaseClient
|
|
635
|
+
|
|
627
636
|
bot = get_bot()
|
|
628
637
|
supabase_client = SupabaseClient("my-bot")
|
|
629
638
|
|
|
@@ -761,7 +770,7 @@ if __name__ == "__main__":
|
|
|
761
770
|
|
|
762
771
|
## 📖 Структура проекта
|
|
763
772
|
|
|
764
|
-
```
|
|
773
|
+
```text
|
|
765
774
|
project/
|
|
766
775
|
├── bots/
|
|
767
776
|
│ └── my-bot/
|
|
@@ -781,7 +790,7 @@ project/
|
|
|
781
790
|
|
|
782
791
|
## ⚙️ Конфигурация (.env)
|
|
783
792
|
|
|
784
|
-
```
|
|
793
|
+
```bash
|
|
785
794
|
# Telegram
|
|
786
795
|
TELEGRAM_BOT_TOKEN=your_token_here
|
|
787
796
|
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
smart_bot_factory/__init__.py,sha256=W5k9awLVi0R_N3fSul7VNkKRdSfExZjNb_M2yNzepg8,102
|
|
2
|
-
smart_bot_factory/cli.py,sha256=
|
|
2
|
+
smart_bot_factory/cli.py,sha256=eQ2fv0uc87nrm1b-lRRw0Tz52NquCcwkk2it__beNKU,33223
|
|
3
3
|
smart_bot_factory/config.py,sha256=kB3G2hGMrrCSOAvlrddf8x43bgfgEaQqOCKOeELAzfM,11640
|
|
4
4
|
smart_bot_factory/setup_checker.py,sha256=fqRzyptyMzcb2I0boUaj0rWLdarqaN6ViX6suwTEeWc,20123
|
|
5
|
-
smart_bot_factory/utm_link_generator.py,sha256=
|
|
6
|
-
smart_bot_factory/admin/__init__.py,sha256=
|
|
7
|
-
smart_bot_factory/admin/
|
|
5
|
+
smart_bot_factory/utm_link_generator.py,sha256=wYPdYYK555YfOP22eJXAcEv_D66_t50Dhg0-wkLVzVk,4502
|
|
6
|
+
smart_bot_factory/admin/__init__.py,sha256=vdsMTpt_LiXkY-awFu_X9e2Zt7CV50PwmsWkFbk6whk,488
|
|
7
|
+
smart_bot_factory/admin/admin_events.py,sha256=yU52QWc1GC-E-WAA_A3HAXpY3zMG96eGq97FtHC5ZB0,34804
|
|
8
|
+
smart_bot_factory/admin/admin_logic.py,sha256=zyaklL-s0LihPGHVbguOB9F0NMaggHAyQGukco_kTtA,22831
|
|
8
9
|
smart_bot_factory/admin/admin_manager.py,sha256=xlyG9mIjPmtUhS4E9lp36T7o5Kfp5PZpJ-r1QjnSn5g,6394
|
|
9
10
|
smart_bot_factory/admin/admin_migration.sql,sha256=kleMPJBSe2Z7ZZz7rNyOX_yoh4GZivGesqAX90U5PGs,5667
|
|
10
11
|
smart_bot_factory/admin/admin_tester.py,sha256=PGFpf7fmD5Wxea31xR2ZM_A_QpvrB73gsbxvUrHQBkg,6463
|
|
11
12
|
smart_bot_factory/admin/timeout_checker.py,sha256=TzA2FGrxwE8fuhKerGnGrt4qYMEZdIR8x3SQAnIW5YQ,24490
|
|
12
|
-
smart_bot_factory/
|
|
13
|
+
smart_bot_factory/aiogram_calendar/__init__.py,sha256=_IzB_HJIZuMs__7xBBsYVG20GbRNFw2VowvhOEyiGGc,349
|
|
14
|
+
smart_bot_factory/aiogram_calendar/common.py,sha256=Ik-ler6Hid11SHpphqfFs5FjvGhj8Ajz0ds-MWMjPoo,2659
|
|
15
|
+
smart_bot_factory/aiogram_calendar/dialog_calendar.py,sha256=AVuIWPp4D8ri7N7aSNqfZ_SicbfYGvQWeJqSmakGkuE,8289
|
|
16
|
+
smart_bot_factory/aiogram_calendar/schemas.py,sha256=y2jnnFuqOqLZ7PwY6WQrzmRgCE6rwFYUGTFYaQnCouM,2524
|
|
17
|
+
smart_bot_factory/aiogram_calendar/simple_calendar.py,sha256=XmCFjrDNJZ9LNEGkbY1vqRbU9t2EgIk69tGg5xy2sfE,7859
|
|
18
|
+
smart_bot_factory/analytics/analytics_manager.py,sha256=y1DI_TnAdSX5NG_mwqHD1emne4opfsyo50D_tebi_UA,17967
|
|
13
19
|
smart_bot_factory/configs/growthmed-october-24/prompts/1sales_context.txt,sha256=uJ4WviYIr9xJaFdu-APrrmBgIWVwdJymcN04upIviLY,1614
|
|
14
20
|
smart_bot_factory/configs/growthmed-october-24/prompts/2product_info.txt,sha256=tWP9gdn58vu9BhYpDx1lGuPNT24j5p1XPiCSD-CdXiU,24191
|
|
15
21
|
smart_bot_factory/configs/growthmed-october-24/prompts/3objection_handling.txt,sha256=zwUGKp3mp1dAQUPjLQsCsczwRJJOqn9GGvVzVBCpvfY,6985
|
|
@@ -24,32 +30,30 @@ smart_bot_factory/configs/growthmed-october-24/tests/realistic_scenarios.yaml,sh
|
|
|
24
30
|
smart_bot_factory/configs/growthmed-october-24/tests/scenario_examples.yaml,sha256=bzDulOU4a2LyWlcHzlQU8GYhOky2WTfyizGfjX4ioMY,2436
|
|
25
31
|
smart_bot_factory/configs/growthmed-october-24/welcome_file/welcome_file_msg.txt,sha256=Db21Mm0r8SBWFdX9EeIF2FZtLQ2cvuwVlSRJd2KEYCg,922
|
|
26
32
|
smart_bot_factory/configs/growthmed-october-24/welcome_file/Чек лист по 152ФЗ и 323ФЗ для медицины.pdf,sha256=BiAiQHNnQXJPMsks9AeL6s0beEjRFkRMJLMlAn4WorA,5284954
|
|
27
|
-
smart_bot_factory/core/bot_utils.py,sha256=
|
|
33
|
+
smart_bot_factory/core/bot_utils.py,sha256=Be334BPspBgHNO9OpEiPlrCc0Gmy7_8sox5WpV8XHic,45174
|
|
28
34
|
smart_bot_factory/core/conversation_manager.py,sha256=eoHL7MCEz68DRvTVwRwZgf2PWwGv4T6J9D-I-thETi8,28289
|
|
29
|
-
smart_bot_factory/core/decorators.py,sha256=
|
|
35
|
+
smart_bot_factory/core/decorators.py,sha256=gJWaJVyCoBSsy4EsaJTv4OPVK-Efv1pQLm54Odgu4Lk,93678
|
|
30
36
|
smart_bot_factory/core/message_sender.py,sha256=J4b6n8nXVjqf-qzL6URRSvc-FVnQfShwujVSM6qv26w,32232
|
|
31
37
|
smart_bot_factory/core/router.py,sha256=03fbysaj0LR96p4-8iiml8dTmEHCkR-AaTposSv8q8o,11898
|
|
32
38
|
smart_bot_factory/core/router_manager.py,sha256=dUwesog-oHk1U2EDdS8p0e4MTSkwtx5_qXn6nrJ9l9I,9700
|
|
33
|
-
smart_bot_factory/core/states.py,sha256=
|
|
39
|
+
smart_bot_factory/core/states.py,sha256=L8qp1UmYFuxTN5U9tY076rDuKgxtFbpSGqBpva2eWbo,895
|
|
34
40
|
smart_bot_factory/creation/__init__.py,sha256=IgDk8GDS3pg7Pw_Et41J33ZmeZIU5dRwQdTmYKXfJfE,128
|
|
35
|
-
smart_bot_factory/creation/bot_builder.py,sha256=
|
|
41
|
+
smart_bot_factory/creation/bot_builder.py,sha256=yGRmOPD7qCMbhcBiltHWISoKxWx8eqjDSnZXpwhqnUs,43115
|
|
36
42
|
smart_bot_factory/creation/bot_testing.py,sha256=JDWXyJfZmbgo-DLdAPk8Sd9FiehtHHa4sLD17lBrTOc,55669
|
|
37
43
|
smart_bot_factory/event/__init__.py,sha256=hPL449RULIOB-OXv1ZbGNiHctAYaOMUqhSWGPrDHYBM,212
|
|
38
|
-
smart_bot_factory/handlers/handlers.py,sha256=
|
|
39
|
-
smart_bot_factory/integrations/openai_client.py,sha256=
|
|
40
|
-
smart_bot_factory/integrations/supabase_client.py,sha256=
|
|
44
|
+
smart_bot_factory/handlers/handlers.py,sha256=jMKD04v81BbCNLl_00rAM_rgPDH1mMdHZlLI8ZhXpc8,60438
|
|
45
|
+
smart_bot_factory/integrations/openai_client.py,sha256=fwaJpwojFdLBWChcFWpFGOHK9upG-nCIwDochkCRRlY,24291
|
|
46
|
+
smart_bot_factory/integrations/supabase_client.py,sha256=XznvAXqcMBqHw2_-t91Exyomru-mLP6-BlYuEeoUJSY,63082
|
|
41
47
|
smart_bot_factory/message/__init__.py,sha256=-ehDZweUc3uKgmLLxFVsD-KWrDtnHpHms7pCrDelWo0,1950
|
|
42
48
|
smart_bot_factory/router/__init__.py,sha256=5gEbpG3eylOyow5NmidzGUy0K-AZq7RhYLVu9OaUT6c,270
|
|
43
49
|
smart_bot_factory/supabase/__init__.py,sha256=XmZP6yM9ffERM5ddAWyJnrNzEhCYtMu3AcjVCi1rOf8,179
|
|
44
50
|
smart_bot_factory/supabase/client.py,sha256=lWIzfOgoSvU7xPhYLoJtM5GnbWdoWsvHcRFC22sFBMU,25637
|
|
45
|
-
smart_bot_factory/table/database_structure.sql,sha256=26gFtMC2jdQGQF7Zb_F4Br56rMd4hUDTk9FkNZYneLo,2789
|
|
46
|
-
smart_bot_factory/table/schema.sql,sha256=-6kOmA9QnSkUtmGI2iQRbTvbdiqOhEOQcuz1lJn79mU,28059
|
|
47
51
|
smart_bot_factory/utils/__init__.py,sha256=UhsJXEHfrIK8h1AHsroHSwAriijk-LvnqLyvgzi2VYs,273
|
|
48
52
|
smart_bot_factory/utils/debug_routing.py,sha256=BOoDhKBg7UXe5uHQxRk3TSfPfLPOFqt0N7lAo6kjCOo,4719
|
|
49
53
|
smart_bot_factory/utils/prompt_loader.py,sha256=JSn7CsWnToSbHYtURdeuZn7ectyDqQGrPGHN2ixIGkw,19930
|
|
50
54
|
smart_bot_factory/utils/user_prompt_loader.py,sha256=dk6P0X_3UcNqxjRtuIvb0LcPrp03zIIsstZwdmeCPaE,2519
|
|
51
|
-
smart_bot_factory-0.3.
|
|
52
|
-
smart_bot_factory-0.3.
|
|
53
|
-
smart_bot_factory-0.3.
|
|
54
|
-
smart_bot_factory-0.3.
|
|
55
|
-
smart_bot_factory-0.3.
|
|
55
|
+
smart_bot_factory-0.3.3.dist-info/METADATA,sha256=kyf-bct-Sf1zvA6PwlUtTOGJ17kV7q8FuqtrjvNvXRM,31949
|
|
56
|
+
smart_bot_factory-0.3.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
57
|
+
smart_bot_factory-0.3.3.dist-info/entry_points.txt,sha256=ybKEAI0WSb7WoRiey7QE-HHfn88UGV7nxLDxXq7b7SU,50
|
|
58
|
+
smart_bot_factory-0.3.3.dist-info/licenses/LICENSE,sha256=OrK3cwdUTzNzIhJvSPtJaVMoYIyC_sSx5EFE_FDMvGs,1092
|
|
59
|
+
smart_bot_factory-0.3.3.dist-info/RECORD,,
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
-- Исправленная структура базы данных для чат-бота с поддержкой множественных ботов
|
|
2
|
-
|
|
3
|
-
-- Таблица пользователей
|
|
4
|
-
CREATE TABLE IF NOT EXISTS sales_users (
|
|
5
|
-
id BIGSERIAL PRIMARY KEY,
|
|
6
|
-
telegram_id BIGINT NOT NULL,
|
|
7
|
-
bot_id TEXT NOT NULL, -- 🆕 Идентификатор бота
|
|
8
|
-
username TEXT,
|
|
9
|
-
first_name TEXT,
|
|
10
|
-
last_name TEXT,
|
|
11
|
-
language_code TEXT,
|
|
12
|
-
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
13
|
-
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
14
|
-
is_active BOOLEAN DEFAULT TRUE,
|
|
15
|
-
UNIQUE(telegram_id, bot_id) -- 🆕 Уникальность по пользователю + боту
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
-- Таблица сессий чата
|
|
19
|
-
CREATE TABLE IF NOT EXISTS sales_chat_sessions (
|
|
20
|
-
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
21
|
-
user_id BIGINT NOT NULL,
|
|
22
|
-
bot_id TEXT NOT NULL, -- 🆕 Идентификатор бота
|
|
23
|
-
system_prompt TEXT NOT NULL,
|
|
24
|
-
status TEXT DEFAULT 'active' CHECK (status IN ('active', 'completed', 'archived')),
|
|
25
|
-
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
26
|
-
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
27
|
-
metadata JSONB DEFAULT '{}'::jsonb,
|
|
28
|
-
FOREIGN KEY (user_id, bot_id) REFERENCES sales_users(telegram_id, bot_id) ON DELETE CASCADE
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
-- Остальные таблицы без изменений, так как они ссылаются на сессии
|
|
32
|
-
|
|
33
|
-
-- Обновляем индексы
|
|
34
|
-
CREATE INDEX IF NOT EXISTS idx_sales_users_telegram_bot ON sales_users(telegram_id, bot_id);
|
|
35
|
-
CREATE INDEX IF NOT EXISTS idx_sales_users_bot_id ON sales_users(bot_id);
|
|
36
|
-
CREATE INDEX IF NOT EXISTS idx_sales_chat_sessions_bot_id ON sales_chat_sessions(bot_id);
|
|
37
|
-
CREATE INDEX IF NOT EXISTS idx_sales_chat_sessions_user_bot ON sales_chat_sessions(user_id, bot_id);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-- Обновляем политики RLS
|
|
41
|
-
DROP POLICY IF EXISTS "Users can view their own data" ON sales_users;
|
|
42
|
-
CREATE POLICY "Users can view their own data" ON sales_users
|
|
43
|
-
FOR SELECT USING (
|
|
44
|
-
telegram_id = current_setting('app.current_user_id')::bigint
|
|
45
|
-
AND bot_id = current_setting('app.current_bot_id')
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
DROP POLICY IF EXISTS "Users can view their own sessions" ON sales_chat_sessions;
|
|
49
|
-
CREATE POLICY "Users can view their own sessions" ON sales_chat_sessions
|
|
50
|
-
FOR SELECT USING (
|
|
51
|
-
user_id = current_setting('app.current_user_id')::bigint
|
|
52
|
-
AND bot_id = current_setting('app.current_bot_id')
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
-- Комментарии
|
|
56
|
-
COMMENT ON COLUMN sales_users.bot_id IS 'Идентификатор бота (имя запускалки без .py)';
|
|
57
|
-
COMMENT ON COLUMN sales_chat_sessions.bot_id IS 'Идентификатор бота для разделения данных между ботами';
|