-
Notifications
You must be signed in to change notification settings - Fork 28
initialize ai model #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
initialize ai model #141
Conversation
nic11371
commented
Nov 12, 2025
- инициализация и подключение к ИИ модели
- создание приложения ai
- добавление в env.example ключей для полключения АИ модели
maxjamchuk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Отличная заготовка для нового сервиса. Перед мёрджем необходимо исправить замечания с лейблами CAUTION и WARNING (путь приложения в apps.py, сетевой запрос при импорте, отсутствие таймаута, unique=True у полей сообщения, отсутствие миграций). Остальные комментарии — рекомендательные.
|
|
||
|
|
||
|
|
||
| AI_KEY="jf48694jcmkvb9t9erlcm9er48tmbo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
лучше не держать строку, похожую на реальный ключ. Даже если это “пример”, это приучает хранить “как будто настоящий” токен в репе. Предпочтительнее placeholder вида AI_KEY="your_key_here".
Если же это настоящий ключ, то его конечно же нужно отозвать и получить новый и больше никогда не выкладывать в GitHub.
|
|
||
|
|
||
|
|
||
| AI_KEY="jf48694jcmkvb9t9erlcm9er48tmbo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
именование AI_KEY в целом ок, но можно сделать более явным (AI_API_KEY) — чтобы не путать с внутренними ключами приложения.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
env-ключи добавлены, но пример ключа лучше сделать безопасным placeholder.
|
|
||
| class AiConfig(AppConfig): | ||
| default_auto_field = 'django.db.models.BigAutoField' | ||
| name = 'app.service.ai' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
AiConfig.name указан как app.service.ai, но путь до каталога — app/services/ai, т.е. должно быть app.services.ai. В текущем виде Django не сможет корректно найти приложение (и это всплывёт сразу при подключении в INSTALLED_APPS).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
есть блокирующая опечатка в имени приложения
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
блокирующий сайд-эффект при импорте + обязательный таймаут
| from django.db import models | ||
|
|
||
|
|
||
| class ChatMessage(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
для полей username, first_name, last_name, text выставлен unique=True.
Для модели сообщений это почти наверняка неверно: одинаковые username и одинаковый text будут встречаться в чате очень часто.
| from django.db import models | ||
|
|
||
|
|
||
| class ChatMessage(models.Model): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
message_id/user_id/chat_id как IntegerField с default=0 и null=True — спорная комбинация. Обычно либо null=False + валидное значение, либо null=True без “магического нуля”. Подумать над типами/ограничениями (и индексацией, если это внешние id).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
в PR нет миграций под модель. Если модель реально нужна — должна быть initial migration, иначе в проде модель “не существует” в БД.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
модель заведена, но ограничения unique=True критические