#!/usr/bin/env python3 # -*- coding: utf-8 -*- """专题十 · 步骤 2 · 修改后:修正 llm.py,移除 model_properties 中的 max_tokens。""" 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() llm_path = P.find_plugin_file(d, "llm.py") 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 补丁(仅 context_size,不含 max_tokens)") return 0 finally: d.close() if __name__ == "__main__": sys.exit(main())