diff --git a/core/__pycache__/views.cpython-311.pyc b/core/__pycache__/views.cpython-311.pyc index 39d7686..c3c9e1e 100644 Binary files a/core/__pycache__/views.cpython-311.pyc and b/core/__pycache__/views.cpython-311.pyc differ diff --git a/core/views.py b/core/views.py index 677f84e..dcd9a32 100644 --- a/core/views.py +++ b/core/views.py @@ -1,3 +1,5 @@ +# core/views.py + from django.shortcuts import render, redirect, get_object_or_404 from django.http import JsonResponse from django.views.decorators.http import require_POST @@ -110,10 +112,11 @@ def execute_command(command_data): new_task = TodoItem.objects.create( title=title, description=args.get('description', ''), - status=args.get('status', 'todo') + status=args.get('status', 'todo'), + tags=args.get('tags', '') ) logger.info(f"Command 'add_task' executed successfully. New task ID: {new_task.id}") - return f"[SYSTEM] Command 'add_task' executed successfully. New task ID: {new_task.id}" + return f"[SYSTEM] Command 'add_task' executed successfully. A new task with ID {new_task.id}, title '{new_task.title}', description '{new_task.description}', status '{new_task.status}', and tags '{new_task.tags}' has been created." elif command_name == 'edit_task': task_id = args.get('task_id') @@ -129,10 +132,12 @@ def execute_command(command_data): task.description = args['description'] if 'status' in args: task.status = args['status'] + if 'tags' in args: + task.tags = args['tags'] task.save() logger.info(f"Command 'edit_task' for task ID {task_id} executed successfully.") - return f"[SYSTEM] Command 'edit_task' for task ID {task_id} executed successfully." + return f"[SYSTEM] Command 'edit_task' for task ID {task_id} executed successfully. The task now has title '{task.title}', description '{task.description}', status '{task.status}', and tags '{task.tags}'." elif command_name == 'delete_task': task_id = args.get('task_id') @@ -202,14 +207,16 @@ def run_ai_process_in_background(conversation_id): * `add_task`: Adds a new task. * `args`: * `title` (string, required): The title of the task. - * `description` (string, optional): The description of the task. - * `status` (string, optional, default: 'todo'): The status of the task. Can be 'todo', 'inprogress', 'done', 'blocked'. + * `description` (string, optional): A detailed description of the task. + * `status` (string, optional, default: 'todo'): The status of the task. Valid options are 'todo', 'inprogress', 'done', 'blocked'. + * `tags` (string, optional): A comma-separated string of tags (e.g., "work,urgent"). * `edit_task`: Edits an existing task. * `args`: * `task_id` (integer, required): The ID of the task to edit. * `title` (string, optional): The new title. * `description` (string, optional): The new description. - * `status` (string, optional): The new status. + * `status` (string, optional): The new status. Valid options are 'todo', 'inprogress', 'done', 'blocked'. + * `tags` (string, optional): The new comma-separated string of tags. * `delete_task`: Deletes a task. * `args`: * `task_id` (integer, required): The ID of the task to delete. @@ -239,14 +246,15 @@ def run_ai_process_in_background(conversation_id): } } ``` -* **User:** "add a new task to buy milk" +* **User:** "add a new task to buy milk with tag 'personal'" * **Correct AI Response:** ```json { "command": { "name": "add_task", "args": { - "title": "buy milk" + "title": "buy milk", + "tags": "personal" } } } @@ -256,9 +264,10 @@ def run_ai_process_in_background(conversation_id): } tasks = TodoItem.objects.all().order_by('created_at') - task_list_str = "\n".join([ - f"- ID {task.id}: {task.title} (Status: {task.get_status_display()}, Tags: {task.tags or 'None'})" for task in tasks - ]) + task_list = [] + for task in tasks: + task_list.append(f"- ID {task.id}: {task.title} (Status: {task.get_status_display()}, Tags: {task.tags or 'None'})") + task_list_str = "\n".join(task_list) tasks_context = { "role": "system", @@ -404,3 +413,10 @@ def settings_view(request): return render(request, 'core/settings.html', { 'custom_instructions': custom_instructions }) + + +@require_POST +def delete_conversation(request, conversation_id): + conversation = get_object_or_404(Conversation, id=conversation_id) + conversation.delete() + return redirect('core:chat') \ No newline at end of file