diff --git a/nl_server/routes.py b/nl_server/routes.py index 599be6e0d8..89ac698d8d 100644 --- a/nl_server/routes.py +++ b/nl_server/routes.py @@ -61,13 +61,13 @@ def search_vars(): if request.args.get('skip_topics'): skip_topics = True - r: Registry = current_app.config[REGISTRY_KEY] + reg: Registry = current_app.config[REGISTRY_KEY] reranker_name = str(escape(request.args.get('reranker', ''))) - reranker_model = r.get_reranking_model( + reranker_model = reg.get_reranking_model( reranker_name) if reranker_name else None - default_indexes = r.server_config().default_indexes + default_indexes = reg.server_config().default_indexes idx_type_str = str(escape(request.args.get('idx', ''))) if not idx_type_str: idx_types = default_indexes @@ -77,7 +77,7 @@ def search_vars(): logging.error('No index type is found!') return 'No index type is found!', 500 - embeddings = _get_indexes(r, idx_types) + embeddings = _get_indexes(reg, idx_types) debug_logs = {'sv_detection_query_index_type': idx_types} results = search.search_vars(embeddings, queries, skip_topics, reranker_model, @@ -97,14 +97,14 @@ def detect_verbs(): List[str] """ query = str(escape(request.args.get('q'))) - r: Registry = current_app.config[REGISTRY_KEY] - return json.dumps(r.get_attribute_model().detect_verbs(query.strip())) + reg: Registry = current_app.config[REGISTRY_KEY] + return json.dumps(reg.get_attribute_model().detect_verbs(query.strip())) @bp.route('/api/server_config/', methods=['GET']) def embeddings_version_map(): - r: Registry = current_app.config[REGISTRY_KEY] - server_config = r.server_config() + reg: Registry = current_app.config[REGISTRY_KEY] + server_config = reg.server_config() return json.dumps(asdict(server_config)) @@ -114,20 +114,17 @@ def load(): current_app.config[REGISTRY_KEY] = registry.build() except Exception as e: logging.error(f'Server registry not built due to error: {str(e)}') - r: Registry = current_app.config[REGISTRY_KEY] - server_config = r.server_config() + reg: Registry = current_app.config[REGISTRY_KEY] + server_config = reg.server_config() return json.dumps(asdict(server_config)) -def _get_indexes(r: Registry, idx_types: List[str]) -> List[Embeddings]: +def _get_indexes(reg: Registry, idx_types: List[str]) -> List[Embeddings]: embeddings: List[Embeddings] = [] for idx in idx_types: - try: - emb = r.get_index(idx) - if emb: - embeddings.append(emb) - except Exception as e: - logging.warning(f'Failed to load index {idx}: {e}') + emb = reg.get_index(idx) + if emb: + embeddings.append(emb) return embeddings diff --git a/static/js/constants/app/explore_constants.ts b/static/js/constants/app/explore_constants.ts index e004c5d7f8..de7ef8c38c 100644 --- a/static/js/constants/app/explore_constants.ts +++ b/static/js/constants/app/explore_constants.ts @@ -24,7 +24,7 @@ export const URL_HASH_PARAMS = { TOPIC: "t", QUERY: "q", DC: "dc", - // Embeddings index name (listed in embeddings.yaml) + // Embeddings index name (listed in catalog.yaml) IDX: "idx", DISABLE_EXPLORE_MORE: "em", // old query param