From 6747e1d44177e419ecde9a51a41380fdcd6543d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A2=A8=E6=A2=93=E6=9F=92?= <1787882683@qq.com> Date: Fri, 2 May 2025 20:42:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=EF=BC=8C=E6=B7=BB=E5=8A=A0lpmm=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=B9=B6=E4=BC=98=E5=8C=96=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/knowledge/src/lpmmconfig.py | 24 ++++++++++-------------- template/lpmm_config_template.toml | 3 +++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/plugins/knowledge/src/lpmmconfig.py b/src/plugins/knowledge/src/lpmmconfig.py index 753562f45..040bdedc0 100644 --- a/src/plugins/knowledge/src/lpmmconfig.py +++ b/src/plugins/knowledge/src/lpmmconfig.py @@ -1,7 +1,7 @@ import os import toml import sys -import argparse +# import argparse from .global_logger import logger PG_NAMESPACE = "paragraph" @@ -37,7 +37,8 @@ def _load_config(config, config_file_path): # Check if all top-level keys from default config exist in the file config for key in config.keys(): if key not in file_config: - print(f"警告: 配置文件 '{config_file_path}' 缺少必需的顶级键: '{key}'。请检查配置文件。") + logger.critical(f"警告: 配置文件 '{config_file_path}' 缺少必需的顶级键: '{key}'。请检查配置文件。") + logger.critical("请通过template/lpmm_config_template.toml文件进行更新") sys.exit(1) if "llm_providers" in file_config: @@ -68,16 +69,11 @@ def _load_config(config, config_file_path): logger.info(f"从文件中读取配置: {config_file_path}") -parser = argparse.ArgumentParser(description="Configurations for the pipeline") -parser.add_argument( - "--config_path", - type=str, - default="lpmm_config.toml", - help="Path to the configuration file", -) - global_config = dict( { + "lpmm":{ + "version": "0.1.0", + }, "llm_providers": { "localhost": { "base_url": "https://api.siliconflow.cn/v1", @@ -136,8 +132,8 @@ global_config = dict( ) # _load_config(global_config, parser.parse_args().config_path) -file_path = os.path.abspath(__file__) -dir_path = os.path.dirname(file_path) -root_path = os.path.join(dir_path, os.pardir, os.pardir, os.pardir, os.pardir) -config_path = os.path.join(root_path, "config", "lpmm_config.toml") +# file_path = os.path.abspath(__file__) +# dir_path = os.path.dirname(file_path) +ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..")) +config_path = os.path.join(ROOT_PATH, "config", "lpmm_config.toml") _load_config(global_config, config_path) diff --git a/template/lpmm_config_template.toml b/template/lpmm_config_template.toml index 8563b7caf..aae664d51 100644 --- a/template/lpmm_config_template.toml +++ b/template/lpmm_config_template.toml @@ -1,3 +1,6 @@ +[lpmm] +version = "0.1.0" + # LLM API 服务提供商,可配置多个 [[llm_providers]] name = "localhost"