mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-27 17:35:07 +01:00
Remove try-catch specific to Github plugin; consolidate GUI logic
This commit is contained in:
parent
07ade2262a
commit
ac96f43b1b
2 changed files with 17 additions and 31 deletions
|
@ -49,7 +49,6 @@ def configure_server(args, required=False):
|
|||
# Initialize the search type and model from Config
|
||||
state.search_index_lock.acquire()
|
||||
state.SearchType = configure_search_types(state.config)
|
||||
state.model = SearchModels()
|
||||
state.model = configure_search(state.model, state.config, args.regenerate)
|
||||
state.search_index_lock.release()
|
||||
|
||||
|
@ -158,16 +157,13 @@ def configure_search(model: SearchModels, config: FullConfig, regenerate: bool,
|
|||
if (t == state.SearchType.Github or t == None) and config.content_type.github:
|
||||
logger.info("🐙 Setting up search for github")
|
||||
# Extract Entries, Generate Github Embeddings
|
||||
try:
|
||||
model.github_search = text_search.setup(
|
||||
GithubToJsonl,
|
||||
config.content_type.github,
|
||||
search_config=config.search_type.asymmetric,
|
||||
regenerate=regenerate,
|
||||
filters=[DateFilter(), WordFilter(), FileFilter()],
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to setup github search: {e}")
|
||||
model.github_search = text_search.setup(
|
||||
GithubToJsonl,
|
||||
config.content_type.github,
|
||||
search_config=config.search_type.asymmetric,
|
||||
regenerate=regenerate,
|
||||
filters=[DateFilter(), WordFilter(), FileFilter()],
|
||||
)
|
||||
|
||||
# Initialize External Plugin Search
|
||||
if (t == None or t in state.SearchType) and config.content_type.plugins:
|
||||
|
|
|
@ -119,28 +119,18 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
# Add labelled text input field
|
||||
input_fields = []
|
||||
|
||||
pat_token = current_content_config.get("pat-token", None)
|
||||
input_field = LabelledTextField("pat-token", search_type=search_type, default_value=pat_token)
|
||||
search_type_layout.addWidget(input_field)
|
||||
input_fields += [input_field]
|
||||
|
||||
repo_name = current_content_config.get("repo-name", None)
|
||||
input_field = LabelledTextField("repo-name", search_type=search_type, default_value=repo_name)
|
||||
search_type_layout.addWidget(input_field)
|
||||
input_fields += [input_field]
|
||||
|
||||
repo_owner = current_content_config.get("repo-owner", None)
|
||||
input_field = LabelledTextField("repo-owner", search_type=search_type, default_value=repo_owner)
|
||||
search_type_layout.addWidget(input_field)
|
||||
input_fields += [input_field]
|
||||
|
||||
repo_branch = current_content_config.get("repo-branch", None)
|
||||
input_field = LabelledTextField("repo-branch", search_type=search_type, default_value=repo_branch)
|
||||
search_type_layout.addWidget(input_field)
|
||||
input_fields += [input_field]
|
||||
fields = ["pat-token", "repo-name", "repo-owner", "repo-branch"]
|
||||
active = False
|
||||
for field in fields:
|
||||
field_value = current_content_config.get(field, None)
|
||||
input_field = LabelledTextField(field, search_type=search_type, default_value=field_value)
|
||||
search_type_layout.addWidget(input_field)
|
||||
input_fields += [input_field]
|
||||
if field_value:
|
||||
active = True
|
||||
|
||||
# Set enabled/disabled based on checkbox state
|
||||
enable_search_type.setChecked(bool(repo_name or repo_owner or repo_branch or pat_token))
|
||||
enable_search_type.setChecked(active)
|
||||
for input_field in input_fields:
|
||||
input_field.setEnabled(enable_search_type.isChecked())
|
||||
enable_search_type.stateChanged.connect(lambda _: [input_field.setEnabled(enable_search_type.isChecked()) for input_field in input_fields]) # type: ignore[attr-defined]
|
||||
|
|
Loading…
Reference in a new issue