mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-01-19 13:23:16 +08:00
配置中心知识库信息 子命令入口
This commit is contained in:
parent
1399238616
commit
abed17896d
@ -1,3 +1,5 @@
|
||||
import json
|
||||
|
||||
from chatchat.configs import (
|
||||
config_basic_workspace,
|
||||
config_model_workspace,
|
||||
@ -136,7 +138,8 @@ def server(**kwargs):
|
||||
@click.option('--pdf-ocr-threshold', type=(float, float), help='pdf ocr threshold')
|
||||
@click.option('--set_kb_info', type=str, help='''每个知识库的初始化介绍,用于在初始化知识库时显示和Agent调用,
|
||||
没写则没有介绍,不会被Agent调用。
|
||||
Example: \'{"samples": "关于本项目issue的解答"}\'
|
||||
as a JSON string.
|
||||
Example: "{\"samples\": \"关于本项目issue的解答\"}"
|
||||
''')
|
||||
@click.option("--set_kb_root_path", help="设置知识库根路径")
|
||||
@click.option("--set_db_root_path", help="设置db根路径")
|
||||
@ -175,7 +178,8 @@ def kb(**kwargs):
|
||||
if kwargs["pdf_ocr_threshold"]:
|
||||
config_kb_workspace.set_pdf_ocr_threshold(pdf_ocr_threshold=kwargs["pdf_ocr_threshold"])
|
||||
if kwargs["set_kb_info"]:
|
||||
config_kb_workspace.set_kb_info(kb_info=ast.literal_eval(kwargs["set_kb_info"]))
|
||||
kb_info_dict = json.loads(kwargs["set_kb_info"])
|
||||
config_kb_workspace.set_kb_info(kb_info=kb_info_dict)
|
||||
if kwargs["set_kb_root_path"]:
|
||||
config_kb_workspace.set_kb_root_path(kb_root_path=kwargs["set_kb_root_path"])
|
||||
if kwargs["set_db_root_path"]:
|
||||
|
||||
@ -262,57 +262,75 @@ class ConfigKbWorkSpace(core_config.ConfigWorkSpace[ConfigKbFactory, ConfigKb]):
|
||||
|
||||
def set_default_knowledge_base(self, kb_name: str):
|
||||
self._config_factory.DEFAULT_KNOWLEDGE_BASE = kb_name
|
||||
self.store_config()
|
||||
|
||||
def set_default_vs_type(self, vs_type: str):
|
||||
self._config_factory.DEFAULT_VS_TYPE = vs_type
|
||||
self.store_config()
|
||||
|
||||
def set_cached_vs_num(self, cached_vs_num: int):
|
||||
self._config_factory.CACHED_VS_NUM = cached_vs_num
|
||||
self.store_config()
|
||||
|
||||
def set_cached_memo_vs_num(self, cached_memo_vs_num: int):
|
||||
self._config_factory.CACHED_MEMO_VS_NUM = cached_memo_vs_num
|
||||
self.store_config()
|
||||
|
||||
def set_chunk_size(self, chunk_size: int):
|
||||
self._config_factory.CHUNK_SIZE = chunk_size
|
||||
self.store_config()
|
||||
|
||||
def set_overlap_size(self, overlap_size: int):
|
||||
self._config_factory.OVERLAP_SIZE = overlap_size
|
||||
self.store_config()
|
||||
|
||||
def set_vector_search_top_k(self, vector_search_top_k: int):
|
||||
self._config_factory.VECTOR_SEARCH_TOP_K = vector_search_top_k
|
||||
self.store_config()
|
||||
|
||||
def set_score_threshold(self, score_threshold: float):
|
||||
self._config_factory.SCORE_THRESHOLD = score_threshold
|
||||
self.store_config()
|
||||
|
||||
def set_default_search_engine(self, default_search_engine: str):
|
||||
self._config_factory.DEFAULT_SEARCH_ENGINE = default_search_engine
|
||||
self.store_config()
|
||||
|
||||
def set_search_engine_top_k(self, search_engine_top_k: int):
|
||||
self._config_factory.SEARCH_ENGINE_TOP_K = search_engine_top_k
|
||||
self.store_config()
|
||||
|
||||
def set_zh_title_enhance(self, zh_title_enhance: bool):
|
||||
self._config_factory.ZH_TITLE_ENHANCE = zh_title_enhance
|
||||
self.store_config()
|
||||
|
||||
def set_pdf_ocr_threshold(self, pdf_ocr_threshold: Tuple[float, float]):
|
||||
self._config_factory.PDF_OCR_THRESHOLD = pdf_ocr_threshold
|
||||
self.store_config()
|
||||
|
||||
def set_kb_info(self, kb_info: Dict[str, str]):
|
||||
self._config_factory.KB_INFO = kb_info
|
||||
self.store_config()
|
||||
|
||||
def set_kb_root_path(self, kb_root_path: str):
|
||||
self._config_factory.KB_ROOT_PATH = kb_root_path
|
||||
self.store_config()
|
||||
|
||||
def set_db_root_path(self, db_root_path: str):
|
||||
self._config_factory.DB_ROOT_PATH = db_root_path
|
||||
self.store_config()
|
||||
|
||||
def set_sqlalchemy_database_uri(self, sqlalchemy_database_uri: str):
|
||||
self._config_factory.SQLALCHEMY_DATABASE_URI = sqlalchemy_database_uri
|
||||
self.store_config()
|
||||
|
||||
def set_text_splitter_name(self, text_splitter_name: str):
|
||||
self._config_factory.TEXT_SPLITTER_NAME = text_splitter_name
|
||||
self.store_config()
|
||||
|
||||
def set_embedding_keyword_file(self, embedding_keyword_file: str):
|
||||
self._config_factory.EMBEDDING_KEYWORD_FILE = embedding_keyword_file
|
||||
self.store_config()
|
||||
|
||||
|
||||
config_kb_workspace: ConfigKbWorkSpace = ConfigKbWorkSpace()
|
||||
|
||||
@ -124,18 +124,23 @@ class ConfigServerWorkSpace(core_config.ConfigWorkSpace[ConfigServerFactory, Con
|
||||
|
||||
def set_httpx_default_timeout(self, timeout: float):
|
||||
self._config_factory.httpx_default_timeout(timeout)
|
||||
self.store_config()
|
||||
|
||||
def set_open_cross_domain(self, open_cross_domain: bool):
|
||||
self._config_factory.open_cross_domain(open_cross_domain)
|
||||
self.store_config()
|
||||
|
||||
def set_default_bind_host(self, default_bind_host: str):
|
||||
self._config_factory.default_bind_host(default_bind_host)
|
||||
self.store_config()
|
||||
|
||||
def set_webui_server_port(self, webui_server_port: int):
|
||||
self._config_factory.webui_server_port(webui_server_port)
|
||||
self.store_config()
|
||||
|
||||
def set_api_server_port(self, api_server_port: int):
|
||||
self._config_factory.api_server_port(api_server_port)
|
||||
self.store_config()
|
||||
|
||||
|
||||
config_server_workspace: ConfigServerWorkSpace = ConfigServerWorkSpace()
|
||||
Loading…
x
Reference in New Issue
Block a user