From 6631fc38dbcb3ebbab1576bfff798b9a910b0ca2 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 18 Oct 2023 03:23:17 -0700 Subject: [PATCH] Delete plaintext config via API. Catch any offline model loading exception --- src/interface/obsidian/src/settings.ts | 2 +- src/khoj/routers/api.py | 4 ++++ src/khoj/utils/config.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/interface/obsidian/src/settings.ts b/src/interface/obsidian/src/settings.ts index 9b672659..c3f40905 100644 --- a/src/interface/obsidian/src/settings.ts +++ b/src/interface/obsidian/src/settings.ts @@ -1,4 +1,4 @@ -import { App, Notice, PluginSettingTab, request, Setting, TFile } from 'obsidian'; +import { App, Notice, PluginSettingTab, Setting, TFile } from 'obsidian'; import Khoj from 'src/main'; import { updateContentIndex } from './utils'; diff --git a/src/khoj/routers/api.py b/src/khoj/routers/api.py index 1512afd0..345429e8 100644 --- a/src/khoj/routers/api.py +++ b/src/khoj/routers/api.py @@ -186,6 +186,10 @@ if not state.demo: state.content_index.markdown = None elif content_type == "org": state.content_index.org = None + elif content_type == "plaintext": + state.content_index.plaintext = None + else: + logger.warning(f"Request to delete unknown content type: {content_type} via API") try: save_config_to_file_updated_state() diff --git a/src/khoj/utils/config.py b/src/khoj/utils/config.py index cdc0d260..5b3b9f6e 100644 --- a/src/khoj/utils/config.py +++ b/src/khoj/utils/config.py @@ -106,7 +106,7 @@ class ConversationProcessorConfigModel: if self.offline_chat.enable_offline_chat: try: self.gpt4all_model.loaded_model = download_model(self.offline_chat.chat_model) - except ValueError as e: + except Exception as e: self.offline_chat.enable_offline_chat = False self.gpt4all_model.loaded_model = None logger.error(f"Error while loading offline chat model: {e}", exc_info=True)