postprocess0111.py 28 KB

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