mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
Fix query timing variables from being referenced before assignment
This commit is contained in:
@@ -69,10 +69,12 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
|
|||||||
print(f'No query param (q) passed in API call to initiate search')
|
print(f'No query param (q) passed in API call to initiate search')
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
# initialize variables
|
||||||
device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
|
device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
|
||||||
user_query = q
|
user_query = q
|
||||||
results_count = n
|
results_count = n
|
||||||
results = {}
|
results = {}
|
||||||
|
query_start, query_end, collate_start, collate_end = None, None, None, None
|
||||||
|
|
||||||
if (t == SearchType.Org or t == None) and model.orgmode_search:
|
if (t == SearchType.Org or t == None) and model.orgmode_search:
|
||||||
# query org-mode notes
|
# query org-mode notes
|
||||||
@@ -136,7 +138,9 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None, r: Opti
|
|||||||
collate_end = time.time()
|
collate_end = time.time()
|
||||||
|
|
||||||
if verbose > 1:
|
if verbose > 1:
|
||||||
|
if query_start and query_end:
|
||||||
print(f"Query took {query_end - query_start:.3f} seconds")
|
print(f"Query took {query_end - query_start:.3f} seconds")
|
||||||
|
if collate_start and collate_end:
|
||||||
print(f"Collating results took {collate_end - collate_start:.3f} seconds")
|
print(f"Collating results took {collate_end - collate_start:.3f} seconds")
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|||||||
Reference in New Issue
Block a user