mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2025-09-13 08:39:42 +00:00
[feature] release 0.1.3
This commit is contained in:
parent
67f8b370c3
commit
4d1d561d28
58 changed files with 11709 additions and 374 deletions
|
@ -5,10 +5,11 @@ Description :
|
|||
Author : unicornchan
|
||||
Date : 2024-06-11 16:35:42
|
||||
Version : 1.0.0
|
||||
LastEditors : chenxl
|
||||
LastEditTime : 2024-07-27 01:55:42
|
||||
LastEditors : WuHao
|
||||
LastEditTime : 2024-08-12 06:31:14
|
||||
'''
|
||||
import os
|
||||
import shutil
|
||||
import yaml
|
||||
|
||||
from ktransformers.server.config.singleton import Singleton
|
||||
|
@ -30,10 +31,18 @@ class Config(metaclass=Singleton):
|
|||
os.path.dirname(os.path.dirname(__file__)))
|
||||
config_yaml: str = os.path.join(
|
||||
base_path, "configs", Config.CONFIG_FILE_NAME)
|
||||
|
||||
user_path: str = os.path.expanduser('~')
|
||||
localstore_path: str = os.path.join(user_path,'.ktransformers')
|
||||
config_path: str = os.path.join(localstore_path,Config.CONFIG_FILE_NAME)
|
||||
if not os.path.exists(config_yaml):
|
||||
print(f"Can't find config file, {config_yaml}")
|
||||
exit(-1)
|
||||
with open(config_yaml, 'r', encoding="utf-8") as fp:
|
||||
if not os.path.exists(localstore_path):
|
||||
os.mkdir(localstore_path)
|
||||
if not os.path.exists(config_path):
|
||||
shutil.copyfile(config_yaml,config_path)
|
||||
with open(config_path, 'r', encoding="utf-8") as fp:
|
||||
config = yaml.safe_load(fp)
|
||||
return config
|
||||
|
||||
|
@ -51,6 +60,8 @@ class Config(metaclass=Singleton):
|
|||
cfg = Config.load()
|
||||
self.base_path = os.path.dirname(
|
||||
os.path.dirname(os.path.dirname(__file__)))
|
||||
self.user_path: str = os.path.expanduser('~')
|
||||
self.localstore_path: str = os.path.join(self.user_path,'.ktransformers')
|
||||
# log configs
|
||||
self.log_dir = os.path.join(self.base_path, Config.to_path(cfg["log"]["dir"]))
|
||||
self.log_file = cfg["log"]["file"]
|
||||
|
@ -83,11 +94,20 @@ class Config(metaclass=Singleton):
|
|||
self.model_name: str = self.model.get("name", "")
|
||||
self.model_device: str = self.model.get("device", "cuda:0")
|
||||
self.gguf_path: str = self.model.get("gguf_path", "")
|
||||
self.model_cache_lens = self.model.get("cache_lens")
|
||||
|
||||
# web config
|
||||
self.web: dict = cfg.get("web", {})
|
||||
self.web_cross_domain: bool = self.web.get("open_cross_domain", True)
|
||||
self.mount_web: bool = self.web.get("mount", False)
|
||||
|
||||
|
||||
self.ext: dict = cfg.get("ext", {})
|
||||
self.cpu_infer = self.ext.get("cpu_infer", 10)
|
||||
|
||||
#file config
|
||||
self.local_store_configs: dict = cfg.get("local_store",{})
|
||||
self.file_upload_dir: str = os.path.join(self.localstore_path,self.local_store_configs.get("file_upload_dir",""))
|
||||
self.assistant_store_dir: str = os.path.join(self.localstore_path,self.local_store_configs.get("assistant_store_dir",""))
|
||||
|
||||
#long context config
|
||||
self.long_context_config: dict = cfg.get("long_context",{})
|
Loading…
Add table
Add a link
Reference in a new issue