mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Clean up search type usage in khoj server, tests and Readme
This commit is contained in:
parent
4d910936b7
commit
d078e7b1f6
3 changed files with 9 additions and 11 deletions
|
@ -311,7 +311,7 @@ pip install --upgrade --pre khoj-assistant
|
||||||
model_directory: "~/.khoj/search/asymmetric/"
|
model_directory: "~/.khoj/search/asymmetric/"
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Regenerate your content index. For example, by opening [\<khoj-url\>/api/update?t=force](http://localhost:42110/api/update?t=force)
|
2. Regenerate your content index. For example, by opening [\<khoj-url\>/api/update?force=true](http://localhost:42110/api/update?force=true)
|
||||||
|
|
||||||
### Bootstrap Khoj Search for Offline Usage later
|
### Bootstrap Khoj Search for Offline Usage later
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,7 @@ from khoj.search_filter.file_filter import FileFilter
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def initialize_server(
|
def initialize_server(config: Optional[FullConfig], regenerate: bool, required=False):
|
||||||
config: Optional[FullConfig], regenerate: bool, type: Optional[SearchType] = None, required=False
|
|
||||||
):
|
|
||||||
if config is None and required:
|
if config is None and required:
|
||||||
logger.error(
|
logger.error(
|
||||||
f"🚨 Exiting as Khoj is not configured.\nConfigure it via http://localhost:42110/config or by editing {state.config_file}."
|
f"🚨 Exiting as Khoj is not configured.\nConfigure it via http://localhost:42110/config or by editing {state.config_file}."
|
||||||
|
@ -52,7 +50,7 @@ def initialize_server(
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
configure_server(config, regenerate, type)
|
configure_server(config, regenerate)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"🚨 Failed to configure server on app load: {e}", exc_info=True)
|
logger.error(f"🚨 Failed to configure server on app load: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,11 @@ def test_search_with_invalid_content_type(client):
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
def test_search_with_valid_content_type(client):
|
def test_search_with_valid_content_type(client):
|
||||||
for content_type in ["all", "org", "markdown", "image", "pdf", "plugin1"]:
|
for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]:
|
||||||
# Act
|
# Act
|
||||||
response = client.get(f"/api/search?q=random&t={content_type}")
|
response = client.get(f"/api/search?q=random&t={content_type}")
|
||||||
# Assert
|
# Assert
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}"
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -53,11 +53,11 @@ def test_update_with_invalid_content_type(client):
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
def test_update_with_valid_content_type(client):
|
def test_update_with_valid_content_type(client):
|
||||||
for content_type in ["org", "markdown", "image", "pdf", "plugin1"]:
|
for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]:
|
||||||
# Act
|
# Act
|
||||||
response = client.get(f"/api/update?t={content_type}")
|
response = client.get(f"/api/update?t={content_type}")
|
||||||
# Assert
|
# Assert
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}"
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
@ -71,11 +71,11 @@ def test_regenerate_with_invalid_content_type(client):
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
def test_regenerate_with_valid_content_type(client):
|
def test_regenerate_with_valid_content_type(client):
|
||||||
for content_type in ["org", "markdown", "image", "pdf", "plugin1"]:
|
for content_type in ["all", "org", "markdown", "image", "pdf", "github", "notion", "plugin1"]:
|
||||||
# Act
|
# Act
|
||||||
response = client.get(f"/api/update?force=true&t={content_type}")
|
response = client.get(f"/api/update?force=true&t={content_type}")
|
||||||
# Assert
|
# Assert
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200, f"Returned status: {response.status_code} for content type: {content_type}"
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue