mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Update indexer API endpoint URL to index/update from indexer/batch
New URL follows action oriented endpoint naming convention used for other Khoj API endpoints Update desktop, obsidian and emacs client to call this new API endpoint
This commit is contained in:
parent
e347823ff4
commit
84654ffc5d
6 changed files with 10 additions and 10 deletions
|
@ -163,7 +163,7 @@ function pushDataToKhoj (regenerate = false) {
|
|||
const headers = {
|
||||
'x-api-key': 'secret'
|
||||
};
|
||||
axios.post(`${hostURL}/api/v1/indexer/batch?regenerate=${regenerate}`, formData, { headers })
|
||||
axios.post(`${hostURL}/api/v1/index/update?regenerate=${regenerate}`, formData, { headers })
|
||||
.then(response => {
|
||||
console.log(response.data);
|
||||
const win = BrowserWindow.getAllWindows()[0];
|
||||
|
|
|
@ -550,7 +550,7 @@ CONFIG is json obtained from Khoj config API."
|
|||
(url-request-extra-headers `(("content-type" . ,(format "multipart/form-data; boundary=%s" boundary))
|
||||
("x-api-key" . ,khoj-server-api-key))))
|
||||
(with-current-buffer
|
||||
(url-retrieve (format "%s/api/v1/indexer/batch" khoj-server-url)
|
||||
(url-retrieve (format "%s/api/v1/index/update" khoj-server-url)
|
||||
;; render response from indexing API endpoint on server
|
||||
(lambda (status)
|
||||
(if (not status)
|
||||
|
|
|
@ -68,7 +68,7 @@ export async function updateContentIndex(vault: Vault, setting: KhojSetting, las
|
|||
}
|
||||
|
||||
// Call Khoj backend to update index with all markdown, pdf files
|
||||
const response = await fetch(`${setting.khojUrl}/api/v1/indexer/batch?regenerate=${regenerate}`, {
|
||||
const response = await fetch(`${setting.khojUrl}/api/v1/index/update?regenerate=${regenerate}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'x-api-key': 'secret',
|
||||
|
|
|
@ -103,7 +103,7 @@ def configure_routes(app):
|
|||
app.mount("/static", StaticFiles(directory=constants.web_directory), name="static")
|
||||
app.include_router(api, prefix="/api")
|
||||
app.include_router(api_beta, prefix="/api/beta")
|
||||
app.include_router(indexer, prefix="/api/v1/indexer")
|
||||
app.include_router(indexer, prefix="/api/v1/index")
|
||||
app.include_router(web_client)
|
||||
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ class IndexerInput(BaseModel):
|
|||
plaintext: Optional[dict[str, str]] = None
|
||||
|
||||
|
||||
@indexer.post("/batch")
|
||||
async def index_batch(
|
||||
@indexer.post("/update")
|
||||
async def update(
|
||||
request: Request,
|
||||
files: list[UploadFile],
|
||||
x_api_key: str = Header(None),
|
||||
|
|
|
@ -60,13 +60,13 @@ def test_regenerate_with_invalid_content_type(client):
|
|||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_index_batch(client):
|
||||
def test_index_update(client):
|
||||
# Arrange
|
||||
files = get_sample_files_data()
|
||||
headers = {"x-api-key": "secret"}
|
||||
|
||||
# Act
|
||||
response = client.post("/api/v1/indexer/batch", files=files, headers=headers)
|
||||
response = client.post("/api/v1/index/update", files=files, headers=headers)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
@ -80,7 +80,7 @@ def test_regenerate_with_valid_content_type(client):
|
|||
headers = {"x-api-key": "secret"}
|
||||
|
||||
# Act
|
||||
response = client.post(f"/api/v1/indexer/batch?search_type={content_type}", files=files, headers=headers)
|
||||
response = client.post(f"/api/v1/index/update?search_type={content_type}", files=files, headers=headers)
|
||||
# Assert
|
||||
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}"
|
||||
|
||||
|
@ -95,7 +95,7 @@ def test_regenerate_with_github_fails_without_pat(client):
|
|||
headers = {"x-api-key": "secret"}
|
||||
|
||||
# Act
|
||||
response = client.post(f"/api/v1/indexer/batch?search_type=github", files=files, headers=headers)
|
||||
response = client.post(f"/api/v1/index/update?search_type=github", files=files, headers=headers)
|
||||
# Assert
|
||||
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: github"
|
||||
|
||||
|
|
Loading…
Reference in a new issue