mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 23:48:56 +01:00
Remove unused parameter from configure_search_type method
This commit is contained in:
parent
f8e5e118e1
commit
8f200cf53f
4 changed files with 7 additions and 13 deletions
|
@ -117,7 +117,7 @@ def configure_server(
|
||||||
state.cross_encoder_model = CrossEncoderModel(get_or_create_search_model().cross_encoder)
|
state.cross_encoder_model = CrossEncoderModel(get_or_create_search_model().cross_encoder)
|
||||||
|
|
||||||
state.config_lock.acquire()
|
state.config_lock.acquire()
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types()
|
||||||
state.search_models = configure_search(state.search_models, state.config.search_type)
|
state.search_models = configure_search(state.search_models, state.config.search_type)
|
||||||
initialize_content(regenerate, search_type, init, user)
|
initialize_content(regenerate, search_type, init, user)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -195,7 +195,7 @@ def update_search_index():
|
||||||
logger.error(f"🚨 Error updating content index via Scheduler: {e}", exc_info=True)
|
logger.error(f"🚨 Error updating content index via Scheduler: {e}", exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
def configure_search_types(config: FullConfig):
|
def configure_search_types():
|
||||||
# Extract core search types
|
# Extract core search types
|
||||||
core_search_types = {e.name: e.value for e in SearchType}
|
core_search_types = {e.name: e.value for e in SearchType}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Tuple, Type, Union, Dict
|
from typing import List, Tuple, Type, Union
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
import torch
|
import torch
|
||||||
|
|
|
@ -227,7 +227,7 @@ def md_content_config():
|
||||||
def chat_client(search_config: SearchConfig, default_user2: KhojUser):
|
def chat_client(search_config: SearchConfig, default_user2: KhojUser):
|
||||||
# Initialize app state
|
# Initialize app state
|
||||||
state.config.search_type = search_config
|
state.config.search_type = search_config
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types()
|
||||||
|
|
||||||
LocalMarkdownConfig.objects.create(
|
LocalMarkdownConfig.objects.create(
|
||||||
input_files=None,
|
input_files=None,
|
||||||
|
@ -261,7 +261,7 @@ def chat_client(search_config: SearchConfig, default_user2: KhojUser):
|
||||||
def chat_client_no_background(search_config: SearchConfig, default_user2: KhojUser):
|
def chat_client_no_background(search_config: SearchConfig, default_user2: KhojUser):
|
||||||
# Initialize app state
|
# Initialize app state
|
||||||
state.config.search_type = search_config
|
state.config.search_type = search_config
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types()
|
||||||
|
|
||||||
# Initialize Processor from Config
|
# Initialize Processor from Config
|
||||||
if os.getenv("OPENAI_API_KEY"):
|
if os.getenv("OPENAI_API_KEY"):
|
||||||
|
@ -296,7 +296,7 @@ def client(
|
||||||
):
|
):
|
||||||
state.config.content_type = content_config
|
state.config.content_type = content_config
|
||||||
state.config.search_type = search_config
|
state.config.search_type = search_config
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types()
|
||||||
state.embeddings_model = EmbeddingsModel()
|
state.embeddings_model = EmbeddingsModel()
|
||||||
state.cross_encoder_model = CrossEncoderModel()
|
state.cross_encoder_model = CrossEncoderModel()
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ def client(
|
||||||
def client_offline_chat(search_config: SearchConfig, default_user2: KhojUser):
|
def client_offline_chat(search_config: SearchConfig, default_user2: KhojUser):
|
||||||
# Initialize app state
|
# Initialize app state
|
||||||
state.config.search_type = search_config
|
state.config.search_type = search_config
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types()
|
||||||
|
|
||||||
LocalMarkdownConfig.objects.create(
|
LocalMarkdownConfig.objects.create(
|
||||||
input_files=None,
|
input_files=None,
|
||||||
|
|
|
@ -203,9 +203,6 @@ def test_get_api_config_types(client, sample_org_data, default_user: KhojUser):
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
def test_get_configured_types_with_no_content_config(fastapi_app: FastAPI):
|
def test_get_configured_types_with_no_content_config(fastapi_app: FastAPI):
|
||||||
# Arrange
|
# Arrange
|
||||||
state.SearchType = configure_search_types(config)
|
|
||||||
original_config = state.config.content_type
|
|
||||||
state.config.content_type = None
|
|
||||||
state.anonymous_mode = True
|
state.anonymous_mode = True
|
||||||
|
|
||||||
configure_routes(fastapi_app)
|
configure_routes(fastapi_app)
|
||||||
|
@ -218,9 +215,6 @@ def test_get_configured_types_with_no_content_config(fastapi_app: FastAPI):
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert response.json() == ["all"]
|
assert response.json() == ["all"]
|
||||||
|
|
||||||
# Restore
|
|
||||||
state.config.content_type = original_config
|
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------------------------------
|
||||||
@pytest.mark.django_db(transaction=True)
|
@pytest.mark.django_db(transaction=True)
|
||||||
|
|
Loading…
Reference in a new issue