代码提交
This commit is contained in:
1 parent
5e953c9fcb
commit
bf42a48fcc
16 files changed
+716
-1560
No files matched your search
-1
@@ -176,7 +176,6 @@ class AgentScopeMemberKernel:
|
||||
model_snapshot,
|
||||
app_config=self._app_config,
|
||||
node_run_id=assignment.node_run_id,
|
||||
budget_guard=budget,
|
||||
)
|
||||
)
|
||||
permission = context.get("permission")
|
||||
|
||||
@@ -723,8 +723,8 @@ workflows:
|
||||
|
||||
# AgentScope 多智能体报告协作工作台(默认关闭;不改变现有会商 / Workflow Studio)
|
||||
report_collaboration:
|
||||
enabled: false
|
||||
worker_enabled: false
|
||||
enabled: true
|
||||
worker_enabled: true
|
||||
planner_model: null
|
||||
coordinator_model: null
|
||||
research_model: null
|
||||
|
||||
@@ -39,7 +39,7 @@ allowed-tools:
|
||||
```
|
||||
|
||||
- `taskId` / `actionId` 必须是整数,等于当前任务与行动 ID。
|
||||
- `userList` 每项是完整 user 对象:`id`、`name` 必填;`platformType` 写入 accountPlat;`accountSource` 优先取 `dataSource`,缺失时回退 `score`;整个对象 JSON 序列化后存入 `frofileInfo`。
|
||||
- `userList` 每项是完整 user 对象:`id`、`name` 必填;`platformType` 写入 accountPlat——缺失时可只给 `platform` 平台名(如 `facebook`、`instagram`),脚本登录后自动查平台字典表(sys-dict-data,dictType=platform)按前端 platformTypeChange 同款规则映射为编码(未识别回退 1,两者都缺则置空);`accountSource` 优先取 `dataSource`,缺失时回退 `score`;整个对象 JSON 序列化后存入 `frofileInfo`。
|
||||
- `recReason` 中的 `<n>` 引用标记会被自动清洗,无需预处理。
|
||||
|
||||
完整字段定义、账号对象字段表与生成规则,见:
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
"endpoints": {
|
||||
"login": "/api/auth/login",
|
||||
"platform_dict": "/api/sys/sys-dict-data",
|
||||
"design_list": "/api/task/task-action-design",
|
||||
"design_create": "/api/task/task-action-design",
|
||||
"design_delete": "/api/task/task-action-design",
|
||||
|
||||
+67
-1
@@ -86,6 +86,48 @@ def clean_reason(text) -> str:
|
||||
return text.replace("、", "").replace("引用", "").replace("()", "")
|
||||
|
||||
|
||||
def platform_type_change(platform, options):
|
||||
"""
|
||||
平台名/别名 → 平台字典编码(写入 task-action-design-account.accountPlat)。
|
||||
移植自前端 chat-data.utils.platformTypeChange:子串匹配 fb / x|witter / in / re / th → 字典 label
|
||||
命中取 value;否则 label 全量小写精确匹配;仍匹配不到回退 1(facebook,与前端一致)。
|
||||
options 形如 [{"label": "facebook", "value": 1}, ...],来自 sys-dict-data 的 platform 字典。
|
||||
技能侧扩展:入参已是编码(int 或纯数字字符串)时原样透传;完全缺失(None/空)返回 None(不臆造)。
|
||||
"""
|
||||
if platform is None or (isinstance(platform, str) and not platform.strip()):
|
||||
return None
|
||||
if isinstance(platform, bool):
|
||||
return None
|
||||
if isinstance(platform, int):
|
||||
return platform
|
||||
if isinstance(platform, str) and platform.strip().isdigit():
|
||||
return int(platform.strip())
|
||||
|
||||
low = str(platform).strip().lower()
|
||||
|
||||
def val(*labels):
|
||||
for lab in labels:
|
||||
for o in options:
|
||||
if str(o.get("label", "")).strip().lower() == lab and o.get("value") is not None:
|
||||
return o.get("value")
|
||||
return None
|
||||
|
||||
if "fb" in low:
|
||||
return val("facebook") or 1
|
||||
if "x" in low or "witter" in low:
|
||||
return val("x(twitter)", "x") or 1
|
||||
if "in" in low:
|
||||
return val("instagram") or 1
|
||||
if "re" in low:
|
||||
return val("reddit") or 1
|
||||
if "th" in low:
|
||||
return val("threads") or 1
|
||||
for o in options:
|
||||
if str(o.get("label", "")).strip().lower() == low and o.get("value") is not None:
|
||||
return o.get("value")
|
||||
return 1
|
||||
|
||||
|
||||
class ApiClient:
|
||||
def __init__(self, cfg: dict, dry_run: bool = False):
|
||||
self.base = cfg["base_url"].rstrip("/")
|
||||
@@ -239,6 +281,24 @@ def main():
|
||||
client.token = token
|
||||
result["登录"] = f"成功(已获取 {cfg['auth']['token_field']},后续请求头 {cfg['auth']['header_name']}: {cfg['auth']['header_template']})"
|
||||
|
||||
# ---- 1.5 平台字典(platform 名称/别名 → 字典编码,写入 accountPlat 前映射;与前端 platformTypeChange 同款) ----
|
||||
platform_options = []
|
||||
dict_status, dict_resp = client.request("查询平台字典", "GET", ep(cfg, "platform_dict"),
|
||||
query={"filter": ["dictType||$eq||platform"], "limit": 99999})
|
||||
dict_rows = (dict_resp or {}).get("data") or [] if isinstance(dict_resp, dict) else []
|
||||
if dict_status == 200:
|
||||
platform_options = [
|
||||
{"label": r.get("dictLabel"), "value": int(str(r["dictValue"]).strip())}
|
||||
for r in dict_rows
|
||||
if r.get("dictValue") is not None and str(r.get("dictValue")).strip().lstrip("-").isdigit()
|
||||
]
|
||||
result["平台字典"] = (
|
||||
f"已加载 {len(platform_options)} 项:"
|
||||
+ "、".join(f"{o['label']}={o['value']}" for o in platform_options)
|
||||
)
|
||||
else:
|
||||
result["平台字典"] = f"查询失败(HTTP {dict_status}),平台名只能按子串规则映射且未命中回退 1,建议检查字典表"
|
||||
|
||||
# ---- 2. 查询已有受众(查重) ----
|
||||
q = {"filter": [f"taskId||$eq||{task_id}", f"actionId||$eq||{action_id}"], "limit": 99999}
|
||||
status, designs_resp = client.request("查询已有受众", "GET", ep(cfg, "design_list"), query=q)
|
||||
@@ -298,11 +358,17 @@ def main():
|
||||
# ---- 5. 创建账号关联 ----
|
||||
for user in g.get("userList") or []:
|
||||
account_source = user.get("dataSource") if user.get("dataSource") is not None else user.get("score")
|
||||
# 平台编码:user.platformType(编码)缺失时回退 user.platform(名称),统一经平台字典映射为编码
|
||||
raw_platform = user.get("platformType") if user.get("platformType") is not None else user.get("platform")
|
||||
account_plat = platform_type_change(raw_platform, platform_options)
|
||||
group.setdefault("账号平台映射", []).append(
|
||||
{"accountName": user.get("name"), "原始值": raw_platform, "accountPlat": account_plat}
|
||||
)
|
||||
account_body = {
|
||||
"taskId": task_id, "actionId": action_id,
|
||||
"accountId": user.get("id"),
|
||||
"accountName": user.get("name"),
|
||||
"accountPlat": user.get("platformType"),
|
||||
"accountPlat": account_plat,
|
||||
"accountSource": account_source,
|
||||
"frofileInfo": json.dumps(user, ensure_ascii=False),
|
||||
"designId": design_id,
|
||||
|
||||
Reference in new issue
Block a user