#!/usr/bin/env python3 # -*- coding: utf-8 -*- """专题十五 · 步骤 1.2:POST /apps 创建 mode=agent 空壳。""" from __future__ import annotations import sys import _bootstrap # noqa: F401 import _config as C from dify_api import Dify, pp def main() -> int: d = Dify(C.DIFY_EMAIL, C.DIFY_PASSWORD) try: d.login() body = { "name": C.NEW_APP_NAME, "description": "企业内部制度问答", "mode": "agent", "icon_type": "emoji", "icon": "🤖", "icon_background": "#FFEAD5", } r = d.post("/apps", body) pp("create app", r) app_id = (r.get("json") or {}).get("id") print("app_id", app_id) if not app_id: return 1 print("下一步:运行 专题十五_02_查三个ID.py 记下 agent_id / snapshot_id / draft_id") return 0 if r.get("code") in ("200", "201") else 1 finally: d.close() if __name__ == "__main__": sys.exit(main())