mirror of
https://github.com/RYDE-WORK/Langchain-Chatchat.git
synced 2026-02-07 15:38:27 +08:00
子命令处理
This commit is contained in:
parent
d0aa044329
commit
9f045e6191
@ -1,52 +1,88 @@
|
|||||||
from chatchat.configs import config_basic_workspace as workspace
|
from chatchat.configs import (
|
||||||
|
config_basic_workspace,
|
||||||
|
config_model_workspace,
|
||||||
|
)
|
||||||
|
|
||||||
|
# We cannot lazy-load click here because its used via decorators.
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
@click.group(help="指令` chatchat-config` 工作空间配置")
|
||||||
def main():
|
def main():
|
||||||
import argparse
|
pass
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="指令` chatchat-config` 工作空间配置")
|
|
||||||
# 只能选择true或false
|
|
||||||
parser.add_argument(
|
|
||||||
"-v",
|
|
||||||
"--verbose",
|
|
||||||
choices=["true", "false"],
|
|
||||||
help="是否开启详细日志"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-d",
|
|
||||||
"--data",
|
|
||||||
help="数据存放路径"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"-f",
|
|
||||||
"--format",
|
|
||||||
help="日志格式"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--clear",
|
|
||||||
action="store_true",
|
|
||||||
help="清除配置"
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--show",
|
|
||||||
action="store_true",
|
|
||||||
help="显示配置"
|
|
||||||
)
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
if args.verbose:
|
@main.command("basic", help="基础配置")
|
||||||
if args.verbose.lower() == "true":
|
@click.option("--verbose", type=click.Choice(["true", "false"]), help="是否开启详细日志")
|
||||||
workspace.set_log_verbose(True)
|
@click.option("--data", help="数据存放路径")
|
||||||
|
@click.option("--format", help="日志格式")
|
||||||
|
@click.option("--clear", is_flag=True, help="清除配置")
|
||||||
|
@click.option("--show", is_flag=True, help="显示配置")
|
||||||
|
def basic(**kwargs):
|
||||||
|
|
||||||
|
if kwargs["verbose"]:
|
||||||
|
if kwargs["verbose"].lower() == "true":
|
||||||
|
config_basic_workspace.set_log_verbose(True)
|
||||||
else:
|
else:
|
||||||
workspace.set_log_verbose(False)
|
config_basic_workspace.set_log_verbose(False)
|
||||||
if args.data:
|
if kwargs["data"]:
|
||||||
workspace.set_data_path(args.data)
|
config_basic_workspace.set_data_path(kwargs["data"])
|
||||||
if args.format:
|
if kwargs["format"]:
|
||||||
workspace.set_log_format(args.format)
|
config_basic_workspace.set_log_format(kwargs["format"])
|
||||||
if args.clear:
|
if kwargs["clear"]:
|
||||||
workspace.clear()
|
config_basic_workspace.clear()
|
||||||
if args.show:
|
if kwargs["show"]:
|
||||||
print(workspace.get_config())
|
print(config_basic_workspace.get_config())
|
||||||
|
|
||||||
|
|
||||||
|
@main.command("model", help="模型配置")
|
||||||
|
@click.option("--default_llm_model", help="默认llm模型")
|
||||||
|
@click.option("--default_embedding_model", help="默认embedding模型")
|
||||||
|
@click.option("--agent_model", help="agent模型")
|
||||||
|
@click.option("--history_len", type=int, help="历史长度")
|
||||||
|
@click.option("--max_tokens", type=int, help="最大tokens")
|
||||||
|
@click.option("--temperature", type=float, help="温度")
|
||||||
|
@click.option("--support_agent_models", multiple=True, help="支持的agent模型")
|
||||||
|
@click.option("--model_providers_cfg_path_config", help="模型平台配置文件路径")
|
||||||
|
@click.option("--model_providers_cfg_host", help="模型平台配置服务host")
|
||||||
|
@click.option("--model_providers_cfg_port", type=int, help="模型平台配置服务port")
|
||||||
|
@click.option("--clear", is_flag=True, help="清除配置")
|
||||||
|
@click.option("--show", is_flag=True, help="显示配置")
|
||||||
|
def model(**kwargs):
|
||||||
|
|
||||||
|
if kwargs["default_llm_model"]:
|
||||||
|
config_model_workspace.set_default_llm_model(llm_model=kwargs["default_llm_model"])
|
||||||
|
if kwargs["default_embedding_model"]:
|
||||||
|
config_model_workspace.set_default_embedding_model(embedding_model=kwargs["default_embedding_model"])
|
||||||
|
|
||||||
|
if kwargs["agent_model"]:
|
||||||
|
config_model_workspace.set_agent_model(agent_model=kwargs["agent_model"])
|
||||||
|
|
||||||
|
if kwargs["history_len"]:
|
||||||
|
config_model_workspace.set_history_len(history_len=kwargs["history_len"])
|
||||||
|
|
||||||
|
if kwargs["max_tokens"]:
|
||||||
|
config_model_workspace.set_max_tokens(max_tokens=kwargs["max_tokens"])
|
||||||
|
|
||||||
|
if kwargs["temperature"]:
|
||||||
|
config_model_workspace.set_temperature(temperature=kwargs["temperature"])
|
||||||
|
|
||||||
|
if kwargs["support_agent_models"]:
|
||||||
|
config_model_workspace.set_support_agent_models(support_agent_models=kwargs["support_agent_models"])
|
||||||
|
|
||||||
|
if kwargs["model_providers_cfg_path_config"]:
|
||||||
|
config_model_workspace.set_model_providers_cfg_path_config(model_providers_cfg_path_config=kwargs["model_providers_cfg_path_config"])
|
||||||
|
|
||||||
|
if kwargs["model_providers_cfg_host"]:
|
||||||
|
config_model_workspace.set_model_providers_cfg_host(model_providers_cfg_host=kwargs["model_providers_cfg_host"])
|
||||||
|
|
||||||
|
if kwargs["model_providers_cfg_port"]:
|
||||||
|
config_model_workspace.set_model_providers_cfg_port(model_providers_cfg_port=kwargs["model_providers_cfg_port"])
|
||||||
|
|
||||||
|
if kwargs["clear"]:
|
||||||
|
config_model_workspace.clear()
|
||||||
|
if kwargs["show"]:
|
||||||
|
print(config_model_workspace.get_config())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@ -34,9 +34,9 @@ class ConfigModel(core_config.Config):
|
|||||||
MODEL_PROVIDERS_CFG_PATH_CONFIG: Optional[str] = None
|
MODEL_PROVIDERS_CFG_PATH_CONFIG: Optional[str] = None
|
||||||
"""模型平台配置文件路径"""
|
"""模型平台配置文件路径"""
|
||||||
MODEL_PROVIDERS_CFG_HOST: Optional[str] = None
|
MODEL_PROVIDERS_CFG_HOST: Optional[str] = None
|
||||||
"""模型平台配置文件host"""
|
"""模型平台配置服务host"""
|
||||||
MODEL_PROVIDERS_CFG_PORT: Optional[int] = None
|
MODEL_PROVIDERS_CFG_PORT: Optional[int] = None
|
||||||
"""模型平台配置文件port"""
|
"""模型平台配置服务port"""
|
||||||
TOOL_CONFIG: Optional[Dict[str, Any]] = None
|
TOOL_CONFIG: Optional[Dict[str, Any]] = None
|
||||||
"""工具配置项"""
|
"""工具配置项"""
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user