: rm sensitive info in config.yaml, add readme of makefile. support old model_path config

This commit is contained in:
liam 2024-10-31 21:28:17 +08:00
parent 9a2e7057c8
commit a148da2cfe
6 changed files with 43 additions and 5 deletions

1
.gitignore vendored
View file

@ -18,3 +18,4 @@ compile_commands.json
ktransformers/server/local_store/
ktransformers/server_test1.db
*.patch
img/

View file

@ -151,7 +151,7 @@ Some preparation:
```
install.bat
```
4. If you are developer, you can make use of the makefile to compile and format the code. <br> the detailed usage of makefile is [here](./doc/en/makefile_usage.md)
<h3>Local Chat</h3>
We provide a simple command-line local chat Python script that you can run for testing.

26
doc/en/makefile_usage.md Normal file
View file

@ -0,0 +1,26 @@
# Makefile
## Target
### flake_find:
```bash
make flake_find
```
find all the python files under ./ktransformers dir and find the Error, Warning, Fatal... (their codes) into a list that are not consistent with the pep8 standard. For now we have get all this list in the .flake8 file's extend-ignore section in order to let flakes8 ignore them temporarily.(we may improve them in the future)
### format:
```bash
make format
```
we use black to format all the python files under ./ktransformers dir. It obeys the pep8 standard
but we modify the line length to 120 by add
```toml
[tool.black]
line-length = 120
preview = true
unstable = true
```
in the pyproject.toml file.
### dev_install:
```bash
make dev_install
```
install the package in the development mode. It means that the package is installed in the editable mode. So if you modify the code, you don't need to reinstall the package. We recommend the developer to use this method to install the package.

View file

@ -24,9 +24,7 @@ model:
type: ktransformers
name: DeepSeek-Coder-V2-Instruct
# path: /mnt/data/model/DeepSeek-Coder-V2-Instruct/
path: deepseek-ai/DeepSeek-V2-Lite-Chat
# gguf_path: /mnt/data/model/DeepSeek-Coder-V2-GGUF-WJH/
gguf_path: ./DeepSeek-V2-Lite-Chat-GGUF
device: cuda:0

View file

@ -14,7 +14,8 @@ class ArgumentParser:
parser.add_argument("--ssl_certfile", type=str)
parser.add_argument("--web", type=bool, default=self.cfg.mount_web)
parser.add_argument("--model_name", type=str, default=self.cfg.model_name)
parser.add_argument("--model_dir", type=str, default=self.cfg.model_dir)
parser.add_argument("--model_dir", type=str)
parser.add_argument("--model_path", type=str)
parser.add_argument(
"--device", type=str, default=self.cfg.model_device, help="Warning: Abandoning this parameter"
)
@ -100,6 +101,16 @@ class ArgumentParser:
parser.add_argument("--prompt_file", type=str, default=self.cfg.prompt_file)
args = parser.parse_args()
if (args.model_dir is not None):
if (args.model_path is not None):
# if pass model_dir and model_path, we use model_path
args.model_dir = args.model_path
else:
# if only pass model_dir, we use model_dir
args.model_path = args.model_dir
else:
args.model_dir = self.cfg.model_dir
args.model_path = self.cfg.model_path
# set config from args
for key, value in vars(args).items():
if value is not None and hasattr(self.cfg, key):

View file

@ -88,6 +88,8 @@ class Config(metaclass=Singleton):
self.model: dict = cfg.get("model", {})
self.backend_type: str = self.model.get("type", "transformers")
self.model_dir: str = self.model.get("path", "")
# to make sure it consistent with previous version
self.model_path: str = self.model_dir
self.model_name: str = self.model.get("name", "")
self.model_device: str = self.model.get("device", "cuda:0")
self.gguf_path: Optional[str] = self.model.get("gguf_path", None)