mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-24 07:55:07 +01:00
Set client request param when calling khoj server APIs from Web
This commit is contained in:
parent
caab55fbdd
commit
bb2363f324
3 changed files with 6 additions and 6 deletions
|
@ -46,7 +46,7 @@ regenerateButton.addEventListener("click", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
regenerateButton.style.cursor = "progress";
|
regenerateButton.style.cursor = "progress";
|
||||||
regenerateButton.disabled = true;
|
regenerateButton.disabled = true;
|
||||||
fetch("/api/update?force=true")
|
fetch("/api/update?force=true&client=web")
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
regenerateButton.style.cursor = "pointer";
|
regenerateButton.style.cursor = "pointer";
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
document.getElementById("chat-input").value = "";
|
document.getElementById("chat-input").value = "";
|
||||||
|
|
||||||
// Generate backend API URL to execute query
|
// 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
|
// Call specified Khoj API
|
||||||
fetch(url)
|
fetch(url)
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
fetch('/api/chat')
|
fetch('/api/chat?client=web')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => data.response)
|
.then(data => data.response)
|
||||||
.then(chat_logs => {
|
.then(chat_logs => {
|
||||||
|
|
|
@ -90,8 +90,8 @@
|
||||||
|
|
||||||
// Generate Backend API URL to execute Search
|
// Generate Backend API URL to execute Search
|
||||||
url = type === "image"
|
url = type === "image"
|
||||||
? `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}`
|
? `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&client=web`
|
||||||
: `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}`;
|
: `/api/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}&client=web`;
|
||||||
|
|
||||||
// Execute Search and Render Results
|
// Execute Search and Render Results
|
||||||
fetch(url)
|
fetch(url)
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
|
|
||||||
function updateIndex() {
|
function updateIndex() {
|
||||||
type = document.getElementById("type").value;
|
type = document.getElementById("type").value;
|
||||||
fetch(`/api/update?t=${type}`)
|
fetch(`/api/update?t=${type}&client=web`)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
|
Loading…
Reference in a new issue