-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from arjbingly/make-config
Ability to create a defaults config file
- Loading branch information
Showing
4 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Runnable file for creating a default config.ini file.""" | ||
|
||
import shutil | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
import grag.resources | ||
from importlib_resources import files | ||
|
||
|
||
def create_config(path: Union[str, Path] = '.') -> None: | ||
"""Create a configuration file if it doesn't exist. | ||
This function checks for the existence of a 'config.ini' file at the given path. | ||
If the file does not exist, it copies a default configuration file from the package's | ||
resources to the specified location. If the file already exists, it notifies the user | ||
and does not overwrite the existing file. | ||
Args: | ||
path (Union[str, Path]): The directory path where the 'config.ini' should be | ||
located. If not specified, defaults to the current | ||
directory ('.'). | ||
Returns: | ||
None | ||
Raises: | ||
FileNotFoundError: If the default configuration file does not exist. | ||
PermissionError: If the process does not have permission to write to the specified | ||
directory. | ||
""" | ||
default_config_path = files(grag.resources).joinpath('default_config.ini') | ||
path = Path(path) / 'config.ini' | ||
path = path.resolve() | ||
if path.exists(): | ||
print('Config file already exists') | ||
else: | ||
shutil.copyfile(default_config_path, path, follow_symlinks=True) | ||
print(f"Created config file at {path}") | ||
|
||
|
||
if __name__ == '__main__': | ||
create_config() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
; This is the default config.ini file generated by GRAG | ||
; All values are same as package defaults | ||
; Values that do not have a default value are commented out | ||
|
||
; Make sure to fill in the path configs under data, env, quantize and root (whatever applies) | ||
|
||
[llm] | ||
;model_name : Llama-2-13b-chat | ||
;quantization : Q5_K_M | ||
;pipeline : llama_cpp | ||
device_map : auto | ||
task : text-generation | ||
max_new_tokens : 1024 | ||
temperature : 0.1 | ||
n_batch : 1024 | ||
n_ctx : 6000 | ||
n_gpu_layers : -1 | ||
std_out : True | ||
base_dir : ${root:root_path}/models | ||
|
||
[chroma_client] | ||
host : localhost | ||
port : 8000 | ||
collection_name : grag | ||
embedding_type : instructor-embedding | ||
embedding_model : hkunlp/instructor-xl | ||
|
||
[deeplake_client] | ||
collection_name : grag | ||
embedding_type : instructor-embedding | ||
embedding_model : hkunlp/instructor-xl | ||
store_path : ${data:data_path}/vectordb | ||
|
||
[text_splitter] | ||
chunk_size : 2000 | ||
chunk_overlap : 400 | ||
|
||
[multivec_retriever] | ||
store_path : ${data:data_path}/doc_store | ||
top_k : 3 | ||
id_key : doc_id | ||
namespace : 71e4b558187b270922923569301f1039 | ||
|
||
[parse_pdf] | ||
single_text_out : True | ||
strategy : hi_res | ||
infer_table_structure : True | ||
extract_images : True | ||
image_output_dir : None | ||
add_captions_to_text : True | ||
add_captions_to_blocks : True | ||
table_as_html : False | ||
|
||
;[data] | ||
;data_path : ${root:root_path}/data | ||
; | ||
;[env] | ||
;env_path : ${root:root_path}/.env | ||
; | ||
;[quantize] | ||
;llama_cpp_path : ${root:root_path} | ||
; | ||
;[root] | ||
;root_path : ~/Capstone_5 |