Pass type of item via regenerate API. Default type query param to None

This commit is contained in:
Debanjum Singh Solanky 2021-08-17 04:36:48 -07:00
parent ff7207a6bd
commit 252266b62a

View file

@ -18,7 +18,7 @@ app = FastAPI()
@app.get('/search') @app.get('/search')
def search(q: str, n: Optional[int] = 5, t: Optional[str] = 'notes'): def search(q: str, n: Optional[int] = 5, t: Optional[str] = None):
if q is None or q == '': if q is None or q == '':
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 {}
@ -26,7 +26,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[str] = 'notes'):
user_query = q user_query = q
results_count = n results_count = n
if t == 'notes': if t == 'notes' or t == None:
# query notes # query notes
hits = asymmetric.query_notes( hits = asymmetric.query_notes(
user_query, user_query,
@ -44,17 +44,12 @@ def search(q: str, n: Optional[int] = 5, t: Optional[str] = 'notes'):
@app.get('/regenerate') @app.get('/regenerate')
def regenerate(): def regenerate(t: Optional[str] = None):
# Extract Entries, Generate Embeddings if t == 'notes' or t == None:
extracted_entries, computed_embeddings, _, _, _ = asymmetric.setup(args.input_files, args.input_filter, args.compressed_jsonl, args.embeddings, regenerate=True, verbose=args.verbose) # Extract Entries, Generate Embeddings
global corpus_embeddings
# Now Update State global entries
# update state variables after regeneration complete entries, corpus_embeddings, _, _, _ = asymmetric.setup(args.input_files, args.input_filter, args.compressed_jsonl, args.embeddings, regenerate=True, verbose=args.verbose)
# minimize time the application is in inconsistent, partially updated state
global corpus_embeddings
global entries
entries = extracted_entries
corpus_embeddings = computed_embeddings
return {'status': 'ok', 'message': 'regeneration completed'} return {'status': 'ok', 'message': 'regeneration completed'}