From de15a7a3fc3fce8bceef90725a736cd57764b80f Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Tue, 16 Jul 2024 15:15:40 +0530 Subject: [PATCH] Rename API path /api/config to /api/configure - Update clients calling /api/config to call /api/configure instead --- src/interface/desktop/search.html | 2 +- src/interface/emacs/khoj.el | 2 +- .../components/modelPicker/modelPicker.tsx | 6 ++--- .../sidePanel/chatHistorySidePanel.tsx | 2 +- src/khoj/configure.py | 4 ++-- src/khoj/interface/web/chat.html | 2 +- src/khoj/interface/web/config.html | 24 +++++++++---------- .../web/content_source_computer_input.html | 6 ++--- .../web/content_source_github_input.html | 2 +- .../web/content_source_notion_input.html | 2 +- src/khoj/interface/web/search.html | 2 +- tests/test_client.py | 4 ++-- 12 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/interface/desktop/search.html b/src/interface/desktop/search.html index 1f2133fe..d0c63c34 100644 --- a/src/interface/desktop/search.html +++ b/src/interface/desktop/search.html @@ -212,7 +212,7 @@ const headers = { 'Authorization': `Bearer ${khojToken}` }; // Populate type dropdown field with enabled content types only - fetch(`${hostURL}/api/config/types`, { headers }) + fetch(`${hostURL}/api/configure/types`, { headers }) .then(response => response.json()) .then(enabled_types => { // Show warning if no content types are enabled diff --git a/src/interface/emacs/khoj.el b/src/interface/emacs/khoj.el index ca805815..136534d5 100644 --- a/src/interface/emacs/khoj.el +++ b/src/interface/emacs/khoj.el @@ -697,7 +697,7 @@ Optionally apply CALLBACK with JSON parsed response and CBARGS." (defun khoj--get-enabled-content-types () "Get content types enabled for search from API." - (khoj--call-api "/api/config/types" "GET" nil `(lambda (item) (mapcar #'intern item)))) + (khoj--call-api "/api/configure/types" "GET" nil `(lambda (item) (mapcar #'intern item)))) (defun khoj--query-search-api-and-render-results (query content-type buffer-name &optional rerank is-find-similar) "Query Khoj Search API with QUERY, CONTENT-TYPE and RERANK as query params. diff --git a/src/interface/web/app/components/modelPicker/modelPicker.tsx b/src/interface/web/app/components/modelPicker/modelPicker.tsx index 40854d93..8e77db41 100644 --- a/src/interface/web/app/components/modelPicker/modelPicker.tsx +++ b/src/interface/web/app/components/modelPicker/modelPicker.tsx @@ -68,8 +68,8 @@ interface ModelPickerProps { } export const ModelPicker: React.FC = (props: ModelPickerProps) => { - const { data: models } = useOptionsRequest('/api/config/chat/model/options'); - const { data: selectedModel } = useSelectedModel('/api/config/chat/model'); + const { data: models } = useOptionsRequest('/api/configure/chat/model/options'); + const { data: selectedModel } = useSelectedModel('/api/configure/chat/model'); const [openLoginDialog, setOpenLoginDialog] = React.useState(false); let userData = useAuthenticatedData(); @@ -94,7 +94,7 @@ export const ModelPicker: React.FC = (props: ModelPickerProps) => { props.setModelUsed(model); } - fetch('/api/config/chat/model' + '?id=' + String(model.id), { method: 'POST', body: JSON.stringify(model) }) + fetch('/api/configure/chat/model' + '?id=' + String(model.id), { method: 'POST', body: JSON.stringify(model) }) .then((response) => { if (!response.ok) { throw new Error('Failed to select model'); diff --git a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx index 7232089f..4c3645e1 100644 --- a/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx +++ b/src/interface/web/app/components/sidePanel/chatHistorySidePanel.tsx @@ -148,7 +148,7 @@ interface FilesMenuProps { function FilesMenu(props: FilesMenuProps) { // Use SWR to fetch files - const { data: files, error } = useSWR(props.conversationId ? '/api/config/content/computer' : null, fetcher); + const { data: files, error } = useSWR(props.conversationId ? '/api/configure/content/computer' : null, fetcher); const { data: selectedFiles, error: selectedFilesError } = useSWR(props.conversationId ? `/api/chat/conversation/file-filters/${props.conversationId}` : null, fetcher); const [isOpen, setIsOpen] = useState(false); const [unfilteredFiles, setUnfilteredFiles] = useState([]); diff --git a/src/khoj/configure.py b/src/khoj/configure.py index 6c4d8484..819fc15d 100644 --- a/src/khoj/configure.py +++ b/src/khoj/configure.py @@ -316,7 +316,7 @@ def configure_routes(app): app.include_router(api, prefix="/api") app.include_router(api_chat, prefix="/api/chat") app.include_router(api_agents, prefix="/api/agents") - app.include_router(api_config, prefix="/api/config") + app.include_router(api_config, prefix="/api/configure") app.include_router(indexer, prefix="/api/v1/index") app.include_router(notion_router, prefix="/api/notion") app.include_router(web_client) @@ -336,7 +336,7 @@ def configure_routes(app): if is_twilio_enabled(): from khoj.routers.api_phone import api_phone - app.include_router(api_phone, prefix="/api/config/phone") + app.include_router(api_phone, prefix="/api/configure/phone") logger.info("📞 Enabled Twilio") diff --git a/src/khoj/interface/web/chat.html b/src/khoj/interface/web/chat.html index 7a819633..a24a4ed4 100644 --- a/src/khoj/interface/web/chat.html +++ b/src/khoj/interface/web/chat.html @@ -1954,7 +1954,7 @@ To get started, just start typing below. You can also type / to see a list of co } var allFiles; function renderAllFiles() { - fetch('/api/config/content/computer') + fetch('/api/configure/content/computer') .then(response => response.json()) .then(data => { var indexedFiles = document.getElementsByClassName("indexed-files")[0]; diff --git a/src/khoj/interface/web/config.html b/src/khoj/interface/web/config.html index b21fa3ac..eba13b42 100644 --- a/src/khoj/interface/web/config.html +++ b/src/khoj/interface/web/config.html @@ -394,7 +394,7 @@ function saveProfileGivenName() { const givenName = document.getElementById("profile_given_name").value; - fetch('/api/config/user/name?name=' + givenName, { + fetch('/api/configure/user/name?name=' + givenName, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -421,7 +421,7 @@ saveVoiceModelButton.disabled = true; saveVoiceModelButton.textContent = "Saving..."; - fetch('/api/config/voice/model?id=' + voiceModel, { + fetch('/api/configure/voice/model?id=' + voiceModel, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -455,7 +455,7 @@ saveModelButton.innerHTML = ""; saveModelButton.textContent = "Saving..."; - fetch('/api/config/chat/model?id=' + chatModel, { + fetch('/api/configure/chat/model?id=' + chatModel, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -494,7 +494,7 @@ saveSearchModelButton.disabled = true; saveSearchModelButton.textContent = "Saving..."; - fetch('/api/config/search/model?id=' + searchModel, { + fetch('/api/configure/search/model?id=' + searchModel, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -526,7 +526,7 @@ saveModelButton.disabled = true; saveModelButton.innerHTML = "Saving..."; - fetch('/api/config/paint/model?id=' + paintModel, { + fetch('/api/configure/paint/model?id=' + paintModel, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -553,7 +553,7 @@ }; function clearContentType(content_source) { - fetch('/api/config/content/' + content_source, { + fetch('/api/configure/content/' + content_source, { method: 'DELETE', headers: { 'Content-Type': 'application/json', @@ -676,7 +676,7 @@ content_sources = ["computer", "github", "notion"]; content_sources.forEach(content_source => { - fetch(`/api/config/content/${content_source}`, { + fetch(`/api/configure/content/${content_source}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -807,7 +807,7 @@ function getIndexedDataSize() { document.getElementById("indexed-data-size").textContent = "Calculating..."; - fetch('/api/config/content/size') + fetch('/api/configure/content/size') .then(response => response.json()) .then(data => { document.getElementById("indexed-data-size").textContent = data.indexed_data_size_in_mb + " MB used"; @@ -815,7 +815,7 @@ } function removeFile(path) { - fetch('/api/config/content/file?filename=' + path, { + fetch('/api/configure/content/file?filename=' + path, { method: 'DELETE', headers: { 'Content-Type': 'application/json', @@ -890,7 +890,7 @@ }) phonenumberRemoveButton.addEventListener("click", () => { - fetch('/api/config/phone', { + fetch('/api/configure/phone', { method: 'DELETE', headers: { 'Content-Type': 'application/json', @@ -917,7 +917,7 @@ }, 5000); } else { const mobileNumber = iti.getNumber(); - fetch('/api/config/phone?phone_number=' + mobileNumber, { + fetch('/api/configure/phone?phone_number=' + mobileNumber, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -970,7 +970,7 @@ return; } - fetch('/api/config/phone/verify?code=' + otp, { + fetch('/api/configure/phone/verify?code=' + otp, { method: 'POST', headers: { 'Content-Type': 'application/json', diff --git a/src/khoj/interface/web/content_source_computer_input.html b/src/khoj/interface/web/content_source_computer_input.html index f9b02d57..e0ffc4e9 100644 --- a/src/khoj/interface/web/content_source_computer_input.html +++ b/src/khoj/interface/web/content_source_computer_input.html @@ -32,7 +32,7 @@