From b73f44671380d8740377ff186e78727a11ad5d54 Mon Sep 17 00:00:00 2001 From: sabaimran Date: Wed, 29 Jan 2025 21:50:28 -0800 Subject: [PATCH 1/5] Fallback to show raw outputted diagram if fails rendering --- .../web/app/components/mermaid/mermaid.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/interface/web/app/components/mermaid/mermaid.tsx b/src/interface/web/app/components/mermaid/mermaid.tsx index d73a4447..bdbbe6a3 100644 --- a/src/interface/web/app/components/mermaid/mermaid.tsx +++ b/src/interface/web/app/components/mermaid/mermaid.tsx @@ -141,10 +141,17 @@ const Mermaid: React.FC = ({ chart }) => { return (
{mermaidError ? ( -
- - Error rendering diagram: {mermaidError} -
+ <> +
+ + {mermaidError} +
+ + { + chart + } + + ) : (
Date: Thu, 30 Jan 2025 20:40:37 +0900 Subject: [PATCH 2/5] Fix typo in docs for Chat Model Type for Google Gemini setup (#1098) --- documentation/docs/get-started/setup.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/get-started/setup.mdx b/documentation/docs/get-started/setup.mdx index 7a2cbb16..cf71b441 100644 --- a/documentation/docs/get-started/setup.mdx +++ b/documentation/docs/get-started/setup.mdx @@ -329,7 +329,7 @@ Using Ollama? See the [Ollama Integration](/advanced/ollama) section for more cu - Give the configuration a friendly name like `Gemini`. Do not configure the API base url. 2. Create a new [chat model](http://localhost:42110/server/admin/database/chatmodel/add) - Set the `chat-model` field to a [Google Gemini chat model](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/models#gemini-models). Example: `gemini-1.5-flash`. - - Set the `model-type` field to `Gemini`. + - Set the `model-type` field to `Google`. - Set the `ai model api` field to the Gemini AI Model API you created in step 1. From b111a9d6c6e1c2bf3564fe13747999ff88725b3e Mon Sep 17 00:00:00 2001 From: sabaimran Date: Thu, 30 Jan 2025 11:48:33 -0800 Subject: [PATCH 3/5] Release Khoj version 1.35.3 --- manifest.json | 2 +- src/interface/desktop/package.json | 2 +- src/interface/emacs/khoj.el | 2 +- src/interface/obsidian/manifest.json | 2 +- src/interface/obsidian/package.json | 2 +- src/interface/obsidian/versions.json | 3 ++- src/interface/web/package.json | 2 +- versions.json | 3 ++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest.json b/manifest.json index 8cdf3f2f..3a3a8ff8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "khoj", "name": "Khoj", - "version": "1.35.2", + "version": "1.35.3", "minAppVersion": "0.15.0", "description": "Your Second Brain", "author": "Khoj Inc.", diff --git a/src/interface/desktop/package.json b/src/interface/desktop/package.json index d43bd1a6..f270ec90 100644 --- a/src/interface/desktop/package.json +++ b/src/interface/desktop/package.json @@ -1,6 +1,6 @@ { "name": "Khoj", - "version": "1.35.2", + "version": "1.35.3", "description": "Your Second Brain", "author": "Khoj Inc. ", "license": "GPL-3.0-or-later", diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index b77c70e9..e8102a39 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -6,7 +6,7 @@ ;; Saba Imran ;; Description: Your Second Brain ;; Keywords: search, chat, ai, org-mode, outlines, markdown, pdf, image -;; Version: 1.35.2 +;; Version: 1.35.3 ;; Package-Requires: ((emacs "27.1") (transient "0.3.0") (dash "2.19.1")) ;; URL: https://github.com/khoj-ai/khoj/tree/master/src/interface/emacs diff --git a/src/interface/obsidian/manifest.json b/src/interface/obsidian/manifest.json index 8cdf3f2f..3a3a8ff8 100644 --- a/src/interface/obsidian/manifest.json +++ b/src/interface/obsidian/manifest.json @@ -1,7 +1,7 @@ { "id": "khoj", "name": "Khoj", - "version": "1.35.2", + "version": "1.35.3", "minAppVersion": "0.15.0", "description": "Your Second Brain", "author": "Khoj Inc.", diff --git a/src/interface/obsidian/package.json b/src/interface/obsidian/package.json index 8861f177..543edbf0 100644 --- a/src/interface/obsidian/package.json +++ b/src/interface/obsidian/package.json @@ -1,6 +1,6 @@ { "name": "Khoj", - "version": "1.35.2", + "version": "1.35.3", "description": "Your Second Brain", "author": "Debanjum Singh Solanky, Saba Imran ", "license": "GPL-3.0-or-later", diff --git a/src/interface/obsidian/versions.json b/src/interface/obsidian/versions.json index 21346aa4..e9325f95 100644 --- a/src/interface/obsidian/versions.json +++ b/src/interface/obsidian/versions.json @@ -112,5 +112,6 @@ "1.34.0": "0.15.0", "1.35.0": "0.15.0", "1.35.1": "0.15.0", - "1.35.2": "0.15.0" + "1.35.2": "0.15.0", + "1.35.3": "0.15.0" } diff --git a/src/interface/web/package.json b/src/interface/web/package.json index 05270d36..4148d401 100644 --- a/src/interface/web/package.json +++ b/src/interface/web/package.json @@ -1,6 +1,6 @@ { "name": "khoj-ai", - "version": "1.35.2", + "version": "1.35.3", "private": true, "scripts": { "dev": "next dev", diff --git a/versions.json b/versions.json index 21346aa4..e9325f95 100644 --- a/versions.json +++ b/versions.json @@ -112,5 +112,6 @@ "1.34.0": "0.15.0", "1.35.0": "0.15.0", "1.35.1": "0.15.0", - "1.35.2": "0.15.0" + "1.35.2": "0.15.0", + "1.35.3": "0.15.0" } From 0bfa7c1c458625b3d503a94a2ac09fa645491a03 Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 1 Feb 2025 02:29:44 +0530 Subject: [PATCH 4/5] Add support for o3 mini model by openai --- src/khoj/processor/conversation/openai/utils.py | 4 ++++ src/khoj/processor/conversation/utils.py | 1 + src/khoj/utils/constants.py | 1 + 3 files changed, 6 insertions(+) diff --git a/src/khoj/processor/conversation/openai/utils.py b/src/khoj/processor/conversation/openai/utils.py index 76b175b5..7d21662f 100644 --- a/src/khoj/processor/conversation/openai/utils.py +++ b/src/khoj/processor/conversation/openai/utils.py @@ -71,6 +71,8 @@ def completion_with_backoff( elif model_name.startswith("o1"): temperature = 1 model_kwargs.pop("response_format", None) + elif model_name.startswith("o3-"): + temperature = 1 if os.getenv("KHOJ_LLM_SEED"): model_kwargs["seed"] = int(os.getenv("KHOJ_LLM_SEED")) @@ -181,6 +183,8 @@ def llm_thread( elif model_name.startswith("o1-"): temperature = 1 model_kwargs.pop("response_format", None) + elif model_name.startswith("o3-"): + temperature = 1 elif model_name.startswith("deepseek-reasoner"): # Two successive messages cannot be from the same role. Should merge any back-to-back messages from the same role. # The first message should always be a user message (except system message). diff --git a/src/khoj/processor/conversation/utils.py b/src/khoj/processor/conversation/utils.py index 1ab06fae..695ad5e4 100644 --- a/src/khoj/processor/conversation/utils.py +++ b/src/khoj/processor/conversation/utils.py @@ -55,6 +55,7 @@ model_to_prompt_size = { "gpt-4o-mini": 60000, "o1": 20000, "o1-mini": 60000, + "o3-mini": 60000, # Google Models "gemini-1.5-flash": 60000, "gemini-1.5-pro": 60000, diff --git a/src/khoj/utils/constants.py b/src/khoj/utils/constants.py index 6e89594d..b3ff1f97 100644 --- a/src/khoj/utils/constants.py +++ b/src/khoj/utils/constants.py @@ -40,6 +40,7 @@ model_to_cost: Dict[str, Dict[str, float]] = { "gpt-4o-mini": {"input": 0.15, "output": 0.60}, "o1": {"input": 15.0, "output": 60.00}, "o1-mini": {"input": 3.0, "output": 12.0}, + "o3-mini": {"input": 1.10, "output": 4.40}, # Gemini Pricing: https://ai.google.dev/pricing "gemini-1.5-flash": {"input": 0.075, "output": 0.30}, "gemini-1.5-flash-002": {"input": 0.075, "output": 0.30}, From f2eba667fc2b24f0e18ff60928407bee6b7b1cbb Mon Sep 17 00:00:00 2001 From: Debanjum Date: Sat, 1 Feb 2025 19:12:51 +0530 Subject: [PATCH 5/5] Fallback to schedule automation in UTC timezone if unset - Handle null automation ids in calls to get_automation function --- src/khoj/database/adapters/__init__.py | 2 +- src/khoj/routers/helpers.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/khoj/database/adapters/__init__.py b/src/khoj/database/adapters/__init__.py index 2cd9daf7..65d2b70f 100644 --- a/src/khoj/database/adapters/__init__.py +++ b/src/khoj/database/adapters/__init__.py @@ -1794,7 +1794,7 @@ class AutomationAdapters: def get_automation(user: KhojUser, automation_id: str) -> Job: # Perform validation checks # Check if user is allowed to delete this automation id - if not automation_id.startswith(f"automation_{user.uuid}_"): + if not is_none_or_empty(automation_id) or automation_id.startswith(f"automation_{user.uuid}_"): raise ValueError("Invalid automation id") # Check if automation with this id exist automation: Job = state.scheduler.get_job(job_id=automation_id) diff --git a/src/khoj/routers/helpers.py b/src/khoj/routers/helpers.py index 67b367b0..58ab7385 100644 --- a/src/khoj/routers/helpers.py +++ b/src/khoj/routers/helpers.py @@ -1977,7 +1977,13 @@ def schedule_automation( # Run automation at some random minute (to distribute request load) instead of running every X minutes crontime = " ".join([str(math.floor(random() * 60))] + crontime.split(" ")[1:]) - user_timezone = pytz.timezone(timezone) + # Convert timezone string to timezone object + try: + user_timezone = pytz.timezone(timezone) + except pytz.UnknownTimeZoneError: + logger.error(f"Invalid timezone: {timezone}. Fallback to use UTC to schedule automation.") + user_timezone = pytz.utc + trigger = CronTrigger.from_crontab(crontime, user_timezone) trigger.jitter = 60 # Generate id and metadata used by task scheduler and process locks for the task runs