#!/usr/bin/env python3 # -*- coding: utf-8 -*- """专题五 · 步骤 6 · 修改后:patch llm.py get_customizable_model_schema(自定义模型可选)。""" from __future__ import annotations import sys import _bootstrap # noqa: F401 import _config as C import _plugin_patch as P from dify_api import Dify def main() -> int: d = Dify(C.DIFY_EMAIL, C.DIFY_PASSWORD) try: d.login() llm_path = P.find_plugin_file(d, "llm.py") print("llm.py:", llm_path) content = P.read_remote_file(d, llm_path) new_content = P.replace_method( content, "get_customizable_model_schema", P.GET_CUSTOMIZABLE_MODEL_SCHEMA ) P.deploy_plugin_file(d, llm_path, new_content) print("已应用 llm.py schema 补丁并重启 plugin_daemon") return 0 finally: d.close() if __name__ == "__main__": sys.exit(main())