AI接口
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
"""显式执行真实方舟联调;不输出密钥,不访问真实 MySQL/Gitea。"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
from urllib.parse import urlparse
|
||||
|
||||
root = Path(__file__).resolve().parent.parent
|
||||
environment = os.environ.copy()
|
||||
path = root / ".env"
|
||||
if path.exists():
|
||||
for line in path.read_text().splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
key, separator, raw = line.removeprefix("export ").partition("=")
|
||||
if not separator or not key.strip().isidentifier():
|
||||
continue
|
||||
values = shlex.split(raw, comments=True)
|
||||
environment.setdefault(key.strip(), values[0] if values else "")
|
||||
if not environment.get("ARK_API_KEY", "").strip():
|
||||
sys.exit("请在本机 .env 或环境变量中配置 ARK_API_KEY,不要将密钥提交到 Git。")
|
||||
endpoint = environment.get("ARK_ENDPOINT", "https://ark.cn-beijing.volces.com/api/v3/responses")
|
||||
if urlparse(endpoint).scheme != "https" or urlparse(endpoint).hostname != "ark.cn-beijing.volces.com":
|
||||
sys.exit("真实联调脚本仅允许北京区域官方方舟 HTTPS 地址,请核对 ARK_ENDPOINT。")
|
||||
environment["COMMUNITY_ARK_LIVE_TEST"] = "true"
|
||||
environment["AI_ENABLED"] = "true"
|
||||
sys.exit(subprocess.run([
|
||||
"mvn", "-q", "-pl", "community-api", "-am", "test",
|
||||
"-Dtest=AiSearchLiveTest", "-Dsurefire.failIfNoSpecifiedTests=false",
|
||||
], cwd=root, env=environment).returncode)
|
||||
Reference in New Issue
Block a user