From 1fed842fcca221e02c03f411821d3d7f89491213 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Mon, 30 Sep 2024 01:19:56 -0700 Subject: [PATCH] Localize online search results to user country when location available Get country code to server chat api from i.p location check on clients. Use country code to get country specific online search results via Serper.dev API --- src/interface/desktop/chat.html | 3 +++ src/interface/desktop/shortcut.html | 6 ++++-- src/interface/obsidian/src/chat_view.ts | 3 +++ src/interface/web/app/chat/page.tsx | 3 ++- src/interface/web/app/common/utils.ts | 1 + src/interface/web/app/share/chat/page.tsx | 1 + src/khoj/processor/tools/online_search.py | 10 +++++----- src/khoj/routers/api_chat.py | 6 ++++-- src/khoj/utils/rawconfig.py | 1 + 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/interface/desktop/chat.html b/src/interface/desktop/chat.html index 3df00efc..cd47dae5 100644 --- a/src/interface/desktop/chat.html +++ b/src/interface/desktop/chat.html @@ -60,6 +60,7 @@ let region = null; let city = null; let countryName = null; + let countryCode = null; let timezone = null; let chatMessageState = { newResponseTextEl: null, @@ -76,6 +77,7 @@ region = data.region; city = data.city; countryName = data.country_name; + countryCode = data.country_code; timezone = data.timezone; }) .catch(err => { @@ -157,6 +159,7 @@ ...(!!city && { city: city }), ...(!!region && { region: region }), ...(!!countryName && { country: countryName }), + ...(!!countryCode && { country_code: countryCode }), ...(!!timezone && { timezone: timezone }), }; diff --git a/src/interface/desktop/shortcut.html b/src/interface/desktop/shortcut.html index 86e5d906..4b07b8ea 100644 --- a/src/interface/desktop/shortcut.html +++ b/src/interface/desktop/shortcut.html @@ -308,18 +308,19 @@