diff --git a/src/khoj/database/admin.py b/src/khoj/database/admin.py index 9b07efde..a1242f89 100644 --- a/src/khoj/database/admin.py +++ b/src/khoj/database/admin.py @@ -60,7 +60,7 @@ class ConversationAdmin(admin.ModelAdmin): "updated_at", "client", ) - search_fields = ("conversation_id",) + search_fields = ("id", "user__email", "user__username", "client__name") ordering = ("-created_at",) actions = ["export_selected_objects", "export_selected_minimal_objects"] diff --git a/src/khoj/processor/content/text_to_entries.py b/src/khoj/processor/content/text_to_entries.py index ea62cde3..b2493aa3 100644 --- a/src/khoj/processor/content/text_to_entries.py +++ b/src/khoj/processor/content/text_to_entries.py @@ -41,6 +41,9 @@ class TextToEntries(ABC): "Split entries if compiled entry length exceeds the max tokens supported by the ML model." chunked_entries: List[Entry] = [] for entry in entries: + if is_none_or_empty(entry.compiled): + continue + # Split entry into words compiled_entry_words = [word for word in entry.compiled.split(" ") if word != ""] diff --git a/src/khoj/processor/conversation/prompts.py b/src/khoj/processor/conversation/prompts.py index 5ef3ff03..9ad85afb 100644 --- a/src/khoj/processor/conversation/prompts.py +++ b/src/khoj/processor/conversation/prompts.py @@ -302,7 +302,7 @@ You are Khoj, a smart and helpful personal assistant. You have access to a varie Here are some example responses: -Example 1: +Example: Chat History: User: I'm thinking of moving to a new city. I'm trying to decide between New York and San Francisco. AI: Moving to a new city can be challenging. Both New York and San Francisco are great cities to live in. New York is known for its diverse culture and San Francisco is known for its tech scene. @@ -310,15 +310,7 @@ AI: Moving to a new city can be challenging. Both New York and San Francisco are Q: What is the population of each of those cities? Khoj: ["online"] -Example 2: -Chat History: -User: I've been having a hard time at work. I'm thinking of quitting. -AI: I'm sorry to hear that. It's important to take care of your mental health. Have you considered talking to your manager about your concerns? - -Q: What are the best ways to quit a job? -Khoj: ["default"] - -Example 3: +Example: Chat History: User: I'm thinking of my next vacation idea. Ideally, I want to see something new and exciting. AI: Excellent! Taking a vacation is a great way to relax and recharge. @@ -326,14 +318,16 @@ AI: Excellent! Taking a vacation is a great way to relax and recharge. Q: Where did Grandma grow up? Khoj: ["notes"] -Example 4: +Example: Chat History: Q: What's the latest news with the first company I worked for? Khoj: ["notes", "online"] -Example 5: +Example: Chat History: +User: I want to start a new hobby. I'm thinking of learning to play the guitar. +AI: Learning to play the guitar is a great hobby. It can be a lot of fun and a great way to express yourself. Q: Who is Sandra? Khoj: ["default"] @@ -344,7 +338,7 @@ Chat History: {chat_history} Q: {query} -A: +Khoj: """.strip() ) diff --git a/src/khoj/processor/tools/online_search.py b/src/khoj/processor/tools/online_search.py index 394bed12..f1ff8e5d 100644 --- a/src/khoj/processor/tools/online_search.py +++ b/src/khoj/processor/tools/online_search.py @@ -103,10 +103,14 @@ def search_with_olostep(web_url: str) -> str: web_scraping_params: Dict[str, Union[str, int, bool]] = OLOSTEP_QUERY_PARAMS.copy() # type: ignore web_scraping_params["url"] = web_url - response = requests.request("GET", OLOSTEP_API_URL, params=web_scraping_params, headers=headers) + try: + response = requests.request("GET", OLOSTEP_API_URL, params=web_scraping_params, headers=headers) - if response.status_code != 200: - logger.error(response, exc_info=True) + if response.status_code != 200: + logger.error(response, exc_info=True) + return None + except Exception as e: + logger.error(f"Error while searching with Olostep: {e}", exc_info=True) return None return response.json()["markdown_content"]