Files
aiagent/backend/scripts/templates/template_customer_service.py
renjianbo 3dcf769660 feat: Android login/register add mandatory agreement checkbox
- LoginScreen: add agreement checkbox, disabled until checked
- RegisterScreen: add agreement checkbox, disabled until checked
- RegisterViewModel: pass agreed_terms/agreed_terms_version to API
- RegisterRequest DTO: add agreedTerms/agreedTermsVersion fields
- Also include 3 template scripts missed in previous commit

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-07-01 22:06:16 +08:00

58 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
路线图场景模板:客服 — 通过 API 从模板创建 Agent。
用法:
cd backend && .\\venv\\Scripts\\python.exe scripts/templates/template_customer_service.py
环境变量: PLATFORM_BASE_URL, PLATFORM_USERNAME, PLATFORM_PASSWORD,
AGENT_NAME默认 场景模板_客服_时间戳 可不用), TARGET_NAME
"""
from __future__ import annotations
import os
import sys
import time
import requests
BASE = os.getenv("PLATFORM_BASE_URL", "http://127.0.0.1:8037").rstrip("/")
USER = os.getenv("PLATFORM_USERNAME")
PWD = os.getenv("PLATFORM_PASSWORD")
TEMPLATE_ID = "template_customer_service"
DEFAULT_NAME = os.getenv("TARGET_NAME") or f"场景模板_客服_{int(time.time())}"
def main() -> int:
r = requests.post(
f"{BASE}/api/v1/auth/login",
data={"username": USER, "password": PWD},
headers={"Content-Type": "application/x-www-form-urlencoded"},
timeout=15,
)
if r.status_code != 200:
print("登录失败:", r.status_code, r.text[:500], file=sys.stderr)
return 1
token = r.json().get("access_token")
if not token:
print("无 access_token", file=sys.stderr)
return 1
h = {"Authorization": f"Bearer {token}", "Content-Type": "application/json"}
body = {
"template_id": TEMPLATE_ID,
"name": DEFAULT_NAME,
"description": "由 scripts/templates/template_customer_service.py 创建",
"parameters": {"temperature": 0.35},
}
cr = requests.post(f"{BASE}/api/v1/agents/from-scene-template", json=body, headers=h, timeout=60)
if cr.status_code not in (200, 201):
print("创建失败:", cr.status_code, cr.text[:800], file=sys.stderr)
return 1
print(cr.json().get("id"), cr.json().get("name"))
return 0
if __name__ == "__main__":
raise SystemExit(main())