mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 05:39:06 +00:00
Create khoj_sample file with all configurable fields in one place
- Reason - Simplifies code. No merge_dict required - 1 place for user to see all configurables, defaults and required values - Details - Remove default_config from code. Set defaults in khoj_sample.yml itself - Keep fields required to be set by user as empty in khoj_sample to YAML - Set defaults for fields not requiring configuration by user
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# Standard Packages
|
||||
import argparse
|
||||
import pathlib
|
||||
import json
|
||||
|
||||
# External Packages
|
||||
import yaml
|
||||
@@ -28,55 +27,16 @@ def cli(args=None):
|
||||
if not (args.config_file):
|
||||
print(f"Need --config-file flag to be passed from commandline")
|
||||
exit(1)
|
||||
elif not resolve_absolute_path(args.config_file).exists():
|
||||
print(f"Config file {args.config_file} does not exist")
|
||||
exit(1)
|
||||
|
||||
# Config Priority: Config File > Default Config
|
||||
args.config = default_config
|
||||
if args.config_file and resolve_absolute_path(args.config_file).exists():
|
||||
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
||||
config_from_file = yaml.safe_load(config_file)
|
||||
args.config = merge_dicts(priority_dict=config_from_file, default_dict=args.config)
|
||||
# Read Config from YML file
|
||||
config_from_file = None
|
||||
with open(get_absolute_path(args.config_file), 'r', encoding='utf-8') as config_file:
|
||||
config_from_file = yaml.safe_load(config_file)
|
||||
|
||||
args.config = FullConfig.parse_obj(args.config)
|
||||
# Parse, Validate Config in YML file
|
||||
args.config = FullConfig.parse_obj(config_from_file)
|
||||
|
||||
return args
|
||||
|
||||
|
||||
default_config = {
|
||||
'content-type':
|
||||
{
|
||||
'org': None,
|
||||
'ledger': None,
|
||||
'image': None,
|
||||
'music': None,
|
||||
'markdown': None,
|
||||
},
|
||||
'search-type':
|
||||
{
|
||||
'symmetric':
|
||||
{
|
||||
'encoder': "sentence-transformers/all-MiniLM-L6-v2",
|
||||
'cross-encoder': "cross-encoder/ms-marco-MiniLM-L-6-v2",
|
||||
'model_directory': None
|
||||
},
|
||||
'asymmetric':
|
||||
{
|
||||
'encoder': "sentence-transformers/multi-qa-MiniLM-L6-cos-v1",
|
||||
'cross-encoder': "cross-encoder/ms-marco-MiniLM-L-6-v2",
|
||||
'model_directory': None
|
||||
},
|
||||
'image':
|
||||
{
|
||||
'encoder': "clip-ViT-B-32",
|
||||
'model_directory': None
|
||||
},
|
||||
},
|
||||
'processor':
|
||||
{
|
||||
'conversation':
|
||||
{
|
||||
'openai-api-key': "",
|
||||
'conversation-logfile': ".conversation_logs.json",
|
||||
'conversation-history': ""
|
||||
},
|
||||
}
|
||||
}
|
||||
return args
|
||||
Reference in New Issue
Block a user