diff --git a/src/khoj/interface/web/config.html b/src/khoj/interface/web/config.html
index 882957d9..96e4fa55 100644
--- a/src/khoj/interface/web/config.html
+++ b/src/khoj/interface/web/config.html
@@ -280,7 +280,7 @@
Tasks
-
Manage your scheduled tasks handled by Khoj
+
Manage your scheduled tasks
diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py
index 65a99e79..88078c9b 100644
--- a/src/khoj/routers/api.py
+++ b/src/khoj/routers/api.py
@@ -3,6 +3,7 @@ import json
import logging
import math
import os
+import re
import time
import uuid
from typing import Any, Callable, List, Optional, Union
@@ -397,7 +398,11 @@ def get_jobs(request: Request) -> Response:
# Collate all tasks assigned by user that are still active
tasks_info = [
- {"id": task.id, "name": task.name, "next": task.next_run_time.strftime("%Y-%m-%d %H:%M")}
+ {
+ "id": task.id,
+ "name": re.sub(r"^/task\s*", "", task.name),
+ "next": task.next_run_time.strftime("%Y-%m-%d %H:%M"),
+ }
for task in tasks
if task.id.startswith(f"job_{user.uuid}_")
]
diff --git a/src/khoj/routers/api_chat.py b/src/khoj/routers/api_chat.py
index 47bc7c70..1f24b3a2 100644
--- a/src/khoj/routers/api_chat.py
+++ b/src/khoj/routers/api_chat.py
@@ -3,6 +3,7 @@ import hashlib
import json
import logging
import math
+import re
from datetime import datetime
from typing import Dict, Optional
from urllib.parse import unquote
@@ -425,10 +426,11 @@ async def websocket_endpoint(
f"Unable to schedule reminder. Ensure the reminder doesn't already exist."
)
continue
+ unprefixed_inferred_query = re.sub(r"^\/task\s*", "", inferred_query)
next_run_time = job.next_run_time.strftime("%Y-%m-%d %H:%M:%S")
llm_response = f"""
- ### 🕒 Scheduled Job
-- Query: **"{inferred_query}"**
+ ### 🕒 Scheduled Task
+- Query: **"{unprefixed_inferred_query}"**
- Schedule: `{crontime}`
- Next Run At: **{next_run_time}** UTC.
""".strip()
@@ -689,10 +691,11 @@ async def chat(
status_code=500,
)
+ unprefixed_inferred_query = re.sub(r"^\/task\s*", "", inferred_query)
next_run_time = job.next_run_time.strftime("%Y-%m-%d %H:%M:%S")
llm_response = f"""
- ### 🕒 Scheduled Job
-- Query: **"{inferred_query}"**
+ ### 🕒 Scheduled Task
+- Query: **"{unprefixed_inferred_query}"**
- Schedule: `{crontime}`
- Next Run At: **{next_run_time}** UTC.'
""".strip()
diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py
index 8059733d..e11c1cff 100644
--- a/src/khoj/routers/helpers.py
+++ b/src/khoj/routers/helpers.py
@@ -3,6 +3,7 @@ import base64
import io
import json
import logging
+import re
from concurrent.futures import ThreadPoolExecutor
from datetime import datetime, timedelta, timezone
from functools import partial
@@ -858,8 +859,15 @@ def should_notify(original_query: str, executed_query: str, ai_response: str) ->
with timer("Chat actor: Decide to notify user of AI response", logger):
try:
response = send_message_to_model_wrapper_sync(to_notify_or_not)
- return "no" not in response.lower()
+ should_notify_result = "no" not in response.lower()
+ logger.info(
+ f'Decided to {"not " if not should_notify_result else ""}notify user of scheduled task response.'
+ )
+ return should_notify_result
except:
+ logger.warning(
+ f"Fallback to notify user of scheduled task response as failed to infer should notify or not."
+ )
return True
@@ -895,7 +903,7 @@ def scheduled_chat(executing_query: str, scheduling_query: str, user: KhojUser,
return None
# Extract the AI response from the chat API response
- cleaned_query = scheduling_query.replace("/task", "", 1).strip()
+ cleaned_query = re.sub(r"^/task\s*", "", scheduling_query).strip()
if raw_response.headers.get("Content-Type") == "application/json":
response_map = raw_response.json()
ai_response = response_map.get("response") or response_map.get("image")