mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Set client request param when calling khoj server APIs from Emacs
This commit is contained in:
@@ -634,7 +634,7 @@ CONFIG is json obtained from Khoj config API."
|
|||||||
(buffer-string)))
|
(buffer-string)))
|
||||||
;; Update index on khoj server after configuration update
|
;; Update index on khoj server after configuration update
|
||||||
(let ((khoj--server-ready? nil))
|
(let ((khoj--server-ready? nil))
|
||||||
(url-retrieve (format "%s/api/update?t=org" khoj-server-url) #'identity)))
|
(url-retrieve (format "%s/api/update?t=org&client=emacs" khoj-server-url) #'identity)))
|
||||||
|
|
||||||
(defun khoj--get-enabled-content-types ()
|
(defun khoj--get-enabled-content-types ()
|
||||||
"Get content types enabled for search from API."
|
"Get content types enabled for search from API."
|
||||||
@@ -651,7 +651,7 @@ CONFIG is json obtained from Khoj config API."
|
|||||||
Use QUERY, CONTENT-TYPE and (optional) RERANK as query params"
|
Use QUERY, CONTENT-TYPE and (optional) RERANK as query params"
|
||||||
(let ((rerank (or rerank "false"))
|
(let ((rerank (or rerank "false"))
|
||||||
(encoded-query (url-hexify-string query)))
|
(encoded-query (url-hexify-string query)))
|
||||||
(format "%s/api/search?q=%s&t=%s&r=%s&n=%s" khoj-server-url encoded-query content-type rerank khoj-results-count)))
|
(format "%s/api/search?q=%s&t=%s&r=%s&n=%s&client=emacs" khoj-server-url encoded-query content-type rerank khoj-results-count)))
|
||||||
|
|
||||||
(defun khoj--query-search-api-and-render-results (query-url content-type query buffer-name)
|
(defun khoj--query-search-api-and-render-results (query-url content-type query buffer-name)
|
||||||
"Query Khoj Search with QUERY-URL.
|
"Query Khoj Search with QUERY-URL.
|
||||||
@@ -788,7 +788,7 @@ Render results in BUFFER-NAME using QUERY, CONTENT-TYPE."
|
|||||||
"Send QUERY to Khoj Chat API."
|
"Send QUERY to Khoj Chat API."
|
||||||
(let* ((url-request-method "GET")
|
(let* ((url-request-method "GET")
|
||||||
(encoded-query (url-hexify-string query))
|
(encoded-query (url-hexify-string query))
|
||||||
(query-url (format "%s/api/chat?q=%s" khoj-server-url encoded-query)))
|
(query-url (format "%s/api/chat?q=%s&client=emacs" khoj-server-url encoded-query)))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(condition-case ex
|
(condition-case ex
|
||||||
(progn
|
(progn
|
||||||
@@ -1031,7 +1031,7 @@ Paragraph only starts at first text after blank line."
|
|||||||
(let* ((force-update (if (member "--force-update" args) "true" "false"))
|
(let* ((force-update (if (member "--force-update" args) "true" "false"))
|
||||||
;; set content type to: specified > last used > based on current buffer > default type
|
;; set content type to: specified > last used > based on current buffer > default type
|
||||||
(content-type (or (transient-arg-value "--content-type=" args) (khoj--buffer-name-to-content-type (buffer-name))))
|
(content-type (or (transient-arg-value "--content-type=" args) (khoj--buffer-name-to-content-type (buffer-name))))
|
||||||
(update-url (format "%s/api/update?t=%s&force=%s" khoj-server-url content-type force-update))
|
(update-url (format "%s/api/update?t=%s&force=%s&client=emacs" khoj-server-url content-type force-update))
|
||||||
(url-request-method "GET"))
|
(url-request-method "GET"))
|
||||||
(progn
|
(progn
|
||||||
(setq khoj--content-type content-type)
|
(setq khoj--content-type content-type)
|
||||||
|
|||||||
Reference in New Issue
Block a user