tihuan.py 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. import json
  2. from tihuan_hunningtu import tihuan_hunningtu
  3. from tihuan_gangjin import tihuan_gangjin
  4. from tihuan_gangcai import tihuan_gangcai
  5. from tihuan_shajiang import tihuan_shajiang
  6. from tihuan_zhuan import tihuan_zhuan
  7. from tihuan_shicai import tihuan_shicai
  8. from tihuan_gai import tihuan_gai
  9. from tihuan_fangshui import tihuan_fangshui
  10. from tihuan_wa import tihuan_wa
  11. from tihuan_dizhuan import tihuan_dizhuan
  12. from tihuan_juancai import tihuan_juancai
  13. from tihuan_bancai import tihuan_bancai
  14. from tihuan_mugongban import tihuan_mugongban
  15. from config import simplemodel
  16. with open("name_label", "r") as f:
  17. content = f.read()
  18. name_label = json.loads(content)
  19. def tihuan(
  20. name,
  21. dercj,
  22. label,
  23. aiclient,
  24. qwclient,
  25. sfclient,
  26. data
  27. ):
  28. result=[]
  29. xuanxiang=[]
  30. choice=[]
  31. letters='ABC'
  32. index = name.find('+')
  33. if index > -1:
  34. name = name[:index]
  35. pos=[]
  36. for i in range(len(name)):
  37. if name[i] == '-':
  38. pos.append(i)
  39. if len(pos) > 1:
  40. name = name[:pos[1]]
  41. if name in ['13-26']:
  42. return []
  43. description = name_label[name]
  44. rcjobj = json.loads(dercj)
  45. clde = rcjobj['clde']
  46. hit_zhuan=False
  47. hit_kuai=False
  48. sj_max = 0
  49. sj_min = 10000
  50. for i in range(len(clde)):
  51. bh = clde[i]['CLBH']
  52. sl = clde[i]['SL']
  53. if float(sl) < 1e-6:
  54. continue
  55. if bh.startswith("0413"):
  56. hit_zhuan = True
  57. if bh.startswith("0415"):
  58. hit_kuai = True
  59. if bh.startswith("800") and not bh.startswith('8007'):##砂浆
  60. if sl < 0.01:
  61. continue
  62. if sl > sj_max:
  63. sj_max = sl
  64. if sl < sj_min:
  65. sj_min = sl
  66. for i in range(len(clde)):
  67. bh = clde[i]['CLBH']
  68. sl = clde[i]['SL']
  69. if float(sl) < 1e-6:
  70. continue
  71. if bh in ['80010161']:##块料楼地面 干硬性水泥砂浆
  72. continue
  73. if bh.startswith("8021"):
  74. ##混凝土
  75. completion = aiclient.chat.completions.create(
  76. model="glm-4.5-air",
  77. messages=[
  78. {"role": "system", "content": "You are a helpful assistant."},
  79. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了混凝土(砼)作为材料之一。请从工作内容中找到与该工序最匹配的描述(注意区分面层跟找平找坡层),并从描述中抽取出混凝土的具体品种型号等信息。例如,如果工作内容的描述中写的是“C40微膨胀混凝土”,那么你应该原封不动的返回“C40微膨胀混凝土”。再例如,如果工作内容中描述混凝土种类商品砼,混凝土强度等级C15,那么你应该返回“C15商品砼”。如果工作内容中没有具体描述混凝土的信息,则返回“通用混凝土”'},
  80. ],
  81. extra_body={"thinking": {"type": "disabled"}},
  82. )
  83. json_string = completion.choices[0].message.content
  84. print(json_string)
  85. completion = sfclient.chat.completions.create(
  86. model=simplemodel(),
  87. messages=[
  88. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  89. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种混凝土名称型号作为答案,请将该混凝土名称型号输出"},
  90. ],
  91. extra_body={"thinking": {"type": "disabled"}},
  92. )
  93. json_string = completion.choices[0].message.content
  94. print(json_string)
  95. parts = json_string.split('\n')
  96. parts = [x for x in parts if ':' in x]
  97. if len(parts) == 0:
  98. continue
  99. parts = parts[0].split(':')
  100. part = parts[1]
  101. part = part.replace(',','')
  102. part = part.replace('\'','')
  103. part = part.replace('\"','')
  104. part = part.replace(' ','')
  105. result.append(tihuan_hunningtu(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  106. if bh.startswith("01010100"):
  107. ##钢筋
  108. completion = aiclient.chat.completions.create(
  109. model="glm-4.5-air",
  110. messages=[
  111. {"role": "system", "content": "You are a helpful assistant."},
  112. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了钢筋作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出钢筋的具体品种型号等信息。例如,如果工作内容的描述中写的是“Φ25以内三级钢”,那么你应该原封不动的返回“Φ25以内三级钢”。如果工作内容中没有具体描述钢筋的信息,则返回“通用钢筋”'},
  113. ],
  114. extra_body={"thinking": {"type": "disabled"}},
  115. )
  116. json_string = completion.choices[0].message.content
  117. print(json_string)
  118. completion = sfclient.chat.completions.create(
  119. model=simplemodel(),
  120. messages=[
  121. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  122. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种钢筋名称作为答案,请将该钢筋名称输出"},
  123. ],
  124. extra_body={"thinking": {"type": "disabled"}},
  125. )
  126. json_string = completion.choices[0].message.content
  127. print(json_string)
  128. parts = json_string.split('\n')
  129. parts = [x for x in parts if ':' in x]
  130. if len(parts) == 0:
  131. continue
  132. parts = parts[0].split(':')
  133. part = parts[1]
  134. part = part.replace(',','')
  135. part = part.replace('\'','')
  136. part = part.replace('\"','')
  137. part = part.replace(' ','')
  138. result.append(tihuan_gangjin(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  139. if bh.startswith("800") and not bh.startswith('8007'):
  140. ##砂浆
  141. if data['bianma'].startswith('0112'):
  142. if sl < 0.01:
  143. continue
  144. if sl >= sj_max:##打底
  145. completion = aiclient.chat.completions.create(
  146. model="glm-4.5-air",
  147. messages=[
  148. {"role": "system", "content": "You are a helpful assistant."},
  149. {"role": "user", "content": "以下是一段工作内容的描述: " + data['tz_bak'] + '\n其中包括了一道工序如下: ' +description + '\n工序使用了砂浆打底(**不**是罩面)。请从工作内容中找到与砂浆打底(**不**是罩面)最匹配的描述,并从抽取的描述中再抽取出砂浆的具体品种型号等信息。例如,如果工作内容的描述中写的是“Mb10水泥砂浆”,那么你应该原封不动的返回“Mb10水泥砂浆”。如果工作内容中没有具体描述砂浆的信息,则返回“通用砂浆”'},
  150. ],
  151. extra_body={"thinking": {"type": "disabled"}},
  152. )
  153. json_string = completion.choices[0].message.content
  154. print(json_string)
  155. elif sl <= sj_min:##罩面
  156. completion = aiclient.chat.completions.create(
  157. model="glm-4.5-air",
  158. messages=[
  159. {"role": "system", "content": "You are a helpful assistant."},
  160. {"role": "user", "content": "以下是一段工作内容的描述: " + data['tz_bak'] + '\n其中包括了一道工序如下: ' +description + '\n工序使用了砂浆罩面(**不**是打底)。请从工作内容中找到与砂浆罩面(**不**是打底)最匹配的描述,并从抽取的描述中再抽取出砂浆的具体品种型号等信息。例如,如果工作内容的描述中写的是“Mb10水泥砂浆”,那么你应该原封不动的返回“Mb10水泥砂浆”。如果工作内容中没有具体描述砂浆的信息,则返回“通用砂浆”'},
  161. ],
  162. extra_body={"thinking": {"type": "disabled"}},
  163. )
  164. json_string = completion.choices[0].message.content
  165. print(json_string)
  166. else:
  167. continue
  168. else:
  169. completion = aiclient.chat.completions.create(
  170. model="glm-4.5-air",
  171. messages=[
  172. {"role": "system", "content": "You are a helpful assistant."},
  173. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了砂浆作为材料之一。请从工作内容中找到与该工序最匹配的描述(不要从工序文字中抽取描述)(注意区分找平找坡层跟面层保护层),并从抽取的描述中再抽取出砂浆的具体品种型号等信息。例如,如果工作内容的描述中写的是“Mb10水泥砂浆”,那么你应该原封不动的返回“Mb10水泥砂浆”。如果工作内容中没有具体描述砂浆的信息,则返回“通用砂浆”'},
  174. ],
  175. extra_body={"thinking": {"type": "disabled"}},
  176. )
  177. json_string = completion.choices[0].message.content
  178. print(json_string)
  179. completion = sfclient.chat.completions.create(
  180. model=simplemodel(),
  181. messages=[
  182. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  183. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种砂浆名称作为答案,请将该砂浆名称输出.必须以json格式输出.请直接输出结果"},
  184. ],
  185. extra_body={"thinking": {"type": "disabled"}},
  186. )
  187. json_string = completion.choices[0].message.content
  188. print(json_string)
  189. parts = json_string.split('\n')
  190. parts = [x for x in parts if ':' in x]
  191. if len(parts) == 0:
  192. continue
  193. parts = parts[0].split(':')
  194. parts = parts[1:]
  195. part = ':'.join(parts)
  196. part = part.replace(',','')
  197. part = part.replace('\'','')
  198. part = part.replace('\"','')
  199. part = part.replace(' ','')
  200. result.append(tihuan_shajiang(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  201. if bh.startswith("0413") and not hit_kuai:
  202. ##砖
  203. completion = aiclient.chat.completions.create(
  204. model="glm-4.5-air",
  205. messages=[
  206. {"role": "system", "content": "You are a helpful assistant."},
  207. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了砖(砌块)作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出砖(砌块)的具体品种型号等信息。例如,如果工作内容的描述中写的是“MU20蒸压灰砂砖”,那么你应该原封不动的返回“MU20蒸压灰砂砖”。如果工作内容中没有具体描述砖(砌块)的信息,则返回“通用砖”'},
  208. ],
  209. extra_body={"thinking": {"type": "disabled"}},
  210. )
  211. json_string = completion.choices[0].message.content
  212. print(json_string)
  213. completion = sfclient.chat.completions.create(
  214. model=simplemodel(),
  215. messages=[
  216. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  217. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种砖(砌块)名称作为答案,请将该砖(砌块)名称输出"},
  218. ],
  219. extra_body={"thinking": {"type": "disabled"}},
  220. )
  221. json_string = completion.choices[0].message.content
  222. print(json_string)
  223. parts = json_string.split('\n')
  224. parts = [x for x in parts if ':' in x]
  225. if len(parts) == 0:
  226. continue
  227. parts = parts[0].split(':')
  228. part = parts[1]
  229. part = part.replace(',','')
  230. part = part.replace('\'','')
  231. part = part.replace('\"','')
  232. part = part.replace(' ','')
  233. result.append(tihuan_zhuan(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  234. if bh.startswith("0415"):
  235. ##砌块
  236. completion = aiclient.chat.completions.create(
  237. model="glm-4.5-air",
  238. messages=[
  239. {"role": "system", "content": "You are a helpful assistant."},
  240. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了砖(砌块)作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出砖(砌块)的具体品种型号等信息。例如,如果工作内容的描述中写的是“MU20蒸压灰砂砖”,那么你应该原封不动的返回“MU20蒸压灰砂砖”。如果工作内容中没有具体描述砖(砌块)的信息,则返回“通用砖”'},
  241. ],
  242. extra_body={"thinking": {"type": "disabled"}},
  243. )
  244. json_string = completion.choices[0].message.content
  245. print(json_string)
  246. completion = sfclient.chat.completions.create(
  247. model=simplemodel(),
  248. messages=[
  249. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  250. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种砖(砌块)名称作为答案,请将该砖(砌块)名称输出"},
  251. ],
  252. extra_body={"thinking": {"type": "disabled"}},
  253. )
  254. json_string = completion.choices[0].message.content
  255. print(json_string)
  256. parts = json_string.split('\n')
  257. parts = [x for x in parts if ':' in x]
  258. if len(parts) == 0:
  259. continue
  260. parts = parts[0].split(':')
  261. part = parts[1]
  262. part = part.replace(',','')
  263. part = part.replace('\'','')
  264. part = part.replace('\"','')
  265. part = part.replace(' ','')
  266. result.append(tihuan_zhuan(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  267. if bh.startswith("0711213"):
  268. ##石材块料
  269. completion = aiclient.chat.completions.create(
  270. model="glm-4.5-air",
  271. messages=[
  272. {"role": "system", "content": "You are a helpful assistant."},
  273. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了石材块料、砖作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出石材块料、砖的具体品种型号等信息。例如,如果工作内容的描述中写的是“30厚600X600芝麻黑火烧面花岗岩”,那么你应该原封不动的返回“30厚600X600芝麻黑火烧面花岗岩”。如果工作内容中没有具体描述石材块料、砖的信息,则返回“通用石材块料”'},
  274. ],
  275. extra_body={"thinking": {"type": "disabled"}},
  276. )
  277. json_string = completion.choices[0].message.content
  278. print(json_string)
  279. completion = sfclient.chat.completions.create(
  280. model=simplemodel(),
  281. messages=[
  282. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  283. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种石材块料、砖名称作为答案,请将该石材块料、砖名称输出"},
  284. ],
  285. extra_body={"thinking": {"type": "disabled"}},
  286. )
  287. json_string = completion.choices[0].message.content
  288. print(json_string)
  289. parts = json_string.split('\n')
  290. parts = [x for x in parts if ':' in x]
  291. if len(parts) == 0:
  292. continue
  293. parts = parts[0].split(':')
  294. part = parts[1]
  295. part = part.replace(',','')
  296. part = part.replace('\'','')
  297. part = part.replace('\"','')
  298. part = part.replace(' ','')
  299. result.append(tihuan_shicai(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  300. if bh.startswith("3301"):
  301. ##盖板
  302. completion = aiclient.chat.completions.create(
  303. model="glm-4.5-air",
  304. messages=[
  305. {"role": "system", "content": "You are a helpful assistant."},
  306. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了盖板(篦子)作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出盖板(篦子)的具体品种型号等信息。例如,如果工作内容的描述中写的是“Φ1000带锁圆形钢盖板”,那么你应该原封不动的返回“Φ1000带锁圆形钢盖板”。如果工作内容中没有具体描述盖板(篦子)的信息,则返回“通用盖板”'},
  307. ],
  308. extra_body={"thinking": {"type": "disabled"}},
  309. )
  310. json_string = completion.choices[0].message.content
  311. print(json_string)
  312. completion = sfclient.chat.completions.create(
  313. model=simplemodel(),
  314. messages=[
  315. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  316. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种盖板(篦子)名称作为答案,请将该盖板(篦子)名称输出"},
  317. ],
  318. extra_body={"thinking": {"type": "disabled"}},
  319. )
  320. json_string = completion.choices[0].message.content
  321. print(json_string)
  322. parts = json_string.split('\n')
  323. parts = [x for x in parts if ':' in x]
  324. if len(parts) == 0:
  325. continue
  326. parts = parts[0].split(':')
  327. part = parts[1]
  328. part = part.replace(',','')
  329. part = part.replace('\'','')
  330. part = part.replace('\"','')
  331. part = part.replace(' ','')
  332. result.append(tihuan_gai(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  333. if bh.startswith("012701") or bh.startswith('012703'):
  334. ##钢材
  335. completion = aiclient.chat.completions.create(
  336. model="glm-4.5-air",
  337. messages=[
  338. {"role": "system", "content": "You are a helpful assistant."},
  339. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了钢材作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出钢材的具体品种型号等信息。例如,如果工作内容的描述中写的是“Q235B”,那么你应该原封不动的返回“Q235B”。如果工作内容提及镀锌钢管,则你应该返回“镀锌钢管”。如果工作内容中没有具体描述钢材的信息,则返回“通用钢”'},
  340. ],
  341. extra_body={"thinking": {"type": "disabled"}},
  342. )
  343. json_string = completion.choices[0].message.content
  344. print(json_string)
  345. completion = sfclient.chat.completions.create(
  346. model=simplemodel(),
  347. messages=[
  348. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  349. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种钢材名称型号作为答案,请将该钢材名称型号输出"},
  350. ],
  351. extra_body={"thinking": {"type": "disabled"}},
  352. )
  353. json_string = completion.choices[0].message.content
  354. print(json_string)
  355. parts = json_string.split('\n')
  356. parts = [x for x in parts if ':' in x]
  357. if len(parts) == 0:
  358. continue
  359. parts = parts[0].split(':')
  360. part = parts[1]
  361. part = part.replace(',','')
  362. part = part.replace('\'','')
  363. part = part.replace('\"','')
  364. part = part.replace(' ','')
  365. result.append(tihuan_gangcai(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  366. if bh.startswith("11030746"):
  367. ##防水涂料
  368. completion = aiclient.chat.completions.create(
  369. model="glm-4.5-air",
  370. messages=[
  371. {"role": "system", "content": "You are a helpful assistant."},
  372. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了防水涂料作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出防水涂料的具体品种型号等信息。例如,如果工作内容的描述中写的是“2.0厚非固化沥青防水涂料”,那么你应该原封不动的返回“2.0厚非固化沥青防水涂料”。如果工作内容中没有具体描述防水涂料的信息,则返回“通用防水涂料”'},
  373. ],
  374. extra_body={"thinking": {"type": "disabled"}},
  375. )
  376. json_string = completion.choices[0].message.content
  377. print(json_string)
  378. completion = sfclient.chat.completions.create(
  379. model=simplemodel(),
  380. messages=[
  381. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  382. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种防水涂料名称作为答案,请将该防水涂料名称输出"},
  383. ],
  384. extra_body={"thinking": {"type": "disabled"}},
  385. )
  386. json_string = completion.choices[0].message.content
  387. print(json_string)
  388. parts = json_string.split('\n')
  389. parts = [x for x in parts if ':' in x]
  390. if len(parts) == 0:
  391. continue
  392. parts = parts[0].split(':')
  393. part = parts[1]
  394. part = part.replace(',','')
  395. part = part.replace('\'','')
  396. part = part.replace('\"','')
  397. part = part.replace(' ','')
  398. result.append(tihuan_fangshui(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  399. if bh.startswith("041703"):
  400. ##水泥彩瓦
  401. completion = aiclient.chat.completions.create(
  402. model="glm-4.5-air",
  403. messages=[
  404. {"role": "system", "content": "You are a helpful assistant."},
  405. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了瓦作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出瓦的具体品种型号等信息。例如,如果工作内容的描述中写的是“0.9mm铝镁锰合金仿古金属瓦”,那么你应该原封不动的返回“0.9mm铝镁锰合金仿古金属瓦”。如果工作内容中没有具体描述瓦的信息,则返回“通用瓦”'},
  406. ],
  407. extra_body={"thinking": {"type": "disabled"}},
  408. )
  409. json_string = completion.choices[0].message.content
  410. print(json_string)
  411. completion = sfclient.chat.completions.create(
  412. model=simplemodel(),
  413. messages=[
  414. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  415. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种瓦名称型号作为答案,请将该瓦名称型号输出"},
  416. ],
  417. extra_body={"thinking": {"type": "disabled"}},
  418. )
  419. json_string = completion.choices[0].message.content
  420. print(json_string)
  421. parts = json_string.split('\n')
  422. parts = [x for x in parts if ':' in x]
  423. if len(parts) == 0:
  424. continue
  425. parts = parts[0].split(':')
  426. part = parts[1]
  427. part = part.replace(',','')
  428. part = part.replace('\'','')
  429. part = part.replace('\"','')
  430. part = part.replace(' ','')
  431. result.append(tihuan_wa(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  432. if bh.startswith("066501") or bh.startswith('066121'):
  433. ##地砖、面砖
  434. completion = aiclient.chat.completions.create(
  435. model="glm-4.5-air",
  436. messages=[
  437. {"role": "system", "content": "You are a helpful assistant."},
  438. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了地砖、面砖作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出地砖、面砖的具体品种型号等信息。例如,如果工作内容的描述中写的是“10厚800X800防滑地砖”,那么你应该原封不动的返回“10厚800X800防滑地砖”。如果工作内容中没有具体描述地砖、面砖的信息,则返回“通用砖”'},
  439. ],
  440. extra_body={"thinking": {"type": "disabled"}},
  441. )
  442. json_string = completion.choices[0].message.content
  443. print(json_string)
  444. completion = sfclient.chat.completions.create(
  445. model=simplemodel(),
  446. messages=[
  447. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  448. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种砖名称型号作为答案,请将该砖名称型号输出"},
  449. ],
  450. extra_body={"thinking": {"type": "disabled"}},
  451. )
  452. json_string = completion.choices[0].message.content
  453. print(json_string)
  454. parts = json_string.split('\n')
  455. parts = [x for x in parts if ':' in x]
  456. if len(parts) == 0:
  457. continue
  458. parts = parts[0].split(':')
  459. part = parts[1]
  460. part = part.replace(',','')
  461. part = part.replace('\'','')
  462. part = part.replace('\"','')
  463. part = part.replace(' ','')
  464. result.append(tihuan_dizhuan(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  465. if bh.startswith("11570") or bh.startswith('115721'):
  466. ##卷材
  467. completion = aiclient.chat.completions.create(
  468. model="glm-4.5-air",
  469. messages=[
  470. {"role": "system", "content": "You are a helpful assistant."},
  471. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了卷材作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出卷材的具体品种型号等信息。例如,如果工作内容的描述中写的是“3.0厚SBS聚合物改性沥青防水卷材(PY)Ⅱ型聚酯胎”,那么你应该原封不动的返回“3.0厚SBS聚合物改性沥青防水卷材(PY)Ⅱ型聚酯胎”。如果工作内容中没有具体描述卷材的信息,则返回“通用卷材”'},
  472. ],
  473. extra_body={"thinking": {"type": "disabled"}},
  474. )
  475. json_string = completion.choices[0].message.content
  476. print(json_string)
  477. completion = sfclient.chat.completions.create(
  478. model=simplemodel(),
  479. messages=[
  480. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  481. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种卷材名称型号作为答案,请将该卷材名称型号输出"},
  482. ],
  483. extra_body={"thinking": {"type": "disabled"}},
  484. )
  485. json_string = completion.choices[0].message.content
  486. print(json_string)
  487. parts = json_string.split('\n')
  488. parts = [x for x in parts if ':' in x]
  489. if len(parts) == 0:
  490. continue
  491. parts = parts[0].split(':')
  492. part = parts[1]
  493. part = part.replace(',','')
  494. part = part.replace('\'','')
  495. part = part.replace('\"','')
  496. part = part.replace(' ','')
  497. result.append(tihuan_juancai(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  498. if bh.startswith("021103"):
  499. ##挤塑板
  500. completion = aiclient.chat.completions.create(
  501. model="glm-4.5-air",
  502. messages=[
  503. {"role": "system", "content": "You are a helpful assistant."},
  504. {"role": "user", "content": "以下是一段工作内容的描述: " + label + '\n其中包括了一道工序如下: ' +description + '\n工序使用了板材作为材料之一。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出板材的具体品种型号等信息。例如,如果工作内容的描述中写的是“20厚Ⅰ型石墨聚苯板”,那么你应该原封不动的返回“20厚Ⅰ型石墨聚苯板”。如果工作内容中没有具体描述板材的信息,则返回“通用板材”'},
  505. ],
  506. extra_body={"thinking": {"type": "disabled"}},
  507. )
  508. json_string = completion.choices[0].message.content
  509. print(json_string)
  510. completion = sfclient.chat.completions.create(
  511. model=simplemodel(),
  512. messages=[
  513. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  514. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种板材名称型号作为答案,请将该板材名称型号输出"},
  515. ],
  516. extra_body={"thinking": {"type": "disabled"}},
  517. )
  518. json_string = completion.choices[0].message.content
  519. print(json_string)
  520. parts = json_string.split('\n')
  521. parts = [x for x in parts if ':' in x]
  522. if len(parts) == 0:
  523. continue
  524. parts = parts[0].split(':')
  525. part = parts[1]
  526. part = part.replace(',','')
  527. part = part.replace('\'','')
  528. part = part.replace('\"','')
  529. part = part.replace(' ','')
  530. result.append(tihuan_bancai(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  531. if bh.startswith("0509"):
  532. ##细木工板
  533. completion = aiclient.chat.completions.create(
  534. model="glm-4.5-air",
  535. messages=[
  536. {"role": "system", "content": "You are a helpful assistant."},
  537. {"role": "user", "content": "以下是一段工作内容的描述: " + data['tz_bak'] + '\n其中包括了一道工序如下: ' +description + '\n工序使用了板材作为材料之一,用于阻燃吸音。请从工作内容中找到与该工序最匹配的描述,并从描述中抽取出板材的具体品种型号等信息。例如,如果工作内容的描述中写的是“18mm厚阻燃板”,那么你应该原封不动的返回“18mm厚阻燃板”。如果工作内容中没有具体描述板材的信息,则返回“通用板材”'},
  538. ],
  539. extra_body={"thinking": {"type": "disabled"}},
  540. )
  541. json_string = completion.choices[0].message.content
  542. print(json_string)
  543. completion = sfclient.chat.completions.create(
  544. model=simplemodel(),
  545. messages=[
  546. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  547. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一种板材名称型号作为答案,请将该板材名称型号输出"},
  548. ],
  549. extra_body={"thinking": {"type": "disabled"}},
  550. )
  551. json_string = completion.choices[0].message.content
  552. print(json_string)
  553. parts = json_string.split('\n')
  554. parts = [x for x in parts if ':' in x]
  555. if len(parts) == 0:
  556. continue
  557. parts = parts[0].split(':')
  558. part = parts[1]
  559. part = part.replace(',','')
  560. part = part.replace('\'','')
  561. part = part.replace('\"','')
  562. part = part.replace(' ','')
  563. result.append(tihuan_mugongban(clde[i]['CLBH'], clde[i]['CLMC'], clde[i]['YSJG'], part))
  564. return result