#!/usr/bin/env python3 # -*- coding: utf-8 -*- """专题五 · 步骤 7 · 修改后:patch chat.py 合并多条 system(同专题四步骤 4)。""" from __future__ import annotations import sys import _bootstrap # noqa: F401 import _plugin_patch as P from dify_api import Dify import _config as C # noqa: F401 def main() -> int: d = Dify(C.DIFY_EMAIL, C.DIFY_PASSWORD) try: d.login() chat_path = P.find_plugin_file(d, "chat.py") content = P.read_remote_file(d, chat_path) new_content = P.replace_function(content, "_ensure_system_first", P.ENSURE_SYSTEM_FIRST) P.deploy_plugin_file(d, chat_path, new_content) print("已应用 chat.py 合并 system 补丁") return 0 finally: d.close() if __name__ == "__main__": sys.exit(main())