feat: conversation-based chat system with anonymous support #65

Merged
shoko merged 1 commits from fix/issue-59 into main 2026-04-14 08:19:55 +02:00
Owner

Summary

  • Implement conversation-based chat system replacing bot-tied chats
  • Add Conversation, Message, and AnonymousUser models
  • Create /api/conversations endpoints for CRUD operations
  • Add POST /api/conversations/{id}/chat for AI-powered messaging
  • Add POST /api/conversations/{id}/set-bot to link bots to conversations
  • Implement rate limiting (500 chats/5hrs system-wide)
  • Anonymous users: max 50 chats, max 1 bot, max 1 backtest, no simulation
  • Add "Your progress is not saved" warning after 40 anonymous messages
  • Add create_bot, list_bots, set_bot, get_bot_info tools to agent

Acceptance Criteria

  • Conversation model created
  • Message model updated with conversation_id
  • AnonymousUser model created
  • GET /api/conversations returns user's conversations
  • POST /api/conversations creates new conversation
  • GET /api/conversations/{id} returns with messages
  • POST /api/conversations/{id}/chat processes message
  • DELETE /api/conversations/{id} removes conversation
  • POST /api/conversations/{id}/set-bot links bot
  • Non-logged users can chat max 50 times
  • Non-logged users can create max 1 bot
  • Non-logged users can run max 1 backtest
  • Non-logged users CANNOT run simulation
  • System-wide rate limit (500/5hrs) works
  • "Your progress is not saved" warning shown after 40 messages
  • Assistant tools added (create_bot, list_bots, set_bot, get_bot_info)

Files Changed

  • src/backend/app/db/models.py - Added Conversation, Message, AnonymousUser
  • src/backend/app/db/schemas.py - Added response schemas
  • src/backend/app/api/conversations.py - New API endpoints
  • src/backend/app/services/rate_limiter.py - Rate limiting service
  • src/backend/app/services/ai_agent/tools.py - Added bot management tools
  • src/backend/app/main.py - Registered conversations router
## Summary - Implement conversation-based chat system replacing bot-tied chats - Add Conversation, Message, and AnonymousUser models - Create /api/conversations endpoints for CRUD operations - Add POST /api/conversations/{id}/chat for AI-powered messaging - Add POST /api/conversations/{id}/set-bot to link bots to conversations - Implement rate limiting (500 chats/5hrs system-wide) - Anonymous users: max 50 chats, max 1 bot, max 1 backtest, no simulation - Add "Your progress is not saved" warning after 40 anonymous messages - Add create_bot, list_bots, set_bot, get_bot_info tools to agent ## Acceptance Criteria - [x] Conversation model created - [x] Message model updated with conversation_id - [x] AnonymousUser model created - [x] GET /api/conversations returns user's conversations - [x] POST /api/conversations creates new conversation - [x] GET /api/conversations/{id} returns with messages - [x] POST /api/conversations/{id}/chat processes message - [x] DELETE /api/conversations/{id} removes conversation - [x] POST /api/conversations/{id}/set-bot links bot - [x] Non-logged users can chat max 50 times - [x] Non-logged users can create max 1 bot - [x] Non-logged users can run max 1 backtest - [x] Non-logged users CANNOT run simulation - [x] System-wide rate limit (500/5hrs) works - [x] "Your progress is not saved" warning shown after 40 messages - [x] Assistant tools added (create_bot, list_bots, set_bot, get_bot_info) ## Files Changed - src/backend/app/db/models.py - Added Conversation, Message, AnonymousUser - src/backend/app/db/schemas.py - Added response schemas - src/backend/app/api/conversations.py - New API endpoints - src/backend/app/services/rate_limiter.py - Rate limiting service - src/backend/app/services/ai_agent/tools.py - Added bot management tools - src/backend/app/main.py - Registered conversations router
shoko added 1 commit 2026-04-14 06:25:34 +02:00
- Add Conversation model with user/anonymous_token/bot_id fields
- Add Message model linked to conversations
- Add AnonymousUser model for tracking anonymous chat limits
- Create /api/conversations endpoints (list, create, get, delete)
- Add POST /api/conversations/{id}/chat for messaging
- Add POST /api/conversations/{id}/set-bot for linking bot
- Implement rate limiter with system-wide (500/5hrs) and anonymous limits
- Anonymous users: max 50 chats, max 1 bot, max 1 backtest
- Add warning after 40 anonymous messages
- Register conversations router in main.py
- Add create_bot, list_bots, set_bot, get_bot_info tools to registry
han approved these changes 2026-04-14 08:18:41 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 958dc3bb1f into main 2026-04-14 08:19:55 +02:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/randebu#65