smart-bot-factory 0.1.4__tar.gz → 0.1.6__tar.gz

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.

Files changed (120) hide show
  1. smart_bot_factory-0.1.6/CLIENTS_USAGE.md +74 -0
  2. smart_bot_factory-0.1.6/PKG-INFO +466 -0
  3. smart_bot_factory-0.1.6/README.md +433 -0
  4. smart_bot_factory-0.1.6/ROUTER_ARCHITECTURE.md +152 -0
  5. smart_bot_factory-0.1.6/best-valera.py +136 -0
  6. smart_bot_factory-0.1.6/bot_testing.py +977 -0
  7. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/prompts/final_instructions.txt +6 -0
  8. smart_bot_factory-0.1.6/bots/best-valera/tests/quick_scenarios.yaml +133 -0
  9. smart_bot_factory-0.1.6/configs/valera/cats//320/224/320/276/320/263/320/276/320/262/320/276/321/200.pdf +0 -0
  10. smart_bot_factory-0.1.6/configs/valera/cats//320/272/320/276/320/275/320/270.jpg +0 -0
  11. smart_bot_factory-0.1.6/configs/valera/cats//320/272/320/276/321/202.jpg +0 -0
  12. smart_bot_factory-0.1.6/configs/valera/cats//320/273/320/265/321/201.jpg +0 -0
  13. smart_bot_factory-0.1.6/configs/valera/tests/fixes_elina.yaml +14 -0
  14. smart_bot_factory-0.1.6/example_usage.py +69 -0
  15. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/pyproject.toml +2 -2
  16. smart_bot_factory-0.1.6/smart_bot_factory/__init__.py +3 -0
  17. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/admin_logic.py +11 -11
  18. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/cli.py +147 -85
  19. smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24/prompts/1sales_context.txt +16 -0
  20. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/configs/growthmed-october-24/prompts/final_instructions.txt +2 -0
  21. smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24/tests/quick_scenarios.yaml +133 -0
  22. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/core/bot_utils.py +224 -88
  23. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/core/conversation_manager.py +542 -535
  24. smart_bot_factory-0.1.6/smart_bot_factory/core/decorators.py +927 -0
  25. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/core/message_sender.py +2 -7
  26. smart_bot_factory-0.1.6/smart_bot_factory/core/router.py +173 -0
  27. smart_bot_factory-0.1.6/smart_bot_factory/core/router_manager.py +166 -0
  28. smart_bot_factory-0.1.6/smart_bot_factory/creation/__init__.py +7 -0
  29. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/creation/bot_builder.py +103 -13
  30. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/creation/bot_testing.py +74 -13
  31. smart_bot_factory-0.1.6/smart_bot_factory/event/__init__.py +12 -0
  32. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/handlers/handlers.py +10 -2
  33. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/integrations/supabase_client.py +272 -2
  34. smart_bot_factory-0.1.6/smart_bot_factory/message/__init__.py +12 -0
  35. smart_bot_factory-0.1.6/smart_bot_factory/router/__init__.py +9 -0
  36. smart_bot_factory-0.1.6/smart_bot_factory/supabase/__init__.py +7 -0
  37. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/uv.lock +1 -1
  38. smart_bot_factory-0.1.4/PKG-INFO +0 -126
  39. smart_bot_factory-0.1.4/README.md +0 -93
  40. smart_bot_factory-0.1.4/best-valera.py +0 -71
  41. smart_bot_factory-0.1.4/bots/best-valera/tests/quick_scenarios.yaml +0 -66
  42. smart_bot_factory-0.1.4/bots/valera/prompts/final_instructions.txt +0 -212
  43. smart_bot_factory-0.1.4/bots/valera/tests/quick_scenarios.yaml +0 -66
  44. smart_bot_factory-0.1.4/smart_bot_factory/__init__.py +0 -33
  45. smart_bot_factory-0.1.4/smart_bot_factory/analytics/__init__.py +0 -7
  46. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/1sales_context.txt +0 -9
  47. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/2product_info.txt +0 -582
  48. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/3objection_handling.txt +0 -66
  49. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/final_instructions.txt +0 -232
  50. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/help_message.txt +0 -28
  51. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/prompts/welcome_message.txt +0 -7
  52. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/welcome_file/welcome_file_msg.txt +0 -16
  53. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/prompts/2product_info.txt +0 -582
  54. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/prompts/3objection_handling.txt +0 -66
  55. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/prompts/help_message.txt +0 -28
  56. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/prompts/welcome_message.txt +0 -8
  57. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/tests/quick_scenarios.yaml +0 -66
  58. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/tests/realistic_scenarios.yaml +0 -108
  59. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/tests/scenario_examples.yaml +0 -46
  60. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/welcome_file/welcome_file_msg.txt +0 -16
  61. smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24/welcome_file//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf +0 -0
  62. smart_bot_factory-0.1.4/smart_bot_factory/core/__init__.py +0 -22
  63. smart_bot_factory-0.1.4/smart_bot_factory/core/decorators.py +0 -230
  64. smart_bot_factory-0.1.4/smart_bot_factory/creation/__init__.py +0 -8
  65. smart_bot_factory-0.1.4/smart_bot_factory/integrations/__init__.py +0 -9
  66. smart_bot_factory-0.1.4/valera.py +0 -71
  67. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.github/ISSUE_TEMPLATE//342/234/250-/320/267/320/260/320/277/321/200/320/276/321/201-/321/204/321/203/320/275/320/272/321/206/320/270/320/270.md" +0 -0
  68. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.github/ISSUE_TEMPLATE//360/237/220/233-/320/261/320/260/320/263-/321/200/320/265/320/277/320/276/321/200/321/202.md" +0 -0
  69. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.github/workflows/ci.yml +0 -0
  70. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.github/workflows/publish-private.yml +0 -0
  71. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.github/workflows/publish.yml +0 -0
  72. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.gitignore +0 -0
  73. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/.python-version +0 -0
  74. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/Dockerfile +0 -0
  75. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/LICENSE +0 -0
  76. {smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-october-24 → smart_bot_factory-0.1.6/bots/best-valera}/prompts/1sales_context.txt +0 -0
  77. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/prompts/2product_info.txt +0 -0
  78. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/prompts/3objection_handling.txt +0 -0
  79. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/prompts/help_message.txt +0 -0
  80. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/prompts/welcome_message.txt +0 -0
  81. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/tests/realistic_scenarios.yaml +0 -0
  82. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/tests/scenario_examples.yaml +0 -0
  83. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/welcome_files/welcome_file_msg.txt +0 -0
  84. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/bots/best-valera/welcome_files//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf" +0 -0
  85. {smart_bot_factory-0.1.4/bots/valera/welcome_files → smart_bot_factory-0.1.6/configs/valera/welcome_file}//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf" +0 -0
  86. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/create_tag.sh +0 -0
  87. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/docker-compose.yml +0 -0
  88. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/env.example +0 -0
  89. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/requirements.txt +0 -0
  90. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/save_backup.sh +0 -0
  91. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/save_fixes.sh +0 -0
  92. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/__init__.py +0 -0
  93. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/admin_manager.py +0 -0
  94. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/admin_migration.sql +0 -0
  95. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/admin_tester.py +0 -0
  96. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/admin/timeout_checker.py +0 -0
  97. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/analytics/analytics_manager.py +0 -0
  98. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/config.py +0 -0
  99. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/prompts/2product_info.txt +0 -0
  100. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/prompts/3objection_handling.txt +0 -0
  101. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/prompts/help_message.txt +0 -0
  102. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/prompts/welcome_message.txt +0 -0
  103. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/configs/growthmed-october-24/reports/test_20250924_064229.txt +0 -0
  104. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/configs/growthmed-october-24/reports/test_20250924_064335.txt +0 -0
  105. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/configs/growthmed-october-24/reports/test_20250924_064638.txt +0 -0
  106. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/tests/realistic_scenarios.yaml +0 -0
  107. {smart_bot_factory-0.1.4/bots/valera → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/tests/scenario_examples.yaml +0 -0
  108. {smart_bot_factory-0.1.4/bots/valera/welcome_files → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24/welcome_file}/welcome_file_msg.txt +0 -0
  109. {smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper → smart_bot_factory-0.1.6/smart_bot_factory/configs/growthmed-october-24}/welcome_file//320/247/320/265/320/272 /320/273/320/270/321/201/321/202 /320/277/320/276 152/320/244/320/227 /320/270 323/320/244/320/227 /320/264/320/273/321/217 /320/274/320/265/320/264/320/270/321/206/320/270/320/275/321/213.pdf" +0 -0
  110. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/core/states.py +0 -0
  111. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/database/database_structure.sql +0 -0
  112. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/database/schema.sql +0 -0
  113. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/integrations/openai_client.py +0 -0
  114. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/setup_checker.py +0 -0
  115. /smart_bot_factory-0.1.4/smart_bot_factory/configs/growthmed-helper/env_example.txt → /smart_bot_factory-0.1.6/smart_bot_factory/supabase/example_usage.py +0 -0
  116. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/utils/__init__.py +0 -0
  117. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/utils/debug_routing.py +0 -0
  118. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/utils/prompt_loader.py +0 -0
  119. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/smart_bot_factory/utm_link_generator.py +0 -0
  120. {smart_bot_factory-0.1.4 → smart_bot_factory-0.1.6}/system_prompt_example.txt +0 -0
@@ -0,0 +1,74 @@
1
+ # Использование клиентов в Smart Bot Factory
2
+
3
+ ## Простой импорт клиентов
4
+
5
+ ```python
6
+ from smart_bot_factory.clients import supabase_client, openai_client
7
+ ```
8
+
9
+ ## Автозаполнение работает!
10
+
11
+ После импорта IDE знает типы и предлагает:
12
+
13
+ ### Supabase Client
14
+ ```python
15
+ # IDE предлагает методы SupabaseClient
16
+ users = supabase_client.client.table('users').select('*').execute()
17
+ user = supabase_client.create_or_get_user(user_data)
18
+ session = supabase_client.create_chat_session(user_data, system_prompt)
19
+ ```
20
+
21
+ ### OpenAI Client
22
+ ```python
23
+ # IDE предлагает методы OpenAIClient
24
+ response = openai_client.chat.completions.create(
25
+ model="gpt-4o-mini",
26
+ messages=[{"role": "user", "content": "Hello"}]
27
+ )
28
+ ```
29
+
30
+ ## Пример глобального обработчика
31
+
32
+ ```python
33
+ from smart_bot_factory.core import global_handler
34
+ from smart_bot_factory.clients import supabase_client
35
+
36
+ @global_handler("mass_notification", notify=True)
37
+ async def send_mass_notification(message_text: str):
38
+ """Отправляет сообщение всем пользователям"""
39
+
40
+ # Проверяем доступность
41
+ if not supabase_client:
42
+ return {"status": "error", "message": "Supabase клиент не найден"}
43
+
44
+ try:
45
+ # Получаем всех пользователей - автозаполнение работает!
46
+ users = supabase_client.client.table('users').select('telegram_id').execute()
47
+
48
+ sent_count = 0
49
+ for user in users.data:
50
+ # Отправляем сообщение каждому пользователю
51
+ # ... логика отправки ...
52
+ sent_count += 1
53
+
54
+ return {
55
+ "status": "completed",
56
+ "sent_count": sent_count,
57
+ "message": f"Отправлено {sent_count} сообщений"
58
+ }
59
+
60
+ except Exception as e:
61
+ return {"status": "error", "message": str(e)}
62
+ ```
63
+
64
+ ## Доступные клиенты
65
+
66
+ - `supabase_client` - клиент для работы с Supabase
67
+ - `openai_client` - клиент для работы с OpenAI
68
+
69
+ ## Важно
70
+
71
+ - Клиенты доступны только после запуска бота через `BotBuilder`
72
+ - Все клиенты типизированы для полной поддержки автозаполнения
73
+ - Остальные глобальные переменные (config, admin_manager и т.д.) недоступны пользователю
74
+
@@ -0,0 +1,466 @@
1
+ Metadata-Version: 2.4
2
+ Name: smart-bot-factory
3
+ Version: 0.1.6
4
+ Summary: Библиотека для создания умных чат-ботов
5
+ Author-email: Kopatych <herousplay@gmail.com>
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Keywords: chatbot,cli,openai,supabase,telegram
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: Framework :: AsyncIO
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Communications :: Chat
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Requires-Dist: aiofiles>=23.0.0
24
+ Requires-Dist: aiogram>=3.4.1
25
+ Requires-Dist: click>=8.0.0
26
+ Requires-Dist: openai>=1.12.0
27
+ Requires-Dist: project-root-finder>=1.9
28
+ Requires-Dist: python-dotenv>=1.0.1
29
+ Requires-Dist: pytz>=2023.3
30
+ Requires-Dist: pyyaml>=6.0.2
31
+ Requires-Dist: supabase>=2.3.4
32
+ Description-Content-Type: text/markdown
33
+
34
+ # Smart Bot Factory
35
+
36
+ Инструмент для создания умных чат-ботов с поддержкой AI, административной панели и тестирования.
37
+
38
+ ## 🚀 Быстрый старт
39
+
40
+ ### Установка
41
+
42
+ ```bash
43
+ pip install smart-bot-factory
44
+ ```
45
+
46
+ ### Создание первого бота
47
+
48
+ ```bash
49
+ # Создать нового бота
50
+ sbf create my-bot
51
+
52
+ # Запустить бота
53
+ sbf run my-bot
54
+ ```
55
+
56
+ ## 📋 Команды CLI
57
+
58
+ ### `sbf create <bot_id> [template]`
59
+
60
+ Создает нового бота с указанным ID.
61
+
62
+ ```bash
63
+ # Создать бота с базовым шаблоном
64
+ sbf create my-bot
65
+
66
+ # Создать бота на основе существующего
67
+ sbf create new-bot existing-bot
68
+ ```
69
+
70
+ **Что создается:**
71
+ - 📁 `bots/my-bot/` - папка с конфигурацией бота
72
+ - 📄 `my-bot.py` - файл для запуска бота
73
+ - ⚙️ `.env` - файл конфигурации
74
+ - 📝 Промпты, тесты, файлы из шаблона
75
+
76
+ ### `sbf run <bot_id>`
77
+
78
+ Запускает бота в рабочем режиме.
79
+
80
+ ```bash
81
+ sbf run my-bot
82
+ ```
83
+
84
+ **Автоматически:**
85
+ - ✅ Проверяет наличие всех необходимых файлов
86
+ - ⚙️ Загружает конфигурацию из `.env`
87
+ - 🚀 Запускает бота
88
+
89
+ ### `sbf test <bot_id> [options]`
90
+
91
+ Запускает тесты бота.
92
+
93
+ ```bash
94
+ # Все тесты
95
+ sbf test my-bot
96
+
97
+ # Конкретный файл тестов
98
+ sbf test my-bot scenario_examples.yaml
99
+
100
+ # Подробный вывод
101
+ sbf test my-bot -v
102
+
103
+ # Больше потоков для быстрого тестирования
104
+ sbf test my-bot --max-concurrent 10
105
+ ```
106
+
107
+ ### `sbf list`
108
+
109
+ Показывает список всех доступных ботов.
110
+
111
+ ```bash
112
+ sbf list
113
+ ```
114
+
115
+ ### `sbf config <bot_id>`
116
+
117
+ Открывает конфигурацию бота в редакторе.
118
+
119
+ ```bash
120
+ sbf config my-bot
121
+ ```
122
+
123
+ ### `sbf prompts <bot_id> [options]`
124
+
125
+ Управление промптами бота.
126
+
127
+ ```bash
128
+ # Показать список промптов
129
+ sbf prompts my-bot --list
130
+
131
+ # Редактировать промпт
132
+ sbf prompts my-bot --edit system_prompt
133
+
134
+ # Добавить новый промпт
135
+ sbf prompts my-bot --add custom_prompt
136
+ ```
137
+
138
+ ### `sbf copy <source_bot> <new_bot>`
139
+
140
+ Копирует существующего бота как шаблон.
141
+
142
+ ```bash
143
+ # Скопировать бота
144
+ sbf copy my-bot my-bot-v2
145
+
146
+ # Перезаписать существующего бота
147
+ sbf copy my-bot my-bot-v2 --force
148
+ ```
149
+
150
+ ### `sbf rm <bot_id>`
151
+
152
+ Удаляет бота и все его файлы.
153
+
154
+ ```bash
155
+ # Удалить с подтверждением
156
+ sbf rm my-bot
157
+
158
+ # Удалить без подтверждения
159
+ sbf rm my-bot --force
160
+ ```
161
+
162
+ ### `sbf link`
163
+
164
+ Создает UTM-ссылки для бота.
165
+
166
+ ```bash
167
+ sbf link
168
+ ```
169
+
170
+ ### `sbf path`
171
+
172
+ Показывает путь к проекту.
173
+
174
+ ```bash
175
+ sbf path
176
+ ```
177
+
178
+ ## 🏗️ Структура проекта
179
+
180
+ ```
181
+ project/
182
+ ├── bots/
183
+ │ └── my-bot/
184
+ │ ├── .env # Конфигурация
185
+ │ ├── prompts/ # Промпты
186
+ │ │ ├── system_prompt.txt
187
+ │ │ ├── welcome_message.txt
188
+ │ │ └── final_instructions.txt
189
+ │ ├── tests/ # Тесты
190
+ │ │ └── scenario_examples.yaml
191
+ │ ├── reports/ # Отчеты тестирования
192
+ │ ├── welcome_files/ # Файлы для приветствия
193
+ │ └── files/ # Дополнительные файлы
194
+ ├── my-bot.py # Файл запуска бота
195
+ └── smart_bot_factory/ # Библиотека
196
+ ```
197
+
198
+ ## ⚙️ Конфигурация (.env)
199
+
200
+ ```env
201
+ # Telegram
202
+ TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
203
+
204
+ # Supabase
205
+ SUPABASE_URL=https://your-project.supabase.co
206
+ SUPABASE_KEY=your_supabase_anon_key
207
+
208
+ # OpenAI
209
+ OPENAI_API_KEY=sk-your-openai-api-key
210
+ OPENAI_MODEL=gpt-4
211
+ OPENAI_MAX_TOKENS=1500
212
+ OPENAI_TEMPERATURE=0.7
213
+
214
+ # Администраторы
215
+ ADMIN_TELEGRAM_IDS=123456789,987654321
216
+ ADMIN_SESSION_TIMEOUT_MINUTES=30
217
+
218
+ # Настройки
219
+ DEBUG_MODE=false
220
+ MAX_CONTEXT_MESSAGES=50
221
+ LOG_LEVEL=INFO
222
+ MESSAGE_PARSE_MODE=Markdown
223
+ ```
224
+
225
+ ## 🧪 Тестирование
226
+
227
+ ### Формат тестов (YAML)
228
+
229
+ ```yaml
230
+ scenarios:
231
+ - name: "Тест приветствия"
232
+ steps:
233
+ - user_input: "Привет!"
234
+ expected_keywords:
235
+ - ["привет", "здравствуйте", "добро пожаловать"]
236
+ - ["помочь", "помощь"]
237
+ forbidden_keywords: ["пока", "до свидания"]
238
+
239
+ - name: "Тест с синонимами"
240
+ steps:
241
+ - user_input: "Сколько это стоит?"
242
+ expected_keywords:
243
+ - ["стоит", "цена", "стоимость", "сколько"]
244
+ - ["рубл", "пакет", "вариант"]
245
+ forbidden_keywords: ["бесплатно"]
246
+ ```
247
+
248
+ ### Поддержка синонимов
249
+
250
+ В `expected_keywords` можно использовать:
251
+ - **Одно слово:** `["привет"]`
252
+ - **Синонимы:** `[["привет", "здравствуйте", "добро пожаловать"]]`
253
+ - **Смешанный формат:** `["привет", ["здравствуйте", "добро пожаловать"]]`
254
+
255
+ ## 🤖 Программирование ботов
256
+
257
+ ### Основной файл бота
258
+
259
+ ```python
260
+ #!/usr/bin/env python3
261
+ """
262
+ Бот my-bot - создан с помощью Smart Bot Factory
263
+ """
264
+
265
+ import asyncio
266
+ from smart_bot_factory.core import event_handler, send_message_by_human
267
+ from smart_bot_factory.creation import BotBuilder
268
+
269
+ # =============================================================================
270
+ # ОБРАБОТЧИКИ СОБЫТИЙ
271
+ # =============================================================================
272
+
273
+ @event_handler("appointment_booking", "Записывает пользователя на прием")
274
+ async def handle_appointment(user_id: int, event_data: dict):
275
+ """Обработчик записи на прием"""
276
+ await send_message_by_human(
277
+ user_id=user_id,
278
+ message_text="✅ Ваша запись на прием подтверждена!"
279
+ )
280
+
281
+ return {
282
+ "status": "success",
283
+ "appointment_id": "123"
284
+ }
285
+
286
+ # =============================================================================
287
+ # ОСНОВНАЯ ФУНКЦИЯ
288
+ # =============================================================================
289
+
290
+ async def main():
291
+ """Основная функция запуска бота"""
292
+ try:
293
+ # Создаем и собираем бота
294
+ bot_builder = BotBuilder("my-bot")
295
+ await bot_builder.build()
296
+
297
+ # Запускаем бота
298
+ await bot_builder.start()
299
+
300
+ except Exception as e:
301
+ print(f"❌ Ошибка запуска бота: {e}")
302
+ raise
303
+
304
+ if __name__ == "__main__":
305
+ asyncio.run(main())
306
+ ```
307
+
308
+ ### Обработчики событий
309
+
310
+ ```python
311
+ @event_handler("phone_collection", "Собирает номер телефона")
312
+ async def collect_phone(user_id: int, event_data: dict):
313
+ """Сбор номера телефона"""
314
+ phone = event_data.get('phone')
315
+ # Логика сохранения номера
316
+
317
+ return {
318
+ "status": "success",
319
+ "phone": phone
320
+ }
321
+ ```
322
+
323
+ ## 👑 Административная панель
324
+
325
+ ### Команды для админов
326
+
327
+ - `/admin` - Вход в режим администратора
328
+ - `/чаты` - Показать активные диалоги
329
+ - `/чат <user_id>` - Начать диалог с пользователем
330
+ - `/завершить` - Завершить текущий диалог
331
+ - `/отладка <user_id>` - Отладочная информация
332
+
333
+ ### Живой чат
334
+
335
+ Админы могут:
336
+ - 💬 Вести диалоги с пользователями в реальном времени
337
+ - 📊 Видеть историю сообщений
338
+ - ⏰ Автоматическое завершение диалогов по таймауту
339
+ - 🎛️ Управление через кнопки
340
+
341
+ ## 📊 Отчеты и аналитика
342
+
343
+ ### Тестирование
344
+
345
+ - 📈 Детальные отчеты по каждому тесту
346
+ - ⏱️ Время выполнения тестов
347
+ - 📊 Статистика прохождения
348
+ - 💾 Сохранение отчетов в `bots/my-bot/reports/`
349
+
350
+ ### Логирование
351
+
352
+ ```bash
353
+ # Уровни логирования
354
+ LOG_LEVEL=DEBUG # Подробная отладка
355
+ LOG_LEVEL=INFO # Основная информация
356
+ LOG_LEVEL=WARNING # Только предупреждения
357
+ LOG_LEVEL=ERROR # Только ошибки
358
+ ```
359
+
360
+ ## 🔧 Расширенные возможности
361
+
362
+ ### UTM-трекинг
363
+
364
+ ```bash
365
+ # Генерация UTM-ссылок
366
+ sbf link
367
+ ```
368
+
369
+ Поддерживаемые параметры:
370
+ - `utm_source` - источник трафика
371
+ - `utm_medium` - канал
372
+ - `utm_campaign` - кампания
373
+ - `utm_content` - контент
374
+ - `utm_term` - ключевое слово
375
+
376
+ ### Файлы и медиа
377
+
378
+ - 📁 `welcome_files/` - файлы для приветствия
379
+ - 📎 `files/` - дополнительные файлы бота
380
+ - 🖼️ Поддержка изображений, документов, видео
381
+
382
+ ### Кастомизация промптов
383
+
384
+ ```bash
385
+ # Редактирование системного промпта
386
+ sbf prompts my-bot --edit system_prompt
387
+
388
+ # Создание нового промпта
389
+ sbf prompts my-bot --add custom_instructions
390
+ ```
391
+
392
+ ## 🆘 Поддержка и помощь
393
+
394
+ ### Частые проблемы
395
+
396
+ 1. **Бот не запускается**
397
+ - Проверьте `.env` файл
398
+ - Убедитесь в правильности токенов
399
+ - Проверьте логи: `LOG_LEVEL=DEBUG`
400
+
401
+ 2. **Тесты не проходят**
402
+ - Проверьте формат YAML
403
+ - Используйте `-v` для подробного вывода
404
+ - Убедитесь в корректности ключевых слов
405
+
406
+ 3. **Админские функции не работают**
407
+ - Проверьте `ADMIN_TELEGRAM_IDS` в `.env`
408
+ - Убедитесь, что ID указан правильно
409
+ - Используйте `/admin` для входа в режим
410
+
411
+ ### Отладка
412
+
413
+ ```bash
414
+ # Включить режим отладки
415
+ DEBUG_MODE=true
416
+
417
+ # Подробные логи
418
+ LOG_LEVEL=DEBUG
419
+
420
+ # Тестирование с подробным выводом
421
+ sbf test my-bot -v
422
+ ```
423
+
424
+ ## 📚 Примеры
425
+
426
+ ### Полный цикл разработки
427
+
428
+ ```bash
429
+ # 1. Создать бота
430
+ sbf create sales-bot
431
+
432
+ # 2. Настроить конфигурацию
433
+ sbf config sales-bot
434
+
435
+ # 3. Редактировать промпты
436
+ sbf prompts sales-bot --edit system_prompt
437
+
438
+ # 4. Создать тесты
439
+ sbf prompts sales-bot --add test_scenarios
440
+
441
+ # 5. Запустить тесты
442
+ sbf test sales-bot -v
443
+
444
+ # 6. Запустить бота
445
+ sbf run sales-bot
446
+ ```
447
+
448
+ ### Копирование и модификация
449
+
450
+ ```bash
451
+ # Скопировать успешного бота
452
+ sbf copy sales-bot sales-bot-v2
453
+
454
+ # Модифицировать копию
455
+ sbf prompts sales-bot-v2 --edit system_prompt
456
+
457
+ # Протестировать изменения
458
+ sbf test sales-bot-v2
459
+
460
+ # Запустить новую версию
461
+ sbf run sales-bot-v2
462
+ ```
463
+
464
+ ---
465
+
466
+ **Smart Bot Factory** - создавайте умных ботов быстро и эффективно! 🚀