feat: 人设模板系统、节点调度标签、pydantic-settings收敛、错误处理增强

新增persona_template表和CRUD API,BaseIndividualModel增加node_affinity和template_origin_id字段,
WorkerCluster支持多集群Ray资源调度,环境变量收敛到pydantic-settings统一校验,
数据库异常转换为结构化BusinessError/RetryableError,系统节点支持custom_system_prompt。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 06:07:46 +00:00
parent f3a92a793e
commit 8f1398c591
23 changed files with 582 additions and 48 deletions
+6 -10
View File
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import sys
from loguru import logger
@@ -23,15 +22,11 @@ from kilostar.utils.request_context import get_request_id, get_trace_id
def _is_json_mode() -> bool:
"""根据环境变量决定是否启用 JSON 结构化日志。
支持开关:``KILOSTAR_LOG_FORMAT=json`` 或 ``KILOSTAR_LOG_JSON=1/true``。
"""
fmt = os.environ.get("KILOSTAR_LOG_FORMAT", "").lower()
if fmt == "json":
from kilostar.utils.settings import get_settings
s = get_settings().log
if s.kilostar_log_format.lower() == "json":
return True
flag = os.environ.get("KILOSTAR_LOG_JSON", "").lower()
return flag in {"1", "true", "yes", "on"}
return s.kilostar_log_json.lower() in {"1", "true", "yes", "on"}
def _ctx_patcher(record):
@@ -58,7 +53,8 @@ def setup_logger() -> Logger:
"""
logger.remove()
log_level = os.environ.get("KILOSTAR_LOG_LEVEL", "DEBUG").upper()
from kilostar.utils.settings import get_settings
log_level = get_settings().log.kilostar_log_level.upper()
if _is_json_mode():
logger.configure(