mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
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
This commit is contained in:
parent
9536358d34
commit
97a6dfaa1e
3 changed files with 6 additions and 6 deletions
|
@ -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'}
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in a new issue