From 97a6dfaa1efdcf2a4d98656468c2bf77847d7999 Mon Sep 17 00:00:00 2001 From: Saba Date: Sat, 11 Dec 2021 14:13:14 -0500 Subject: [PATCH] Use default value False for verbose parameter, and small changes Pass config as parameter to initialize_search, change name of API methods to handle config CRUD operations, and initalize config to FullConfig --- src/main.py | 8 ++++---- src/search_type/asymmetric.py | 2 +- src/search_type/image_search.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.py b/src/main.py index bfd6fafb..4c6783f6 100644 --- a/src/main.py +++ b/src/main.py @@ -18,9 +18,9 @@ from src.utils.rawconfig import FullConfig from src.processor.conversation.gpt import converse, message_to_log, message_to_prompt, understand # Application Global State +config = FullConfig() model = SearchModels() processor_config = ProcessorConfigModel() -config = {} config_file = "" verbose = 0 app = FastAPI() @@ -33,11 +33,11 @@ def ui(request: Request): return templates.TemplateResponse("config.html", context={'request': request}) @app.get('/config', response_model=FullConfig) -def config(): +def config_data(): return config @app.post('/config') -async def config(updated_config: FullConfig): +async def config_data(updated_config: FullConfig): global config config = updated_config with open(config_file, 'w') as outfile: @@ -92,7 +92,7 @@ def search(q: str, n: Optional[int] = 5, t: Optional[SearchType] = None): @app.get('/regenerate') def regenerate(t: Optional[SearchType] = None): - initialize_search(regenerate=True, t=t) + initialize_search(config, regenerate=True, t=t) return {'status': 'ok', 'message': 'regeneration completed'} diff --git a/src/search_type/asymmetric.py b/src/search_type/asymmetric.py index bdf7ddff..416cf7e2 100644 --- a/src/search_type/asymmetric.py +++ b/src/search_type/asymmetric.py @@ -149,7 +149,7 @@ def collate_results(hits, entries, count=5): in hits[0:count]] -def setup(config: TextSearchConfig, regenerate: bool, verbose: bool) -> TextSearchModel: +def setup(config: TextSearchConfig, regenerate: bool, verbose: bool=False) -> TextSearchModel: # Initialize Model bi_encoder, cross_encoder, top_k = initialize_model() diff --git a/src/search_type/image_search.py b/src/search_type/image_search.py index f0025328..f8af7d8e 100644 --- a/src/search_type/image_search.py +++ b/src/search_type/image_search.py @@ -154,7 +154,7 @@ def collate_results(hits, image_names, image_directory, count=5): in hits[0:count]] -def setup(config: ImageSearchConfig, regenerate: bool, verbose: bool) -> ImageSearchModel: +def setup(config: ImageSearchConfig, regenerate: bool, verbose: bool=False) -> ImageSearchModel: # Initialize Model encoder = initialize_model()