mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Do not version API. Premature given current state of the codebase
- Reason - All clients that currently consume the API are part of Khoj - Any breaking API changes will be fixed in clients immediately - So decoupling client from API is not required - This removes the burden of maintaining muliple versions of the API
This commit is contained in:
@@ -43,8 +43,8 @@ just generating embeddings*
|
||||
|
||||
- **Khoj via API**
|
||||
- See [Khoj API Docs](http://localhost:8000/docs)
|
||||
- [Query](http://localhost:8000/api/v1.0/search?q=%22what%20is%20the%20meaning%20of%20life%22)
|
||||
- [Update Index](http://localhost:8000/api/v1.0/update?t=ledger)
|
||||
- [Query](http://localhost:8000/api/search?q=%22what%20is%20the%20meaning%20of%20life%22)
|
||||
- [Update Index](http://localhost:8000/api/update?t=ledger)
|
||||
- [Configure Application](https://localhost:8000/ui)
|
||||
- **Khoj via Emacs**
|
||||
- [Install](https://github.com/debanjum/khoj/tree/master/src/interface/emacs#installation)
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
- Run ~M-x khoj <user-query>~ or Call ~C-c C-s~
|
||||
|
||||
- *Khoj via API*
|
||||
- Query: ~GET~ [[http://localhost:8000/api/v1.0/search?q=%22what%20is%20the%20meaning%20of%20life%22][http://localhost:8000/api/v1.0/search?q="What is the meaning of life"]]
|
||||
- Update Index: ~GET~ [[http://localhost:8000/api/v1.0/update][http://localhost:8000/api/v1.0/update]]
|
||||
- Query: ~GET~ [[http://localhost:8000/api/search?q=%22what%20is%20the%20meaning%20of%20life%22][http://localhost:8000/api/search?q="What is the meaning of life"]]
|
||||
- Update Index: ~GET~ [[http://localhost:8000/api/update][http://localhost:8000/api/update]]
|
||||
- [[http://localhost:8000/docs][Khoj API Docs]]
|
||||
|
||||
- *Call Khoj via Python Script Directly*
|
||||
|
||||
@@ -28,7 +28,7 @@ def test_search_with_invalid_content_type():
|
||||
user_query = quote("How to call Khoj from Emacs?")
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={user_query}&t=invalid_content_type")
|
||||
response = client.get(f"/api/search?q={user_query}&t=invalid_content_type")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 422
|
||||
@@ -43,7 +43,7 @@ def test_search_with_valid_content_type(content_config: ContentConfig, search_co
|
||||
# config.content_type.image = search_config.image
|
||||
for content_type in ["org", "markdown", "ledger", "music"]:
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q=random&t={content_type}")
|
||||
response = client.get(f"/api/search?q=random&t={content_type}")
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -51,7 +51,7 @@ def test_search_with_valid_content_type(content_config: ContentConfig, search_co
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_update_with_invalid_content_type():
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/update?t=invalid_content_type")
|
||||
response = client.get(f"/api/update?t=invalid_content_type")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 422
|
||||
@@ -65,7 +65,7 @@ def test_update_with_valid_content_type(content_config: ContentConfig, search_co
|
||||
|
||||
for content_type in ["org", "markdown", "ledger", "music"]:
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/update?t={content_type}")
|
||||
response = client.get(f"/api/update?t={content_type}")
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -73,7 +73,7 @@ def test_update_with_valid_content_type(content_config: ContentConfig, search_co
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
def test_regenerate_with_invalid_content_type():
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/update?force=true&t=invalid_content_type")
|
||||
response = client.get(f"/api/update?force=true&t=invalid_content_type")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 422
|
||||
@@ -87,7 +87,7 @@ def test_regenerate_with_valid_content_type(content_config: ContentConfig, searc
|
||||
|
||||
for content_type in ["org", "markdown", "ledger", "music", "image"]:
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/update?force=true&t={content_type}")
|
||||
response = client.get(f"/api/update?force=true&t={content_type}")
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -104,7 +104,7 @@ def test_image_search(content_config: ContentConfig, search_config: SearchConfig
|
||||
|
||||
for query, expected_image_name in query_expected_image_pairs:
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={query}&n=1&t=image")
|
||||
response = client.get(f"/api/search?q={query}&n=1&t=image")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -122,7 +122,7 @@ def test_notes_search(content_config: ContentConfig, search_config: SearchConfig
|
||||
user_query = quote("How to git install application?")
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={user_query}&n=1&t=org&r=true")
|
||||
response = client.get(f"/api/search?q={user_query}&n=1&t=org&r=true")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -139,7 +139,7 @@ def test_notes_search_with_only_filters(content_config: ContentConfig, search_co
|
||||
user_query = quote('+"Emacs" file:"*.org"')
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={user_query}&n=1&t=org")
|
||||
response = client.get(f"/api/search?q={user_query}&n=1&t=org")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -156,7 +156,7 @@ def test_notes_search_with_include_filter(content_config: ContentConfig, search_
|
||||
user_query = quote('How to git install application? +"Emacs"')
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={user_query}&n=1&t=org")
|
||||
response = client.get(f"/api/search?q={user_query}&n=1&t=org")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
@@ -173,7 +173,7 @@ def test_notes_search_with_exclude_filter(content_config: ContentConfig, search_
|
||||
user_query = quote('How to git install application? -"clone"')
|
||||
|
||||
# Act
|
||||
response = client.get(f"/api/v1.0/search?q={user_query}&n=1&t=org")
|
||||
response = client.get(f"/api/search?q={user_query}&n=1&t=org")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user