postprocess0113.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. import time
  2. from fallback import fallback
  3. from config import simplemodel
  4. from template import xuanxiang
  5. import json
  6. with open('zhaoping_rule', 'r') as f:
  7. content = f.read()
  8. import json
  9. obj=json.loads(content)
  10. with open('name_label', 'r') as f:
  11. content = f.read()
  12. import json
  13. name_label=json.loads(content)
  14. baohuceng = ['10-74', '10-75', '10-77', '10-78', '10-80', '10-81', '10-83', '10-84', '10-86', '10-87', '10-90']
  15. from fallback import fallback
  16. def aifilter5(A, #options
  17. B, #data
  18. aiclient,
  19. qwclient,
  20. sfclient,
  21. dw):
  22. options=[]
  23. letters = "ABCDEFGHIJKLMN"
  24. for i in range(len(A)):
  25. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  26. completion = aiclient.chat.completions.create(
  27. #model="THUDM/GLM-4-9B-0414",
  28. model="glm-4.5-air",
  29. #model="Qwen/Qwen3-8B",
  30. #model="ernie-speed-128k",
  31. messages=[
  32. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  33. {"role": "user", "content": "问题描述: " ",".join(options) + "。请问选项中是否有龙骨选项?" + '''
  34. 如果有,请回答
  35. {
  36. 'answer': '有'
  37. }
  38. 如果没有,请回答
  39. {
  40. 'answer': '没有'
  41. }
  42. '''
  43. },
  44. ],
  45. extra_body={"thinking": {"type": "disabled"}},
  46. #extra_body={"enable_thinking": True},
  47. #stream=True
  48. )
  49. json_string = completion.choices[0].message.content
  50. print(json_string)
  51. if len(json_string.replace(" ", "")) < 10:
  52. if '没有' in json_string:
  53. return False
  54. return True
  55. completion = sfclient.chat.completions.create(
  56. model=simplemodel(),
  57. messages=[
  58. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  59. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一个“有”或者“没有”的判断,请将该中文判断输出" + '''
  60. 如果有,请回答
  61. {
  62. 'answer': '有'
  63. }
  64. 如果没有,请回答
  65. {
  66. 'answer': '没有'
  67. }
  68. 你只需要输出结果,不要输出分析过程
  69. '''
  70. },
  71. ],
  72. extra_body={"thinking": {"type": "disabled"}},
  73. #extra_body={"enable_thinking": False},
  74. )
  75. json_string = completion.choices[0].message.content
  76. print(json_string)
  77. if '没有' in json_string:
  78. return False
  79. return True
  80. def aifilter3(A, #options
  81. B, #data
  82. aiclient,
  83. qwclient,
  84. sfclient,
  85. dw):
  86. options=[]
  87. letters = "ABCDEFGHIJKLMN"
  88. for i in range(len(A)):
  89. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  90. completion = aiclient.chat.completions.create(
  91. #model="THUDM/GLM-4-9B-0414",
  92. model="glm-4.5-air",
  93. #model="Qwen/Qwen3-8B",
  94. #model="ernie-speed-128k",
  95. messages=[
  96. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  97. {"role": "user", "content": "问题描述: 墙面装饰工程可分为外墙装饰或者内墙装饰。给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + "。请问该工作内容的描述指的是内墙还是外墙?" + '''
  98. 如果是外墙,请回答
  99. {
  100. 'answer': '外墙'
  101. }
  102. 如果是内墙,请回答
  103. {
  104. 'answer': '内墙'
  105. }
  106. 如果无法确定,请回答
  107. {
  108. 'answer': '不确定'
  109. }
  110. '''
  111. },
  112. ],
  113. extra_body={"thinking": {"type": "disabled"}},
  114. #extra_body={"enable_thinking": True},
  115. #stream=True
  116. )
  117. json_string = completion.choices[0].message.content
  118. print(json_string)
  119. if len(json_string.replace(" ", "")) < 10:
  120. if '外墙' in json_string:
  121. return False
  122. return True
  123. completion = sfclient.chat.completions.create(
  124. model=simplemodel(),
  125. messages=[
  126. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  127. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一个“外墙”或者“内墙”的判断,请将该中文判断输出" + '''
  128. 如果是外墙,请回答
  129. {
  130. 'answer': '外墙'
  131. }
  132. 如果是内墙,请回答
  133. {
  134. 'answer': '内墙'
  135. }
  136. 如果无法确定,请回答
  137. {
  138. 'answer': '不确定'
  139. }
  140. 你只需要输出结果,不要输出分析过程
  141. '''
  142. },
  143. ],
  144. extra_body={"thinking": {"type": "disabled"}},
  145. #extra_body={"enable_thinking": False},
  146. )
  147. json_string = completion.choices[0].message.content
  148. print(json_string)
  149. if '外墙' in json_string:
  150. return False
  151. return True
  152. def aifilter1_2(A, #options
  153. B, #data
  154. aiclient,
  155. qwclient,
  156. sfclient,
  157. dw):
  158. options=[]
  159. letters = "ABCDEFGHIJKLMN"
  160. for i in range(len(A)):
  161. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  162. completion = aiclient.chat.completions.create(
  163. model="glm-4.5-air",
  164. #model="THUDM/GLM-Z1-9B-0414",
  165. #model="ernie-speed-128k",
  166. messages=[
  167. {"role": "system", "content": "You are a helpful assistant."},
  168. {"role": "user", "content": " 背景知识:混凝土楼地面是面层,跟混凝土垫层是不同的施工步骤,不得混淆"},
  169. {"role": "user", "content": " 背景知识:混凝土(砼)整体面层跟混凝土找平层是不同的施工步骤,不得混淆"},
  170. {"role": "user", "content": " 背景知识:混凝土(砼)整体面层跟混凝土垫层是不同的施工步骤,不得混淆"},
  171. {"role": "user", "content": " 背景知识:混凝土(砼)找平层跟混凝土垫层是不同的施工步骤,不得混淆"},
  172. {"role": "user", "content": " 背景知识:水泥砂浆找平层跟水泥砂浆面层是不同的施工步骤,不得混淆"},
  173. {"role": "user", "content": " 背景知识:水泥砂浆找平层跟水泥砂浆保护层是不同的施工步骤,不得混淆"},
  174. {"role": "user", "content": " 特殊处理要求:如果工作内容描述中没有明确提到素水泥浆,则去掉所有含有“素水泥浆”字样的选项"},
  175. {"role": "user", "content": " 特殊处理要求:如果工作内容描述中没有明确提到“加浆抹光”,则去掉所有含有“加浆抹光”字样的选项"},
  176. {"role": "user", "content": " 特殊处理要求:如果工作内容描述中没有明确提到混凝土垫层,则去掉所有混凝土垫层的选项"},
  177. {"role": "user", "content": " 特殊处理要求:如果选项中同时存在“冷轧带肋钢筋”选项和“抗裂基层 热镀锌钢丝网”选项,则去掉热镀锌钢丝网的选项"},
  178. {"role": "user", "content": " 重要提示:选项指的是给定的A、B、C之类的选项,不是指的工作内容中的可能的1、2、3这样罗列的特征"},
  179. {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
  180. {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果,删除选项必须对应到明确的特殊处理要求,不要擅自删除选项.例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  181. ],
  182. extra_body={"thinking": {"type": "disabled"}},
  183. #extra_body={"enable_thinking": True},
  184. #stream=True
  185. )
  186. #done_thinking = False
  187. #json_string=""
  188. #thinking_json_string=""
  189. #for chunk in completion:
  190. # thinking_chunk = chunk.choices[0].delta.reasoning_content
  191. # answer_chunk = chunk.choices[0].delta.content
  192. # if thinking_chunk != '':
  193. # thinking_json_string = thinking_json_string + thinking_chunk
  194. # elif answer_chunk != '':
  195. # if not done_thinking:
  196. # done_thinking = True
  197. # json_string = json_string + answer_chunk
  198. json_string = completion.choices[0].message.content
  199. #print(completion.choices[0].message.reasoning_content)
  200. print(json_string)
  201. if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
  202. answer=[]
  203. if 'A' in json_string and len(A) > 0:
  204. answer.append(A[0])
  205. if 'B' in json_string and len(A) > 1:
  206. answer.append(A[1])
  207. if 'C' in json_string and len(A) > 2:
  208. answer.append(A[2])
  209. if 'D' in json_string and len(A) > 3:
  210. answer.append(A[3])
  211. if 'E' in json_string and len(A) > 4:
  212. answer.append(A[4])
  213. if 'F' in json_string and len(A) > 5:
  214. answer.append(A[5])
  215. if 'G' in json_string and len(A) > 6:
  216. answer.append(A[6])
  217. if 'H' in json_string and len(A) > 7:
  218. answer.append(A[7])
  219. if 'I' in json_string and len(A) > 8:
  220. answer.append(A[8])
  221. if 'J' in json_string and len(A) > 9:
  222. answer.append(A[9])
  223. return answer
  224. completion = sfclient.chat.completions.create(
  225. model=simplemodel(),
  226. messages=xuanxiang(json_string),
  227. extra_body={"thinking": {"type": "disabled"}},
  228. #extra_body={"enable_thinking": False},
  229. )
  230. json_string = completion.choices[0].message.content
  231. print(json_string)
  232. answer=[]
  233. if 'A' in json_string and len(A) > 0:
  234. answer.append(A[0])
  235. if 'B' in json_string and len(A) > 1:
  236. answer.append(A[1])
  237. if 'C' in json_string and len(A) > 2:
  238. answer.append(A[2])
  239. if 'D' in json_string and len(A) > 3:
  240. answer.append(A[3])
  241. if 'E' in json_string and len(A) > 4:
  242. answer.append(A[4])
  243. if 'F' in json_string and len(A) > 5:
  244. answer.append(A[5])
  245. if 'G' in json_string and len(A) > 6:
  246. answer.append(A[6])
  247. if 'H' in json_string and len(A) > 7:
  248. answer.append(A[7])
  249. if 'I' in json_string and len(A) > 8:
  250. answer.append(A[8])
  251. if 'J' in json_string and len(A) > 9:
  252. answer.append(A[9])
  253. return answer
  254. def aifilter1_3(A, #options
  255. B, #data
  256. aiclient,
  257. qwclient,
  258. sfclient,
  259. dw):
  260. options=[]
  261. letters = "ABCDEFGHIJKLMN"
  262. for i in range(len(A)):
  263. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  264. completion = aiclient.chat.completions.create(
  265. model="glm-4.5-air",
  266. #model="THUDM/GLM-Z1-9B-0414",
  267. #model="ernie-speed-128k",
  268. messages=[
  269. {"role": "system", "content": "You are a helpful assistant."},
  270. {"role": "user", "content": " 背景知识:混凝土楼地面是面层,跟混凝土垫层是不同的施工步骤,不得混淆"},
  271. {"role": "user", "content": " 背景知识:混凝土(砼)整体面层跟混凝土找平层是不同的施工步骤,不得混淆"},
  272. {"role": "user", "content": " 背景知识:混凝土(砼)整体面层跟混凝土垫层是不同的施工步骤,不得混淆"},
  273. {"role": "user", "content": " 背景知识:混凝土(砼)找平层跟混凝土垫层是不同的施工步骤,不得混淆"},
  274. {"role": "user", "content": " 背景知识:水泥砂浆找平层跟水泥砂浆面层是不同的施工步骤,不得混淆"},
  275. {"role": "user", "content": " 背景知识:水泥砂浆找平层跟水泥砂浆保护层是不同的施工步骤,不得混淆"},
  276. {"role": "user", "content": " 特殊处理要求:如果工作内容描述中没有明确提到石材面刷防护剂,则去掉所有含有“石材面刷防护剂”字样的选项"},
  277. {"role": "user", "content": " 重要提示:选项指的是给定的A、B、C之类的选项,不是指的工作内容中的可能的1、2、3这样罗列的特征"},
  278. {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
  279. {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果,删除选项必须对应到明确的特殊处理要求,不要擅自删除选项.例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  280. ],
  281. extra_body={"thinking": {"type": "disabled"}},
  282. #extra_body={"enable_thinking": True},
  283. #stream=True
  284. )
  285. #done_thinking = False
  286. #json_string=""
  287. #thinking_json_string=""
  288. #for chunk in completion:
  289. # thinking_chunk = chunk.choices[0].delta.reasoning_content
  290. # answer_chunk = chunk.choices[0].delta.content
  291. # if thinking_chunk != '':
  292. # thinking_json_string = thinking_json_string + thinking_chunk
  293. # elif answer_chunk != '':
  294. # if not done_thinking:
  295. # done_thinking = True
  296. # json_string = json_string + answer_chunk
  297. json_string = completion.choices[0].message.content
  298. #print(completion.choices[0].message.reasoning_content)
  299. print(json_string)
  300. if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
  301. answer=[]
  302. if 'A' in json_string and len(A) > 0:
  303. answer.append(A[0])
  304. if 'B' in json_string and len(A) > 1:
  305. answer.append(A[1])
  306. if 'C' in json_string and len(A) > 2:
  307. answer.append(A[2])
  308. if 'D' in json_string and len(A) > 3:
  309. answer.append(A[3])
  310. if 'E' in json_string and len(A) > 4:
  311. answer.append(A[4])
  312. if 'F' in json_string and len(A) > 5:
  313. answer.append(A[5])
  314. if 'G' in json_string and len(A) > 6:
  315. answer.append(A[6])
  316. if 'H' in json_string and len(A) > 7:
  317. answer.append(A[7])
  318. if 'I' in json_string and len(A) > 8:
  319. answer.append(A[8])
  320. if 'J' in json_string and len(A) > 9:
  321. answer.append(A[9])
  322. return answer
  323. completion = sfclient.chat.completions.create(
  324. model=simplemodel(),
  325. messages=xuanxiang(json_string),
  326. extra_body={"thinking": {"type": "disabled"}},
  327. #extra_body={"enable_thinking": False},
  328. )
  329. json_string = completion.choices[0].message.content
  330. print(json_string)
  331. answer=[]
  332. if 'A' in json_string and len(A) > 0:
  333. answer.append(A[0])
  334. if 'B' in json_string and len(A) > 1:
  335. answer.append(A[1])
  336. if 'C' in json_string and len(A) > 2:
  337. answer.append(A[2])
  338. if 'D' in json_string and len(A) > 3:
  339. answer.append(A[3])
  340. if 'E' in json_string and len(A) > 4:
  341. answer.append(A[4])
  342. if 'F' in json_string and len(A) > 5:
  343. answer.append(A[5])
  344. if 'G' in json_string and len(A) > 6:
  345. answer.append(A[6])
  346. if 'H' in json_string and len(A) > 7:
  347. answer.append(A[7])
  348. if 'I' in json_string and len(A) > 8:
  349. answer.append(A[8])
  350. if 'J' in json_string and len(A) > 9:
  351. answer.append(A[9])
  352. return answer
  353. def aifilter4(A, #options
  354. B, #data
  355. aiclient,
  356. qwclient,
  357. sfclient,
  358. dw):
  359. options=[]
  360. letters = "ABCDEFGHIJKLMN"
  361. for i in range(len(A)):
  362. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  363. completion = aiclient.chat.completions.create(
  364. model="glm-4.5-air",
  365. #model="THUDM/GLM-Z1-9B-0414",
  366. #model="ernie-speed-128k",
  367. messages=[
  368. {"role": "system", "content": "You are a helpful assistant."},
  369. {"role": "user", "content": " 特殊处理要求:如果工作内容没有提及界面剂,则去掉所有含有“界面剂”字样的选项"},
  370. {"role": "user", "content": " 重要提示:选项指的是给定的A、B、C之类的选项,不是指的工作内容中的可能的1、2、3这样罗列的特征"},
  371. {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
  372. {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果, 删除选项必须对应到明确的特殊处理要求,不要擅自删除选项。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  373. ],
  374. extra_body={"thinking": {"type": "disabled"}},
  375. #extra_body={"enable_thinking": True},
  376. #stream=True
  377. )
  378. #done_thinking = False
  379. #json_string=""
  380. #thinking_json_string=""
  381. #for chunk in completion:
  382. # thinking_chunk = chunk.choices[0].delta.reasoning_content
  383. # answer_chunk = chunk.choices[0].delta.content
  384. # if thinking_chunk != '':
  385. # thinking_json_string = thinking_json_string + thinking_chunk
  386. # elif answer_chunk != '':
  387. # if not done_thinking:
  388. # done_thinking = True
  389. # json_string = json_string + answer_chunk
  390. json_string = completion.choices[0].message.content
  391. #print(completion.choices[0].message.reasoning_content)
  392. print(json_string)
  393. if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
  394. answer=[]
  395. if 'A' in json_string and len(A) > 0:
  396. answer.append(A[0])
  397. if 'B' in json_string and len(A) > 1:
  398. answer.append(A[1])
  399. if 'C' in json_string and len(A) > 2:
  400. answer.append(A[2])
  401. if 'D' in json_string and len(A) > 3:
  402. answer.append(A[3])
  403. if 'E' in json_string and len(A) > 4:
  404. answer.append(A[4])
  405. if 'F' in json_string and len(A) > 5:
  406. answer.append(A[5])
  407. if 'G' in json_string and len(A) > 6:
  408. answer.append(A[6])
  409. if 'H' in json_string and len(A) > 7:
  410. answer.append(A[7])
  411. if 'I' in json_string and len(A) > 8:
  412. answer.append(A[8])
  413. if 'J' in json_string and len(A) > 9:
  414. answer.append(A[9])
  415. return answer
  416. completion = sfclient.chat.completions.create(
  417. #model="glm-4.5-flash",
  418. model=simplemodel(),
  419. messages=xuanxiang(json_string),
  420. extra_body={"thinking": {"type": "disabled"}},
  421. #extra_body={"enable_thinking": False},
  422. )
  423. json_string = completion.choices[0].message.content
  424. print(json_string)
  425. answer=[]
  426. if 'A' in json_string and len(A) > 0:
  427. answer.append(A[0])
  428. if 'B' in json_string and len(A) > 1:
  429. answer.append(A[1])
  430. if 'C' in json_string and len(A) > 2:
  431. answer.append(A[2])
  432. if 'D' in json_string and len(A) > 3:
  433. answer.append(A[3])
  434. if 'E' in json_string and len(A) > 4:
  435. answer.append(A[4])
  436. if 'F' in json_string and len(A) > 5:
  437. answer.append(A[5])
  438. if 'G' in json_string and len(A) > 6:
  439. answer.append(A[6])
  440. if 'H' in json_string and len(A) > 7:
  441. answer.append(A[7])
  442. if 'I' in json_string and len(A) > 8:
  443. answer.append(A[8])
  444. if 'J' in json_string and len(A) > 9:
  445. answer.append(A[9])
  446. return answer
  447. def aifilter1(A, #options
  448. B, #data
  449. aiclient,
  450. qwclient,
  451. sfclient,
  452. dw):
  453. options=[]
  454. letters = "ABCDEFGHIJKLMN"
  455. for i in range(len(A)):
  456. options.append("给定选项" + letters[i]+",内容为"+A[i] )
  457. completion = aiclient.chat.completions.create(
  458. model="glm-4.5-air",
  459. #model="THUDM/GLM-Z1-9B-0414",
  460. #model="ernie-speed-128k",
  461. messages=[
  462. {"role": "system", "content": "You are a helpful assistant."},
  463. {"role": "user", "content": " 特殊处理要求一:去掉所有精确含有“刷(喷)浆”字样的选项"},
  464. {"role": "user", "content": " 特殊处理要求二:去掉所有刷素水泥浆的选项"},
  465. {"role": "user", "content": " 重要提示:选项指的是给定的A、B、C之类的选项,不是指的工作内容中的可能的1、2、3这样罗列的特征"},
  466. {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
  467. {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果, 删除选项必须对应到明确的特殊处理要求,不要擅自删除选项。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  468. ],
  469. extra_body={"thinking": {"type": "disabled"}},
  470. #extra_body={"enable_thinking": True},
  471. #stream=True
  472. )
  473. #done_thinking = False
  474. #json_string=""
  475. #thinking_json_string=""
  476. #for chunk in completion:
  477. # thinking_chunk = chunk.choices[0].delta.reasoning_content
  478. # answer_chunk = chunk.choices[0].delta.content
  479. # if thinking_chunk != '':
  480. # thinking_json_string = thinking_json_string + thinking_chunk
  481. # elif answer_chunk != '':
  482. # if not done_thinking:
  483. # done_thinking = True
  484. # json_string = json_string + answer_chunk
  485. json_string = completion.choices[0].message.content
  486. #print(completion.choices[0].message.reasoning_content)
  487. print(json_string)
  488. if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
  489. answer=[]
  490. if 'A' in json_string and len(A) > 0:
  491. answer.append(A[0])
  492. if 'B' in json_string and len(A) > 1:
  493. answer.append(A[1])
  494. if 'C' in json_string and len(A) > 2:
  495. answer.append(A[2])
  496. if 'D' in json_string and len(A) > 3:
  497. answer.append(A[3])
  498. if 'E' in json_string and len(A) > 4:
  499. answer.append(A[4])
  500. if 'F' in json_string and len(A) > 5:
  501. answer.append(A[5])
  502. if 'G' in json_string and len(A) > 6:
  503. answer.append(A[6])
  504. if 'H' in json_string and len(A) > 7:
  505. answer.append(A[7])
  506. if 'I' in json_string and len(A) > 8:
  507. answer.append(A[8])
  508. if 'J' in json_string and len(A) > 9:
  509. answer.append(A[9])
  510. return answer
  511. completion = sfclient.chat.completions.create(
  512. #model="glm-4.5-flash",
  513. model=simplemodel(),
  514. messages=xuanxiang(json_string),
  515. extra_body={"thinking": {"type": "disabled"}},
  516. #extra_body={"enable_thinking": False},
  517. )
  518. json_string = completion.choices[0].message.content
  519. print(json_string)
  520. answer=[]
  521. if 'A' in json_string and len(A) > 0:
  522. answer.append(A[0])
  523. if 'B' in json_string and len(A) > 1:
  524. answer.append(A[1])
  525. if 'C' in json_string and len(A) > 2:
  526. answer.append(A[2])
  527. if 'D' in json_string and len(A) > 3:
  528. answer.append(A[3])
  529. if 'E' in json_string and len(A) > 4:
  530. answer.append(A[4])
  531. if 'F' in json_string and len(A) > 5:
  532. answer.append(A[5])
  533. if 'G' in json_string and len(A) > 6:
  534. answer.append(A[6])
  535. if 'H' in json_string and len(A) > 7:
  536. answer.append(A[7])
  537. if 'I' in json_string and len(A) > 8:
  538. answer.append(A[8])
  539. if 'J' in json_string and len(A) > 9:
  540. answer.append(A[9])
  541. return answer
  542. def aifilter2(A, #options
  543. B, #data
  544. aiclient,
  545. qwclient,
  546. dw):
  547. hit_wumian = False
  548. for entry in A:
  549. if entry in obj['wumian']:
  550. hit_wumian=True
  551. hit_loumian = False
  552. loumian_entry = ''
  553. for entry in A:
  554. if entry in obj['loumian']:
  555. hit_loumian=True
  556. loumian_entry = entry
  557. if hit_wumian and hit_loumian:
  558. return [x for x in A if x != loumian_entry]
  559. return A
  560. def postprocess0113(selected, data, aiclient, qwclient, sfclient, label_name, name_dw, candidates):
  561. prime = aifilter1(selected, data, aiclient, qwclient, sfclient, name_dw)
  562. if len(prime) == 0:
  563. selected = fallback(candidates, data, aiclient, qwclient, sfclient, None, None)
  564. return selected
  565. return prime