diff --git a/core/__pycache__/models.cpython-311.pyc b/core/__pycache__/models.cpython-311.pyc index c6ae9db..a1c59e5 100644 Binary files a/core/__pycache__/models.cpython-311.pyc and b/core/__pycache__/models.cpython-311.pyc differ diff --git a/core/__pycache__/urls.cpython-311.pyc b/core/__pycache__/urls.cpython-311.pyc index 0a046db..b6c3cc4 100644 Binary files a/core/__pycache__/urls.cpython-311.pyc and b/core/__pycache__/urls.cpython-311.pyc differ diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index e1d23ec..0c8979a 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/migrations/0007_conversation_is_generating.py b/core/migrations/0007_conversation_is_generating.py new file mode 100644 index 0000000..5672f81 --- /dev/null +++ b/core/migrations/0007_conversation_is_generating.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.7 on 2025-11-20 19:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0006_setting'), + ] + + operations = [ + migrations.AddField( + model_name='conversation', + name='is_generating', + field=models.BooleanField(default=False), + ), + ] diff --git a/core/migrations/__pycache__/0007_conversation_is_generating.cpython-311.pyc b/core/migrations/__pycache__/0007_conversation_is_generating.cpython-311.pyc new file mode 100644 index 0000000..5ac732d Binary files /dev/null and b/core/migrations/__pycache__/0007_conversation_is_generating.cpython-311.pyc differ diff --git a/core/models.py b/core/models.py index 01752e5..51ac0a9 100644 --- a/core/models.py +++ b/core/models.py @@ -27,6 +27,7 @@ class TodoItem(models.Model): class Conversation(models.Model): title = models.CharField(max_length=200) + is_generating = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) def __str__(self): diff --git a/core/templates/core/chat.html b/core/templates/core/chat.html index 8180408..eac796e 100644 --- a/core/templates/core/chat.html +++ b/core/templates/core/chat.html @@ -81,95 +81,203 @@ diff --git a/core/urls.py b/core/urls.py index b1dc985..f6ced36 100644 --- a/core/urls.py +++ b/core/urls.py @@ -13,4 +13,5 @@ urlpatterns = [ path('chat//', views.chat_view, name='chat_detail'), path('cleanup_tasks/', views.cleanup_tasks, name='cleanup_tasks'), path('settings/', views.settings_view, name='settings'), + path('get_conversation_messages//', views.get_conversation_messages, name='get_conversation_messages'), ] \ No newline at end of file diff --git a/core/views.py b/core/views.py index a6ee8e2..032e2ef 100644 --- a/core/views.py +++ b/core/views.py @@ -352,12 +352,17 @@ def chat_view(request, conversation_id=None): conversation = get_object_or_404(Conversation, id=conversation_id) Message.objects.create(conversation=conversation, content=text, sender='user') + # Set is_generating to True + conversation.is_generating = True + conversation.save() + # Start AI processing in a background thread thread = threading.Thread(target=run_ai_process_in_background, args=(conversation_id,)) thread.daemon = True thread.start() - return redirect('core:chat_detail', conversation_id=conversation_id) + return JsonResponse({'status': 'success', 'conversation_id': conversation_id}) + return JsonResponse({'status': 'error', 'message': 'Text is required.'}, status=400) conversations = Conversation.objects.order_by('-created_at') selected_conversation = None