from __future__ import annotations from flask import current_app from app.services.shipping_notice.agent_resolver import CHAT_AGENT_NAME from app.services.shipping_notice.tool_api_url import resolve_tool_api_base_url # Dify Chatflow input variable names — must match canvas Start / 输入变量配置. HXOPS_TOOL_API_BASE_INPUT = "hxops_tool_api_base" HXOPS_TOOL_API_KEY_INPUT = "hxops_tool_api_key" def is_shipping_notice_chat_agent(agent) -> bool: return getattr(agent, "name", None) == CHAT_AGENT_NAME def build_dify_chat_inputs() -> dict[str, str]: """Build Dify chat API inputs so HTTP nodes can reference env-specific hxops URLs.""" base = resolve_tool_api_base_url() key = str(current_app.config.get("SHIPPING_NOTICE_TOOL_API_KEY") or "").strip() inputs: dict[str, str] = {} if base: inputs[HXOPS_TOOL_API_BASE_INPUT] = base if key: inputs[HXOPS_TOOL_API_KEY_INPUT] = key return inputs