mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-28 01:45: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
|
# Initialize the search type and model from Config
|
||||||
state.search_index_lock.acquire()
|
state.search_index_lock.acquire()
|
||||||
state.SearchType = configure_search_types(state.config)
|
state.SearchType = configure_search_types(state.config)
|
||||||
state.model = SearchModels()
|
|
||||||
state.model = configure_search(state.model, state.config, args.regenerate)
|
state.model = configure_search(state.model, state.config, args.regenerate)
|
||||||
state.search_index_lock.release()
|
state.search_index_lock.release()
|
||||||
|
|
||||||
|
@ -158,7 +157,6 @@ def configure_search(model: SearchModels, config: FullConfig, regenerate: bool,
|
||||||
if (t == state.SearchType.Github or t == None) and config.content_type.github:
|
if (t == state.SearchType.Github or t == None) and config.content_type.github:
|
||||||
logger.info("🐙 Setting up search for github")
|
logger.info("🐙 Setting up search for github")
|
||||||
# Extract Entries, Generate Github Embeddings
|
# Extract Entries, Generate Github Embeddings
|
||||||
try:
|
|
||||||
model.github_search = text_search.setup(
|
model.github_search = text_search.setup(
|
||||||
GithubToJsonl,
|
GithubToJsonl,
|
||||||
config.content_type.github,
|
config.content_type.github,
|
||||||
|
@ -166,8 +164,6 @@ def configure_search(model: SearchModels, config: FullConfig, regenerate: bool,
|
||||||
regenerate=regenerate,
|
regenerate=regenerate,
|
||||||
filters=[DateFilter(), WordFilter(), FileFilter()],
|
filters=[DateFilter(), WordFilter(), FileFilter()],
|
||||||
)
|
)
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"Failed to setup github search: {e}")
|
|
||||||
|
|
||||||
# Initialize External Plugin Search
|
# Initialize External Plugin Search
|
||||||
if (t == None or t in state.SearchType) and config.content_type.plugins:
|
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
|
# Add labelled text input field
|
||||||
input_fields = []
|
input_fields = []
|
||||||
|
|
||||||
pat_token = current_content_config.get("pat-token", None)
|
fields = ["pat-token", "repo-name", "repo-owner", "repo-branch"]
|
||||||
input_field = LabelledTextField("pat-token", search_type=search_type, default_value=pat_token)
|
active = False
|
||||||
search_type_layout.addWidget(input_field)
|
for field in fields:
|
||||||
input_fields += [input_field]
|
field_value = current_content_config.get(field, None)
|
||||||
|
input_field = LabelledTextField(field, search_type=search_type, default_value=field_value)
|
||||||
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)
|
search_type_layout.addWidget(input_field)
|
||||||
input_fields += [input_field]
|
input_fields += [input_field]
|
||||||
|
if field_value:
|
||||||
|
active = True
|
||||||
|
|
||||||
# Set enabled/disabled based on checkbox state
|
# 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:
|
for input_field in input_fields:
|
||||||
input_field.setEnabled(enable_search_type.isChecked())
|
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]
|
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