mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-24 07:55:07 +01:00
Remove unused, deprecated /api/config/data API endpoints
- Use /api/health for server up check instead of api/config/default - Remove unused `khoj--post-new-config' method - Remove the now unused /config/data GET, POST API endpoints
This commit is contained in:
parent
7dfbcd2e5a
commit
8917228dbb
2 changed files with 1 additions and 65 deletions
|
@ -348,7 +348,7 @@ Auto invokes setup steps on calling main entrypoint."
|
||||||
t
|
t
|
||||||
;; else general check via ping to khoj-server-url
|
;; else general check via ping to khoj-server-url
|
||||||
(if (ignore-errors
|
(if (ignore-errors
|
||||||
(url-retrieve-synchronously (format "%s/api/config/data/default" khoj-server-url)))
|
(url-retrieve-synchronously (format "%s/api/health" khoj-server-url)))
|
||||||
;; Successful ping to non-emacs khoj server indicates it is started and ready.
|
;; Successful ping to non-emacs khoj server indicates it is started and ready.
|
||||||
;; So update ready state tracker variable (and implicitly return true for started)
|
;; So update ready state tracker variable (and implicitly return true for started)
|
||||||
(setq khoj--server-ready? t)
|
(setq khoj--server-ready? t)
|
||||||
|
@ -603,22 +603,6 @@ Use `BOUNDARY' to separate files. This is sent to Khoj server as a POST request.
|
||||||
;; --------------
|
;; --------------
|
||||||
;; Query Khoj API
|
;; Query Khoj API
|
||||||
;; --------------
|
;; --------------
|
||||||
|
|
||||||
(defun khoj--post-new-config (config)
|
|
||||||
"Configure khoj server with provided CONFIG."
|
|
||||||
;; POST provided config to khoj server
|
|
||||||
(let ((url-request-method "POST")
|
|
||||||
(url-request-extra-headers `(("Content-Type" . "application/json")
|
|
||||||
("Authorization" . ,(format "Bearer %s" khoj-api-key))))
|
|
||||||
(url-request-data (encode-coding-string (json-encode-alist config) 'utf-8))
|
|
||||||
(config-url (format "%s/api/config/data" khoj-server-url)))
|
|
||||||
(with-current-buffer (url-retrieve-synchronously config-url)
|
|
||||||
(buffer-string)))
|
|
||||||
;; Update index on khoj server after configuration update
|
|
||||||
(let ((khoj--server-ready? nil)
|
|
||||||
(url-request-extra-headers `(("Authorization" . ,(format "\"Bearer %s\"" khoj-api-key)))))
|
|
||||||
(url-retrieve (format "%s/api/update?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."
|
||||||
(let ((config-url (format "%s/api/config/types" khoj-server-url))
|
(let ((config-url (format "%s/api/config/types" khoj-server-url))
|
||||||
|
|
|
@ -97,49 +97,6 @@ def _initialize_config():
|
||||||
state.config.search_type = SearchConfig.model_validate(constants.default_config["search-type"])
|
state.config.search_type = SearchConfig.model_validate(constants.default_config["search-type"])
|
||||||
|
|
||||||
|
|
||||||
@api_config.get("/data", response_model=FullConfig)
|
|
||||||
@requires(["authenticated"])
|
|
||||||
def get_config_data(request: Request):
|
|
||||||
user = request.user.object
|
|
||||||
EntryAdapters.get_unique_file_types(user)
|
|
||||||
|
|
||||||
return state.config
|
|
||||||
|
|
||||||
|
|
||||||
@api_config.post("/data")
|
|
||||||
@requires(["authenticated"])
|
|
||||||
async def set_config_data(
|
|
||||||
request: Request,
|
|
||||||
updated_config: FullConfig,
|
|
||||||
client: Optional[str] = None,
|
|
||||||
):
|
|
||||||
user = request.user.object
|
|
||||||
await map_config_to_db(updated_config, user)
|
|
||||||
|
|
||||||
configuration_update_metadata = {}
|
|
||||||
|
|
||||||
enabled_content = await sync_to_async(EntryAdapters.get_unique_file_types)(user)
|
|
||||||
|
|
||||||
if state.config.content_type is not None:
|
|
||||||
configuration_update_metadata["github"] = "github" in enabled_content
|
|
||||||
configuration_update_metadata["notion"] = "notion" in enabled_content
|
|
||||||
configuration_update_metadata["org"] = "org" in enabled_content
|
|
||||||
configuration_update_metadata["pdf"] = "pdf" in enabled_content
|
|
||||||
configuration_update_metadata["markdown"] = "markdown" in enabled_content
|
|
||||||
|
|
||||||
if state.config.processor is not None:
|
|
||||||
configuration_update_metadata["conversation_processor"] = state.config.processor.conversation is not None
|
|
||||||
|
|
||||||
update_telemetry_state(
|
|
||||||
request=request,
|
|
||||||
telemetry_type="api",
|
|
||||||
api="set_config",
|
|
||||||
client=client,
|
|
||||||
metadata=configuration_update_metadata,
|
|
||||||
)
|
|
||||||
return state.config
|
|
||||||
|
|
||||||
|
|
||||||
@api_config.post("/data/content-source/github", status_code=200)
|
@api_config.post("/data/content-source/github", status_code=200)
|
||||||
@requires(["authenticated"])
|
@requires(["authenticated"])
|
||||||
async def set_content_config_github_data(
|
async def set_content_config_github_data(
|
||||||
|
@ -322,11 +279,6 @@ async def update_search_model(
|
||||||
|
|
||||||
|
|
||||||
# Create Routes
|
# Create Routes
|
||||||
@api_config.get("/data/default")
|
|
||||||
def get_default_config_data():
|
|
||||||
return constants.empty_config
|
|
||||||
|
|
||||||
|
|
||||||
@api_config.get("/index/size", response_model=Dict[str, int])
|
@api_config.get("/index/size", response_model=Dict[str, int])
|
||||||
@requires(["authenticated"])
|
@requires(["authenticated"])
|
||||||
async def get_indexed_data_size(request: Request, common: CommonQueryParams):
|
async def get_indexed_data_size(request: Request, common: CommonQueryParams):
|
||||||
|
|
Loading…
Reference in a new issue