Set client request param when calling khoj server APIs from Web

This commit is contained in:
Debanjum Singh Solanky 2023-06-06 00:05:00 +05:30
parent caab55fbdd
commit bb2363f324
3 changed files with 6 additions and 6 deletions

View file

@ -46,7 +46,7 @@ regenerateButton.addEventListener("click", (event) => {
event.preventDefault();
regenerateButton.style.cursor = "progress";
regenerateButton.disabled = true;
fetch("/api/update?force=true")
fetch("/api/update?force=true&client=web")
.then(response => response.json())
.then(data => {
regenerateButton.style.cursor = "pointer";

View file

@ -62,7 +62,7 @@
document.getElementById("chat-input").value = "";
// Generate backend API URL to execute query
let url = `/api/chat?q=${encodeURIComponent(query)}`;
let url = `/api/chat?q=${encodeURIComponent(query)}&client=web`;
// Call specified Khoj API
fetch(url)
@ -82,7 +82,7 @@
}
window.onload = function () {
fetch('/api/chat')
fetch('/api/chat?client=web')
.then(response => response.json())
.then(data => data.response)
.then(chat_logs => {

View file

@ -90,8 +90,8 @@
// Generate Backend API URL to execute Search
url = type === "image"
? `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}`
: `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}`;
? `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&client=web`
: `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}&client=web`;
// Execute Search and Render Results
fetch(url)
@ -107,7 +107,7 @@
function updateIndex() {
type = document.getElementById("type").value;
fetch(`/api/update?t=${type}`)
fetch(`/api/update?t=${type}&client=web`)
.then(response => response.json())
.then(data => {
console.log(data);