mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-11-09 23:30:13 +08:00
Run `ruff check app tests scripts --fix` with the configured rule set (E4/E7/E9/F/I): import sorting (I001), f-strings without placeholders (F541), lambda/variable/unused-import cleanups that ruff marks safe. Nine files whose only ruff debt sits next to pre-existing pylint import-resolution errors (lazy exports, sys.path script imports) or whose "unused" imports are reached through attribute access by tests are left untouched so the changed-file pylint gate and the benchmark tests stay green; their diagnostics remain in the baseline. app/startup/lifecycle/__init__.py and app/main.py import business modules after cache composition, import-path and stdio setup on purpose (the source comments document the contract), so declare E402 per-file-ignores for them instead of adding per-line noqa. Ruff ratchet watermark drops from 498 to 100; sync the baseline fixture and the optimization checklist figure. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
22 lines
680 B
Python
22 lines
680 B
Python
from langchain_core.messages import ContentBlock, SystemMessage
|
|
|
|
|
|
def append_to_system_message(
|
|
system_message: SystemMessage | None,
|
|
text: str,
|
|
) -> SystemMessage:
|
|
"""将文本追加到系统消息。
|
|
|
|
参数:
|
|
system_message: 现有的系统消息或 None。
|
|
text: 要添加到系统消息的文本。
|
|
|
|
返回:
|
|
追加了文本的新 SystemMessage。
|
|
"""
|
|
new_content: list[ContentBlock] = list(system_message.content_blocks) if system_message else [] # noqa
|
|
if new_content:
|
|
text = f"\n\n{text}"
|
|
new_content.append({"type": "text", "text": text})
|
|
return SystemMessage(content_blocks=new_content)
|