#!/usr/bin/env python3 # -*- coding: utf-8 -*- """专题十四 · 步骤 1:读 Agent 快照 max_tokens 与 retrieval。""" from __future__ import annotations import sys import _bootstrap # noqa: F401 import _config as C from dify_api import Dify def main() -> int: d = Dify(C.DIFY_EMAIL, C.DIFY_PASSWORD) try: sql = """ SELECT config_snapshot::json -> 'model' -> 'model_settings' -> 'max_tokens' AS max_tokens, config_snapshot::json -> 'knowledge' -> 'sets' -> 0 -> 'retrieval' AS retrieval FROM agent_config_snapshots WHERE id = '%s'; """ % C.SNAP_ID out, err = d.sh( 'docker exec %s psql -U postgres -d dify -c "%s"' % (C.PG_CONTAINER, sql.replace("\n", " ")) ) print(out or err) return 0 finally: d.close() if __name__ == "__main__": sys.exit(main())