feat: 更新配置模板,添加lpmm版本信息并优化错误日志输出
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import toml
|
import toml
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
# import argparse
|
||||||
from .global_logger import logger
|
from .global_logger import logger
|
||||||
|
|
||||||
PG_NAMESPACE = "paragraph"
|
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
|
# Check if all top-level keys from default config exist in the file config
|
||||||
for key in config.keys():
|
for key in config.keys():
|
||||||
if key not in file_config:
|
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)
|
sys.exit(1)
|
||||||
|
|
||||||
if "llm_providers" in file_config:
|
if "llm_providers" in file_config:
|
||||||
@@ -68,16 +69,11 @@ def _load_config(config, config_file_path):
|
|||||||
logger.info(f"从文件中读取配置: {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(
|
global_config = dict(
|
||||||
{
|
{
|
||||||
|
"lpmm":{
|
||||||
|
"version": "0.1.0",
|
||||||
|
},
|
||||||
"llm_providers": {
|
"llm_providers": {
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"base_url": "https://api.siliconflow.cn/v1",
|
"base_url": "https://api.siliconflow.cn/v1",
|
||||||
@@ -136,8 +132,8 @@ global_config = dict(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# _load_config(global_config, parser.parse_args().config_path)
|
# _load_config(global_config, parser.parse_args().config_path)
|
||||||
file_path = os.path.abspath(__file__)
|
# file_path = os.path.abspath(__file__)
|
||||||
dir_path = os.path.dirname(file_path)
|
# dir_path = os.path.dirname(file_path)
|
||||||
root_path = os.path.join(dir_path, os.pardir, os.pardir, os.pardir, os.pardir)
|
ROOT_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "..", ".."))
|
||||||
config_path = os.path.join(root_path, "config", "lpmm_config.toml")
|
config_path = os.path.join(ROOT_PATH, "config", "lpmm_config.toml")
|
||||||
_load_config(global_config, config_path)
|
_load_config(global_config, config_path)
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
[lpmm]
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
# LLM API 服务提供商,可配置多个
|
# LLM API 服务提供商,可配置多个
|
||||||
[[llm_providers]]
|
[[llm_providers]]
|
||||||
name = "localhost"
|
name = "localhost"
|
||||||
|
|||||||
Reference in New Issue
Block a user