mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00: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:
@@ -18,9 +18,9 @@ from src.utils.rawconfig import FullConfig
|
|||||||
from src.processor.conversation.gpt import converse, message_to_log, message_to_prompt, understand
|
from src.processor.conversation.gpt import converse, message_to_log, message_to_prompt, understand
|
||||||
|
|
||||||
# Application Global State
|
# Application Global State
|
||||||
|
config = FullConfig()
|
||||||
model = SearchModels()
|
model = SearchModels()
|
||||||
processor_config = ProcessorConfigModel()
|
processor_config = ProcessorConfigModel()
|
||||||
config = {}
|
|
||||||
config_file = ""
|
config_file = ""
|
||||||
verbose = 0
|
verbose = 0
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
@@ -33,11 +33,11 @@ def ui(request: Request):
|
|||||||
return templates.TemplateResponse("config.html", context={'request': request})
|
return templates.TemplateResponse("config.html", context={'request': request})
|
||||||
|
|
||||||
@app.get('/config', response_model=FullConfig)
|
@app.get('/config', response_model=FullConfig)
|
||||||
def config():
|
def config_data():
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@app.post('/config')
|
@app.post('/config')
|
||||||
async def config(updated_config: FullConfig):
|
async def config_data(updated_config: FullConfig):
|
||||||
global config
|
global config
|
||||||
config = updated_config
|
config = updated_config
|
||||||
with open(config_file, 'w') as outfile:
|
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')
|
@app.get('/regenerate')
|
||||||
def regenerate(t: Optional[SearchType] = None):
|
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'}
|
return {'status': 'ok', 'message': 'regeneration completed'}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ def collate_results(hits, entries, count=5):
|
|||||||
in hits[0:count]]
|
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
|
# Initialize Model
|
||||||
bi_encoder, cross_encoder, top_k = 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]]
|
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
|
# Initialize Model
|
||||||
encoder = initialize_model()
|
encoder = initialize_model()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user