aiditApi.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. """
  2. @author: luojunhui
  3. """
  4. import requests
  5. import json
  6. class AIDTApi(object):
  7. """
  8. 自动操作
  9. """
  10. headers = {
  11. 'Accept': 'application/json',
  12. 'Accept-Language': 'zh,zh-CN;q=0.9',
  13. 'Content-Type': 'application/json',
  14. 'Origin': 'http://admin.cybertogether.net',
  15. 'Proxy-Connection': 'keep-alive',
  16. 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
  17. }
  18. person_info = {
  19. "token": "af54cdc404c3464d896745df389b2dce",
  20. "appType": 9,
  21. "platform": "pc",
  22. "appVersionCode": 1000,
  23. "clientTimestamp": 1,
  24. "fid": 1,
  25. "loginUid": 1,
  26. "pageSource": 1,
  27. "requestId": 1,
  28. "rid": 1,
  29. "uid": 1
  30. }
  31. @classmethod
  32. def getPlanArticleList(cls, page_index, plan_id):
  33. """
  34. 获取抓取计划下的文章list
  35. :param plan_id:
  36. :param page_index:
  37. :return:
  38. """
  39. url = "http://aigc-api.cybertogether.net/aigc/crawler/content/list"
  40. payload = json.dumps({
  41. "params": {
  42. "filterItems": [
  43. {
  44. "itemName": "sourceCrawlerPlans",
  45. "selectValues": [plan_id]
  46. }
  47. ],
  48. "listFieldFormula": [],
  49. "pageNum": page_index,
  50. "pageSize": 50,
  51. "contentModal": 3
  52. },
  53. "baseInfo": cls.person_info
  54. })
  55. response = requests.request("POST", url, headers=cls.headers, data=payload)
  56. return response.json()
  57. @classmethod
  58. def updateArticleIntoCrawlerPlan(cls, plan_id, plan_name, plan_tag, url_list):
  59. """
  60. 往抓取计划加文章
  61. :return:
  62. """
  63. url = "http://aigc-api.cybertogether.net/aigc/crawler/plan/save"
  64. payload = json.dumps({
  65. "params": {
  66. "contentFilters": [],
  67. "accountFilters": [],
  68. "filterAccountMatchMode": 1,
  69. "filterContentMatchMode": 1,
  70. "selectModeValues": [],
  71. "searchModeValues": [],
  72. "contentModal": 3,
  73. "analyze": {},
  74. "crawlerComment": 0,
  75. "inputGroup": None,
  76. "inputSourceGroups": [],
  77. "modePublishTime": [],
  78. "planType": 2,
  79. "frequencyType": 2,
  80. "planTag": plan_tag,
  81. "tagPenetrateFlag": 0,
  82. "id": plan_id,
  83. "name": plan_name,
  84. "channel": 5,
  85. "crawlerMode": 5,
  86. "inputModeValues": url_list,
  87. "modePublishTimeStart": None,
  88. "modePublishTimeEnd": None,
  89. "executeRate": None,
  90. "executeDate": None,
  91. "executeWindowStart": None,
  92. "executeWindowEnd": None,
  93. "executeTimeInterval": None,
  94. "executeNum": None,
  95. "addModal": None,
  96. "addChannel": None,
  97. "fileUpload": None,
  98. "prompt": None,
  99. "acelFlag": None,
  100. "tasks": []
  101. },
  102. "baseInfo": cls.person_info
  103. })
  104. response = requests.request("POST", url, headers=cls.headers, data=payload)
  105. print(json.dumps(response.json(), ensure_ascii=False, indent=4))
  106. @classmethod
  107. def bindCrawlerPlanToGeneratePlan(cls):
  108. """
  109. 绑定抓取计划到生成计划
  110. :return:
  111. """
  112. url = "http://aigc-api.cybertogether.net/aigc/produce/plan/save"
  113. payload = json.dumps({
  114. "params": {
  115. "name": "flowPool4Test",
  116. "produceModal": 3,
  117. "planTag": "autoArticlePoolLevel4",
  118. "tagPenetrateFlag": 0,
  119. "moduleGroups": [
  120. {
  121. "modules": [
  122. {
  123. "produceModuleType": 1,
  124. "conditionOutputConfigs": [
  125. {
  126. "outputConfigs": [
  127. "task-ad66503e0cfb1dd18df9b8697156ed01-every-topAll"
  128. ]
  129. }
  130. ]
  131. },
  132. {
  133. "produceModuleType": 2,
  134. "conditionOutputConfigs": [
  135. {
  136. "outputConfigs": [
  137. "task-bad7562d16c070ba488b9a64bdf8af67-every-topAll"
  138. ]
  139. }
  140. ]
  141. },
  142. {
  143. "produceModuleType": 3,
  144. "conditionOutputConfigs": [
  145. {
  146. "outputConfigs": [
  147. "content|0|inputAll-标题-every-topAll"
  148. ]
  149. }
  150. ]
  151. },
  152. {
  153. "produceModuleType": 4,
  154. "conditionOutputConfigs": [
  155. {
  156. "outputConfigs": [
  157. "task-28403a18b08241c2a07ed4122f045163-all-topAll"
  158. ]
  159. }
  160. ]
  161. },
  162. {
  163. "produceModuleType": 10,
  164. "conditionOutputConfigs": [
  165. {
  166. "outputConfigs": [
  167. "content|0|inputAll-miniProgram-all"
  168. ]
  169. }
  170. ]
  171. }
  172. ]
  173. }
  174. ],
  175. "activeManualReview": 1,
  176. "dailyProduceNum": 200,
  177. "totalProduceNum": 10000,
  178. "inputSourceGroups": [
  179. {
  180. "groupId": "0",
  181. "contentFilters": [],
  182. "contentOrders": [
  183. {
  184. "orderField": 4,
  185. "orderType": "desc"
  186. },
  187. {
  188. "orderField": 2,
  189. "orderType": "desc"
  190. }
  191. ],
  192. "filterMatchMode": 2,
  193. "inputType": None,
  194. "perInputCount": 1,
  195. "inputMaxUseCount": 1,
  196. "samplingType": 2,
  197. "groupName": "分组0",
  198. "inputSources": [
  199. {
  200. "contentType": 1,
  201. "inputSourceModal": 3,
  202. "inputSourceChannel": 5,
  203. "inputSourceType": 2,
  204. "inputSourceValue": "20240724082230892806488",
  205. "inputSourceSubType": None,
  206. "fieldName": None,
  207. "inputSourceLabel": "原始帖子-长文-微信公众号-内容添加计划-冷启池子--军事政法"
  208. }
  209. ],
  210. "batchActive": 1
  211. }
  212. ],
  213. "tasks": [
  214. {
  215. "taskFunctionId": None,
  216. "taskFunctionTaskId": None,
  217. "taskFunctionUseType": 0,
  218. "taskId": "85028b8433d186b95ecfcf8cfe12e20e",
  219. "modelName": "GPT-4",
  220. "auditProcessIndex": None,
  221. "name": "理解 事实信息和观点",
  222. "inputConfigs": [
  223. "content|0|input1-正文-all-topAll"
  224. ],
  225. "inputFilterMatchMode": None,
  226. "inputReviewOpen": 0,
  227. "model": "GPT-4",
  228. "modelParam": None,
  229. "prompt": "【 {content|0|input1-正文-all-topAll} 】\n请总结其中所有事实型信息,并分拆其中所有观点",
  230. "auditProcessOpen": 0,
  231. "modelOperation": 1,
  232. "modelOperationName": "生文",
  233. "exeType": 1,
  234. "outputType": 1,
  235. "ext": None
  236. },
  237. {
  238. "taskFunctionId": None,
  239. "taskFunctionTaskId": None,
  240. "taskFunctionUseType": 0,
  241. "taskId": "713bc86019b724007f2d81da182ba29d",
  242. "modelName": "GPT-4",
  243. "auditProcessIndex": None,
  244. "name": "理解 文章核心事件",
  245. "inputConfigs": [
  246. "content|0|input1-正文-all-topAll",
  247. "content|0|input1-标题-all-topAll"
  248. ],
  249. "inputFilterMatchMode": None,
  250. "inputReviewOpen": 0,
  251. "model": "GPT-4",
  252. "modelParam": None,
  253. "prompt": "结合标题和正文,请你找出文章中围绕标题的事件信息,描述清楚发生了什么。\n1、标题:【 {content|0|input1-标题-all-topAll} 】\n2、正文:【 {content|0|input1-正文-all-topAll} 】",
  254. "auditProcessOpen": 0,
  255. "modelOperation": 1,
  256. "modelOperationName": "生文",
  257. "exeType": 1,
  258. "outputType": 1,
  259. "ext": None
  260. },
  261. {
  262. "taskFunctionId": None,
  263. "taskFunctionTaskId": None,
  264. "taskFunctionUseType": 0,
  265. "taskId": "28bd9d91314c1f913f27bce1360070a6",
  266. "modelName": "GPT-4",
  267. "auditProcessIndex": None,
  268. "name": "联想 人们还想知道的",
  269. "inputConfigs": [
  270. "task-713bc86019b724007f2d81da182ba29d-all-topAll"
  271. ],
  272. "inputFilterMatchMode": None,
  273. "inputReviewOpen": 0,
  274. "model": "GPT-4",
  275. "modelParam": None,
  276. "prompt": "【 {task-713bc86019b724007f2d81da182ba29d-all-topAll} 】这是一篇文章的中心思想,围绕它的事实主旨的部分,读者可能还想了解哪些信息?",
  277. "auditProcessOpen": 0,
  278. "modelOperation": 1,
  279. "modelOperationName": "生文",
  280. "exeType": 1,
  281. "outputType": 1,
  282. "ext": None
  283. },
  284. {
  285. "taskFunctionId": None,
  286. "taskFunctionTaskId": None,
  287. "taskFunctionUseType": 0,
  288. "taskId": "e7ad826428c4d432f048c935de74c118",
  289. "modelName": "GPT-4",
  290. "auditProcessIndex": None,
  291. "name": "处理 对联想信息筛选",
  292. "inputConfigs": [
  293. "task-28bd9d91314c1f913f27bce1360070a6-all-topAll",
  294. "content|0|input1-正文-all-topAll"
  295. ],
  296. "inputFilterMatchMode": None,
  297. "inputReviewOpen": 0,
  298. "model": "GPT-4",
  299. "modelParam": None,
  300. "prompt": "1、原文:【 {content|0|input1-正文-all-topAll} 】\n2、问题:【 {task-28bd9d91314c1f913f27bce1360070a6-all-topAll} 】\n请你基于原文内容,从问题中选择两到三点,这两点是你认为跟原文事件最为相关且人们最可能想知道的,由此产生三个问题。直接输出两个问题,不要其他解释",
  301. "auditProcessOpen": 0,
  302. "modelOperation": 1,
  303. "modelOperationName": "生文",
  304. "exeType": 1,
  305. "outputType": 1,
  306. "ext": None
  307. },
  308. {
  309. "taskFunctionId": None,
  310. "taskFunctionTaskId": None,
  311. "taskFunctionUseType": 0,
  312. "taskId": "dd9fda9d1c56d01e5b3a38a4be59ec92",
  313. "modelName": "Bing",
  314. "auditProcessIndex": None,
  315. "name": "bing搜索回答",
  316. "inputConfigs": [
  317. "task-e7ad826428c4d432f048c935de74c118-all-topAll"
  318. ],
  319. "inputFilterMatchMode": None,
  320. "inputReviewOpen": 0,
  321. "model": "Bing",
  322. "prompt": "【 {task-e7ad826428c4d432f048c935de74c118-all-topAll} 】请你根据以上内容展开搜索回答,对问题分别回答,给我具体的事实型信息。",
  323. "auditProcessOpen": 0,
  324. "modelOperation": 1,
  325. "modelOperationName": "生文",
  326. "exeType": 1,
  327. "outputType": 1,
  328. "ext": None
  329. },
  330. {
  331. "taskFunctionId": None,
  332. "taskFunctionTaskId": None,
  333. "taskFunctionUseType": 0,
  334. "taskId": "c37b0763bbbe824bda42726915520aa4",
  335. "modelName": "GPT-4",
  336. "auditProcessIndex": None,
  337. "name": "理解 原文结构",
  338. "inputConfigs": [
  339. "content|0|input1-正文-all-topAll"
  340. ],
  341. "inputFilterMatchMode": None,
  342. "inputReviewOpen": 0,
  343. "model": "GPT-4",
  344. "modelParam": None,
  345. "prompt": "请你分析文章的大结构,比如事件引入等。正文:【 {content|0|input1-正文-all-topAll} 】",
  346. "auditProcessOpen": 0,
  347. "modelOperation": 1,
  348. "modelOperationName": "生文",
  349. "exeType": 1,
  350. "outputType": 1,
  351. "ext": None
  352. },
  353. {
  354. "taskFunctionId": None,
  355. "taskFunctionTaskId": None,
  356. "taskFunctionUseType": 0,
  357. "taskId": "28403a18b08241c2a07ed4122f045163",
  358. "modelName": "GPT-4",
  359. "auditProcessIndex": None,
  360. "name": "成文",
  361. "inputConfigs": [
  362. "task-713bc86019b724007f2d81da182ba29d-all-topAll",
  363. "task-85028b8433d186b95ecfcf8cfe12e20e-all-topAll",
  364. "task-dd9fda9d1c56d01e5b3a38a4be59ec92-all-topAll",
  365. "task-c37b0763bbbe824bda42726915520aa4-all-topAll",
  366. "content|0|input1-标题-all-topAll"
  367. ],
  368. "inputFilterMatchMode": None,
  369. "inputReviewOpen": 0,
  370. "model": "GPT-4",
  371. "modelParam": None,
  372. "prompt": "标题如下:\n\"\"\"\n{content|0|input1-标题-all-topAll}\n\"\"\"\n核心事件如下:\n\"\"\"\n{task-713bc86019b724007f2d81da182ba29d-all-topAll}\n\"\"\"\n事实信息如下:\n\"\"\"\n{task-85028b8433d186b95ecfcf8cfe12e20e-all-topAll}\n\"\"\"\n可补充信息如下:\n\"\"\"\n{task-dd9fda9d1c56d01e5b3a38a4be59ec92-all-topAll}\n\"\"\"\n参考原文结构如下:\n\"\"\"\n{task-c37b0763bbbe824bda42726915520aa4-all-topAll}\n\"\"\"\n任务:请根据以上内容,在符合基础事实的情况下,生成一篇1300字左右文章。\n要求如下:\n\"\"\"\n- 直接输出文章,不需要解释。\n- 事件部分达到文章35%,可以适当加上对事件的评论。\n- 参考文章的大结构来做全文结构。\n- 表达应当客观准确,简明扼要,不需要小标题。\n\"\"",
  373. "auditProcessOpen": 0,
  374. "modelOperation": 1,
  375. "modelOperationName": "生文",
  376. "exeType": 1,
  377. "outputType": 1,
  378. "ext": None
  379. },
  380. {
  381. "taskFunctionId": None,
  382. "taskFunctionTaskId": None,
  383. "taskFunctionUseType": 0,
  384. "taskId": "8966cb4c88152d3a3377ac3cc417305e",
  385. "modelName": "Kimi",
  386. "auditProcessIndex": None,
  387. "name": "titile 安全分",
  388. "inputConfigs": [
  389. "content|0|inputAll-标题-every-topAll"
  390. ],
  391. "inputFilterMatchMode": 2,
  392. "inputReviewOpen": 0,
  393. "model": "Kimi",
  394. "prompt": "请你学习一下内容规范,以下标题可能会违反了某条内容规范。请你对标题做一个内容风险评级,1-10分,等级越高内容违规风险越大。\n请直接输出内容风险评级的分数,不要输出你的理由、分析等内容。\n\n标题为: {content|0|inputAll-标题-every-topAll} \n\n\n\n内容规范为:\n\n4.2 色俗内容\n4.2.1 散布淫秽、色情内容,包括但不限于招嫖、寻找一夜情、性伴侣等。\n4.2.2 发布有色情意味的情色文字、情色视频、情色漫画等内容。\n4.2.3 以投稿/爆料等形式描述约炮经历、性交体验、偷情、涉隐私部位偷拍等伤风败俗的话题内容。\n4.2.4 以低俗的配图引诱用户阅读文章、关注微信公众号。包含性撩拨、性挑逗画面;疑似女性性高潮/性虐场面;偷拍的沐浴/更衣/如厕/亲热等私密画面;女性故意露出敏感部位 (纯裸露的胸、生殖器官)以及敏感部位未打码的真人写真/艺术摄影等。\n4.2.5 文内以低俗类的动图或引导图,诱导用户点击进而跳转至另一篇图文页或关注某个公众号。\n4.2.6 文章主要描述PUA撩妹、撩汉等相关话题,且引导用户关注公众号/加个人微信号/加群。\n\n4.11 煽动、夸大、误导类内容\n平台鼓励创作者提供准确、清晰、能体现文章内容主旨的标题,不允许通过标题噱头诱导用户点击或误导用户。包括但不限于以下情况:\n4.11.1 标题含有危害人身安全、恐吓侮辱、惊悚、极端内容,或者以命令式语气强迫用户阅读。\n4.11.2 标题无依据夸大事件严重程度、紧急程度、受影响面以及事件引发的情绪。\n4.11.3 标题以浮夸的描述,反常识强调某种食物/行为对人体健康的影响,煽动人群要/不要去做某行为。\n4.11.4 非官方通知或者公告,但标题假借官方名义煽动获取流量,或以信息来源机密、看完即删来诱导用户。\n4.11.5 标题故意隐藏关键信息,或无中生有部分信息,给用户造成误导。\n\n4.12 违反国家法律法规禁止的内容\n(1)违反宪法确定的基本原则的;\n(2)危害国家安全,泄露国家秘密,颠覆国家政权,破坏国家统一的;\n(3)损害国家荣誉和利益的;\n(4)煽动民族仇恨、民族歧视,破坏民族团结的;\n(5)破坏国家宗教政策,宣扬邪教和封建迷信的;\n(6)散布不实信息,扰乱社会秩序,破坏社会稳定的;\n(7)散布淫秽、色情、赌博、暴力、恐怖或者教唆犯罪的;\n(8)侮辱或者诽谤他人,侵害他人合法权益的;\n(9)煽动非法集会、结社、游行、示威、聚众扰乱社会秩序;\n(10)以非法民间组织名义活动的;\n(11)不符合《即时通信工具公众信息服务发展管理暂行规定》及遵守法律法规、社会主义制度、国家利益、公民合法利益、公共秩序、社会道德风尚和信息真实性等“七条底线”要求的;\n(12)含有法律、行政法规禁止的其他内容的。",
  395. "auditProcessOpen": 0,
  396. "modelOperation": 1,
  397. "modelOperationName": "生文",
  398. "exeType": 1,
  399. "outputType": 1,
  400. "ext": None
  401. },
  402. {
  403. "taskFunctionId": None,
  404. "taskFunctionTaskId": None,
  405. "taskFunctionUseType": 0,
  406. "taskId": "ad66503e0cfb1dd18df9b8697156ed01",
  407. "modelName": "去除图片水印",
  408. "auditProcessIndex": None,
  409. "name": "封面去水印",
  410. "inputConfigs": [
  411. "content|0|inputAll-封面图-every-topAll"
  412. ],
  413. "inputFilterMatchMode": 2,
  414. "inputReviewOpen": 0,
  415. "model": "remove_logo",
  416. "auditProcessOpen": 0,
  417. "modelOperation": 509,
  418. "modelOperationName": "公众号",
  419. "exeType": 2,
  420. "outputType": 3,
  421. "ext": None
  422. },
  423. {
  424. "taskFunctionId": None,
  425. "taskFunctionTaskId": None,
  426. "taskFunctionUseType": 0,
  427. "taskId": "bad7562d16c070ba488b9a64bdf8af67",
  428. "modelName": "去除图片水印",
  429. "auditProcessIndex": None,
  430. "name": "图片去水印",
  431. "inputConfigs": [
  432. "content|0|inputAll-图集-every-topAll"
  433. ],
  434. "inputFilterMatchMode": 2,
  435. "inputReviewOpen": 0,
  436. "model": "remove_logo",
  437. "auditProcessOpen": 0,
  438. "modelOperation": 509,
  439. "modelOperationName": "公众号",
  440. "exeType": 2,
  441. "outputType": 3,
  442. "ext": None
  443. },
  444. {
  445. "taskType": 4,
  446. "taskId": "94646f3a12be411d31dd4f8a671126d6",
  447. "exeType": 2,
  448. "open": True,
  449. "ext": "{\"wordCountRule\":\"wx_gzh\",\"operator\":\"大于\",\"limit\":\"1000\"}",
  450. "model": "GPT-4",
  451. "prompt": "扩写成为1300字左右文章,在符合事实和原有故事情节的基础上,按自然段落形式展开,有清晰的结构。不要出现字数或总结的说明,请直接输出文章\n\n正文为:{正文}",
  452. "retryMaxCount": 3
  453. }
  454. ],
  455. "layoutType": 1,
  456. "activeManualReviewCount": 1,
  457. "id": "20240723085507877294360"
  458. },
  459. "baseInfo": cls.person_info
  460. })
  461. response = requests.request("POST", url, headers=cls.headers, data=payload)
  462. print(response.text)
  463. @classmethod
  464. def getProducePlanDetail(cls, plan_id):
  465. """
  466. 通过生成计划id,获取生成计划详情
  467. :param plan_id:
  468. :return:
  469. """
  470. url = "http://aigc-api.cybertogether.net/aigc/produce/plan/detail"
  471. payload = {
  472. "params": {
  473. "id": plan_id
  474. },
  475. "baseInfo": cls.person_info
  476. }
  477. response = requests.request(
  478. "POST",
  479. url,
  480. headers=cls.headers,
  481. data=json.dumps(payload)
  482. )
  483. return response.json()