From 4527e0a8015ec6eabe95ef393b59b12fae8e3e32 Mon Sep 17 00:00:00 2001 From: kanchengw Date: Wed, 27 May 2026 20:57:18 +0800 Subject: [PATCH] add properties on chunk --- .../configs}/baidu/request_baidu.yaml | 0 .../configs}/baidu/response_baidu.yaml | 0 .../configs}/deepseek/request_deepseek.yaml | 0 .../configs}/deepseek/response_deepseek.yaml | 0 .../configs}/doubao/request_doubao.yaml | 0 .../configs}/doubao/response_doubao.yaml | 0 {configs => cnllm/configs}/glm/request_glm.yaml | 0 {configs => cnllm/configs}/glm/response_glm.yaml | 0 .../configs}/hunyuan/request_hunyuan.yaml | 0 .../configs}/hunyuan/response_hunyuan.yaml | 0 .../configs}/kimi/request_kimi.yaml | 0 .../configs}/kimi/response_kimi.yaml | 0 .../configs}/minimax/request_minimax.yaml | 0 .../configs}/minimax/response_minimax.yaml | 0 .../configs}/qwen/request_qwen.yaml | 0 .../configs}/qwen/response_qwen.yaml | 0 .../configs}/xiaomi/request_xiaomi.yaml | 0 .../configs}/xiaomi/response_xiaomi.yaml | 0 cnllm/core/adapter.py | 2 +- cnllm/core/embedding.py | 16 ++++++++-------- cnllm/core/responder.py | 2 +- cnllm/utils/validator.py | 5 ++--- cnllm/utils/vendor_error.py | 1 - pyproject.toml | 3 +++ 24 files changed, 15 insertions(+), 14 deletions(-) rename {configs => cnllm/configs}/baidu/request_baidu.yaml (100%) rename {configs => cnllm/configs}/baidu/response_baidu.yaml (100%) rename {configs => cnllm/configs}/deepseek/request_deepseek.yaml (100%) rename {configs => cnllm/configs}/deepseek/response_deepseek.yaml (100%) rename {configs => cnllm/configs}/doubao/request_doubao.yaml (100%) rename {configs => cnllm/configs}/doubao/response_doubao.yaml (100%) rename {configs => cnllm/configs}/glm/request_glm.yaml (100%) rename {configs => cnllm/configs}/glm/response_glm.yaml (100%) rename {configs => cnllm/configs}/hunyuan/request_hunyuan.yaml (100%) rename {configs => cnllm/configs}/hunyuan/response_hunyuan.yaml (100%) rename {configs => cnllm/configs}/kimi/request_kimi.yaml (100%) rename {configs => cnllm/configs}/kimi/response_kimi.yaml (100%) rename {configs => cnllm/configs}/minimax/request_minimax.yaml (100%) rename {configs => cnllm/configs}/minimax/response_minimax.yaml (100%) rename {configs => cnllm/configs}/qwen/request_qwen.yaml (100%) rename {configs => cnllm/configs}/qwen/response_qwen.yaml (100%) rename {configs => cnllm/configs}/xiaomi/request_xiaomi.yaml (100%) rename {configs => cnllm/configs}/xiaomi/response_xiaomi.yaml (100%) diff --git a/configs/baidu/request_baidu.yaml b/cnllm/configs/baidu/request_baidu.yaml similarity index 100% rename from configs/baidu/request_baidu.yaml rename to cnllm/configs/baidu/request_baidu.yaml diff --git a/configs/baidu/response_baidu.yaml b/cnllm/configs/baidu/response_baidu.yaml similarity index 100% rename from configs/baidu/response_baidu.yaml rename to cnllm/configs/baidu/response_baidu.yaml diff --git a/configs/deepseek/request_deepseek.yaml b/cnllm/configs/deepseek/request_deepseek.yaml similarity index 100% rename from configs/deepseek/request_deepseek.yaml rename to cnllm/configs/deepseek/request_deepseek.yaml diff --git a/configs/deepseek/response_deepseek.yaml b/cnllm/configs/deepseek/response_deepseek.yaml similarity index 100% rename from configs/deepseek/response_deepseek.yaml rename to cnllm/configs/deepseek/response_deepseek.yaml diff --git a/configs/doubao/request_doubao.yaml b/cnllm/configs/doubao/request_doubao.yaml similarity index 100% rename from configs/doubao/request_doubao.yaml rename to cnllm/configs/doubao/request_doubao.yaml diff --git a/configs/doubao/response_doubao.yaml b/cnllm/configs/doubao/response_doubao.yaml similarity index 100% rename from configs/doubao/response_doubao.yaml rename to cnllm/configs/doubao/response_doubao.yaml diff --git a/configs/glm/request_glm.yaml b/cnllm/configs/glm/request_glm.yaml similarity index 100% rename from configs/glm/request_glm.yaml rename to cnllm/configs/glm/request_glm.yaml diff --git a/configs/glm/response_glm.yaml b/cnllm/configs/glm/response_glm.yaml similarity index 100% rename from configs/glm/response_glm.yaml rename to cnllm/configs/glm/response_glm.yaml diff --git a/configs/hunyuan/request_hunyuan.yaml b/cnllm/configs/hunyuan/request_hunyuan.yaml similarity index 100% rename from configs/hunyuan/request_hunyuan.yaml rename to cnllm/configs/hunyuan/request_hunyuan.yaml diff --git a/configs/hunyuan/response_hunyuan.yaml b/cnllm/configs/hunyuan/response_hunyuan.yaml similarity index 100% rename from configs/hunyuan/response_hunyuan.yaml rename to cnllm/configs/hunyuan/response_hunyuan.yaml diff --git a/configs/kimi/request_kimi.yaml b/cnllm/configs/kimi/request_kimi.yaml similarity index 100% rename from configs/kimi/request_kimi.yaml rename to cnllm/configs/kimi/request_kimi.yaml diff --git a/configs/kimi/response_kimi.yaml b/cnllm/configs/kimi/response_kimi.yaml similarity index 100% rename from configs/kimi/response_kimi.yaml rename to cnllm/configs/kimi/response_kimi.yaml diff --git a/configs/minimax/request_minimax.yaml b/cnllm/configs/minimax/request_minimax.yaml similarity index 100% rename from configs/minimax/request_minimax.yaml rename to cnllm/configs/minimax/request_minimax.yaml diff --git a/configs/minimax/response_minimax.yaml b/cnllm/configs/minimax/response_minimax.yaml similarity index 100% rename from configs/minimax/response_minimax.yaml rename to cnllm/configs/minimax/response_minimax.yaml diff --git a/configs/qwen/request_qwen.yaml b/cnllm/configs/qwen/request_qwen.yaml similarity index 100% rename from configs/qwen/request_qwen.yaml rename to cnllm/configs/qwen/request_qwen.yaml diff --git a/configs/qwen/response_qwen.yaml b/cnllm/configs/qwen/response_qwen.yaml similarity index 100% rename from configs/qwen/response_qwen.yaml rename to cnllm/configs/qwen/response_qwen.yaml diff --git a/configs/xiaomi/request_xiaomi.yaml b/cnllm/configs/xiaomi/request_xiaomi.yaml similarity index 100% rename from configs/xiaomi/request_xiaomi.yaml rename to cnllm/configs/xiaomi/request_xiaomi.yaml diff --git a/configs/xiaomi/response_xiaomi.yaml b/cnllm/configs/xiaomi/response_xiaomi.yaml similarity index 100% rename from configs/xiaomi/response_xiaomi.yaml rename to cnllm/configs/xiaomi/response_xiaomi.yaml diff --git a/cnllm/core/adapter.py b/cnllm/core/adapter.py index d158b5a..e9c7e0c 100644 --- a/cnllm/core/adapter.py +++ b/cnllm/core/adapter.py @@ -111,7 +111,7 @@ def _load_class_config(cls) -> Dict[str, Any]: config_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", cls.CONFIG_DIR, f"request_{cls.ADAPTER_NAME}.yaml" + "..", "configs", cls.CONFIG_DIR, f"request_{cls.ADAPTER_NAME}.yaml" ) try: import yaml diff --git a/cnllm/core/embedding.py b/cnllm/core/embedding.py index e8ede37..a91cabf 100644 --- a/cnllm/core/embedding.py +++ b/cnllm/core/embedding.py @@ -24,12 +24,12 @@ def _find_config_for_model(model: str) -> tuple: config_dir = adapter_name.replace("-embedding", "") merged_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", config_dir, + "..", "configs", config_dir, f"request_{config_dir}.yaml" ) legacy_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", config_dir, + "..", "configs", config_dir, f"request_embedding_{config_dir}.yaml" ) config_path = merged_path if os.path.exists(merged_path) else legacy_path @@ -49,12 +49,12 @@ def _find_config_for_model(model: str) -> tuple: def _get_config_for_adapter(adapter_name: str) -> tuple: merged_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", adapter_name, + "..", "configs", adapter_name, f"request_{adapter_name}.yaml" ) legacy_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", adapter_name, + "..", "configs", adapter_name, f"request_embedding_{adapter_name}.yaml" ) config_path = merged_path if os.path.exists(merged_path) else legacy_path @@ -81,7 +81,7 @@ def _load_config(self) -> Dict[str, Any]: import yaml config_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", self.config_dir, + "..", "configs", self.config_dir, f"response_embedding_{self.config_dir}.yaml" ) try: @@ -176,12 +176,12 @@ def _load_class_config(cls) -> Dict[str, Any]: merged_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", cls.CONFIG_DIR, + "..", "configs", cls.CONFIG_DIR, f"request_{cls.CONFIG_DIR}.yaml" ) legacy_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", cls.CONFIG_DIR, + "..", "configs", cls.CONFIG_DIR, f"request_embedding_{cls.CONFIG_DIR}.yaml" ) config_path = merged_path if os.path.exists(merged_path) else legacy_path @@ -229,7 +229,7 @@ def __init__( if config_file is None: merged_config = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", self.CONFIG_DIR, + "..", "configs", self.CONFIG_DIR, f"request_{self.CONFIG_DIR}.yaml" ) legacy_config = f"request_embedding_{self.CONFIG_DIR}.yaml" diff --git a/cnllm/core/responder.py b/cnllm/core/responder.py index 4d8470f..75e13d5 100644 --- a/cnllm/core/responder.py +++ b/cnllm/core/responder.py @@ -38,7 +38,7 @@ def __init__(self, config_dir: str = None): def _load_config(self) -> Dict[str, Any]: config_path = os.path.join( os.path.dirname(__file__), - "..", "..", "configs", self.config_dir, f"response_{self.config_dir}.yaml" + "..", "configs", self.config_dir, f"response_{self.config_dir}.yaml" ) try: import yaml diff --git a/cnllm/utils/validator.py b/cnllm/utils/validator.py index de543f3..685928e 100644 --- a/cnllm/utils/validator.py +++ b/cnllm/utils/validator.py @@ -31,7 +31,6 @@ def _load_config(self) -> Dict[str, Any]: config_path = os.path.join( os.path.dirname(__file__), "..", - "..", "configs", self.config_dir, self.config_file @@ -191,7 +190,7 @@ def detect_protocol(base_url: str, config_dir: str) -> str: """ import os, yaml # 查找 YAML 文件 - base_path = os.path.join(os.path.dirname(__file__), "..", "..", "configs", config_dir) + base_path = os.path.join(os.path.dirname(__file__), "..", "configs", config_dir) for candidate in [f"request_{config_dir}.yaml", f"request_{config_dir}.yml"]: yaml_path = os.path.join(base_path, candidate) if os.path.exists(yaml_path): @@ -228,7 +227,7 @@ def has_protocol_config(config_dir: str) -> bool: 其他无多协议的厂商返回 False,避免不必要的 protocol 检测。 """ import os, yaml - base_path = os.path.join(os.path.dirname(__file__), "..", "..", "configs", config_dir) + base_path = os.path.join(os.path.dirname(__file__), "..", "configs", config_dir) for candidate in [f"request_{config_dir}.yaml", f"request_{config_dir}.yml"]: yaml_path = os.path.join(base_path, candidate) if os.path.exists(yaml_path): diff --git a/cnllm/utils/vendor_error.py b/cnllm/utils/vendor_error.py index 1326e39..4f904bd 100644 --- a/cnllm/utils/vendor_error.py +++ b/cnllm/utils/vendor_error.py @@ -55,7 +55,6 @@ def _load_config(self) -> Dict[str, Any]: config_path = os.path.join( os.path.dirname(__file__), "..", - "..", "configs", self.config_dir, f"request_{self.config_dir}.yaml" diff --git a/pyproject.toml b/pyproject.toml index f5f5402..4c428f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,3 +57,6 @@ asyncio_mode = "auto" [tool.setuptools.packages.find] where = ["."] include = ["cnllm*"] + +[tool.setuptools] +include-package-data = true