tihuan_az.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. import json
  2. from config import simplemodel
  3. with open('az_name_label', 'r') as f:
  4. content = f.read()
  5. name_label = json.loads(content)
  6. def tihuan_az(
  7. name,
  8. dercj,
  9. label,
  10. aiclient,
  11. qwclient,
  12. sfclient,
  13. data
  14. ):
  15. result=[]
  16. index = name.find('+')
  17. if index > -1:
  18. name = name[:index]
  19. pos=[]
  20. for i in range(len(name)):
  21. if name[i] == '-':
  22. pos.append(i)
  23. if len(pos) > 1:
  24. name = name[:pos[1]]
  25. name_label_ = name_label[name]
  26. rcjobj = json.loads(dercj)
  27. clde = rcjobj['clde']
  28. for i in range(len(clde)):
  29. bh = clde[i]['CLBH']
  30. sl = clde[i]['SL']
  31. if float(sl) < 1e-6:
  32. continue
  33. if bh.startswith("26012501"):
  34. ##桥架
  35. completion = aiclient.chat.completions.create(
  36. model="glm-4.5-air",
  37. messages=[
  38. {"role": "system", "content": "You are a helpful assistant."},
  39. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出桥架的具体品种型号等信息。"+'''
  40. 例如,给定文字如下:
  41. 1、名称:电线电缆桥架(超高)
  42. 2、型号:QJ
  43. 3、规格:800*200
  44. 4、材质:热镀锌
  45. 你应该返回 “热镀锌桥架800*200”
  46. 现在给定文字如下:
  47. ''' + label +'\n请给出答案'
  48. },
  49. ],
  50. extra_body={"thinking": {"type": "disabled"}},
  51. )
  52. json_string = completion.choices[0].message.content
  53. print(json_string)
  54. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  55. if bh.startswith("1401"):
  56. ##钢管
  57. completion = aiclient.chat.completions.create(
  58. model="glm-4.5-air",
  59. messages=[
  60. {"role": "system", "content": "You are a helpful assistant."},
  61. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出钢管的具体品种型号等信息。"+'''
  62. 例如,给定文字如下:
  63. 1、名称:穿线管
  64. 2、材质:镀锌钢管
  65. 3、规格:SC150
  66. 4、配置形式:明配/超高
  67. 你应该返回 “镀锌钢管DN150”
  68. 现在给定文字如下:
  69. ''' + label +'\n请给出答案'
  70. },
  71. ],
  72. extra_body={"thinking": {"type": "disabled"}},
  73. )
  74. json_string = completion.choices[0].message.content
  75. print(json_string)
  76. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  77. if bh.startswith("25430311") or bh.startswith('25430314'):
  78. ##绝缘导线
  79. completion = aiclient.chat.completions.create(
  80. model="glm-4.5-air",
  81. messages=[
  82. {"role": "system", "content": "You are a helpful assistant."},
  83. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出绝缘导线的具体品种型号等信息。"+'''
  84. 例如,给定文字如下:
  85. 1、名称:配线
  86. 2、配线形式:管内穿线
  87. 3、规格:RS485
  88. 4、材质:铜芯
  89. 你应该返回 “绝缘导线RS485”
  90. 现在给定文字如下:
  91. ''' + label +'\n请给出答案'
  92. },
  93. ],
  94. extra_body={"thinking": {"type": "disabled"}},
  95. )
  96. json_string = completion.choices[0].message.content
  97. print(json_string)
  98. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  99. if bh.startswith("22470111"):
  100. ##灯
  101. completion = aiclient.chat.completions.create(
  102. model="glm-4.5-air",
  103. messages=[
  104. {"role": "system", "content": "You are a helpful assistant."},
  105. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出灯具的具体品种型号等信息。"+'''
  106. 例如,给定文字如下:
  107. 1、名称:LED深照型工厂灯
  108. 2、型号:SL-T2608-300W
  109. 3、规格: 220V 300W
  110. 4、安装形式:超高
  111. 你应该返回 “LED深照型工厂灯SL-T2608-300W”
  112. 现在给定文字如下:
  113. ''' + label +'\n请给出答案'
  114. },
  115. ],
  116. extra_body={"thinking": {"type": "disabled"}},
  117. )
  118. json_string = completion.choices[0].message.content
  119. print(json_string)
  120. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  121. if bh.startswith("26110101"):
  122. ##接线盒
  123. completion = aiclient.chat.completions.create(
  124. model="glm-4.5-air",
  125. messages=[
  126. {"role": "system", "content": "You are a helpful assistant."},
  127. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出接线盒的具体品种型号等信息。"+'''
  128. 例如,给定文字如下:
  129. 1、名称:接线盒
  130. 2、材质:钢制
  131. 3、规格:86型
  132. 4、安装形式:明装,超高
  133. 你应该返回 “钢制接线盒”
  134. 现在给定文字如下:
  135. ''' + label +'\n请给出答案'
  136. },
  137. ],
  138. extra_body={"thinking": {"type": "disabled"}},
  139. )
  140. json_string = completion.choices[0].message.content
  141. print(json_string)
  142. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  143. if bh.startswith("23412504"):
  144. ##插座
  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": "给定一段工作内容的描述,请从工作内容中抽取出插座的具体品种型号等信息。"+'''
  150. 例如,给定文字如下:
  151. 1、名称:单相二三孔安全插座
  152. 2、材质:塑料
  153. 3、规格:86Z223-10A
  154. 你应该返回 “单相二三孔安全插座86Z223-10A”
  155. 现在给定文字如下:
  156. ''' + label +'\n请给出答案'
  157. },
  158. ],
  159. extra_body={"thinking": {"type": "disabled"}},
  160. )
  161. json_string = completion.choices[0].message.content
  162. print(json_string)
  163. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  164. if bh.startswith("23230131"):
  165. ##开关
  166. completion = aiclient.chat.completions.create(
  167. model="glm-4.5-air",
  168. messages=[
  169. {"role": "system", "content": "You are a helpful assistant."},
  170. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出开关的具体品种型号等信息。"+'''
  171. 例如,给定文字如下:
  172. 1、名称:三联单控开关
  173. 2、材质:塑料
  174. 3、规格:86型
  175. 你应该返回 “三联单控开关”
  176. 现在给定文字如下:
  177. ''' + label +'\n请给出答案'
  178. },
  179. ],
  180. extra_body={"thinking": {"type": "disabled"}},
  181. )
  182. json_string = completion.choices[0].message.content
  183. print(json_string)
  184. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  185. if bh.startswith("260935"):
  186. ##端子箱(板)
  187. completion = aiclient.chat.completions.create(
  188. model="glm-4.5-air",
  189. messages=[
  190. {"role": "system", "content": "You are a helpful assistant."},
  191. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出端子箱、板的具体品种型号等信息。"+'''
  192. 例如,给定文字如下:
  193. 1、名称:接地预埋端子板
  194. 2、材质:镀锌钢板
  195. 3、规格:100*100*10
  196. 你应该返回 “接地预埋端子板100*100*10”
  197. 现在给定文字如下:
  198. ''' + label +'\n请给出答案'
  199. },
  200. ],
  201. extra_body={"thinking": {"type": "disabled"}},
  202. )
  203. json_string = completion.choices[0].message.content
  204. print(json_string)
  205. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  206. if bh.startswith("145509"):
  207. ##复合管
  208. completion = aiclient.chat.completions.create(
  209. model="glm-4.5-air",
  210. messages=[
  211. {"role": "system", "content": "You are a helpful assistant."},
  212. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出管道的具体品种型号等信息。"+'''
  213. 例如,给定文字如下:
  214. 1、安装部位:室内
  215. 2、介质:给水
  216. 3、材质、规格:涂塑钢管DN20
  217. 4、连接形式:丝扣连接
  218. 5、压力试验及吹、洗设计要求:吹洗
  219. 你应该返回 “涂塑钢管DN20”
  220. 现在给定文字如下:
  221. ''' + label +'\n请给出答案'
  222. },
  223. ],
  224. extra_body={"thinking": {"type": "disabled"}},
  225. )
  226. json_string = completion.choices[0].message.content
  227. print(json_string)
  228. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  229. if bh.startswith("143103"):
  230. ##塑料管
  231. completion = aiclient.chat.completions.create(
  232. model="glm-4.5-air",
  233. messages=[
  234. {"role": "system", "content": "You are a helpful assistant."},
  235. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出管道的具体品种型号等信息。"+'''
  236. 例如,给定文字如下:
  237. 1、安装部位:室内
  238. 2、介质:排水
  239. 3、材质、规格:U-PVC110
  240. 4、连接形式:粘接
  241. 你应该返回 “U-PVC110”
  242. 现在给定文字如下:
  243. ''' + label +'\n请给出答案'
  244. },
  245. ],
  246. extra_body={"thinking": {"type": "disabled"}},
  247. )
  248. json_string = completion.choices[0].message.content
  249. print(json_string)
  250. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  251. if bh.startswith("1631") and '排气阀' not in label:
  252. ##阀门
  253. completion = aiclient.chat.completions.create(
  254. model="glm-4.5-air",
  255. messages=[
  256. {"role": "system", "content": "You are a helpful assistant."},
  257. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出阀门的具体品种型号等信息。"+'''
  258. 例如,给定文字如下:
  259. 1、类型:截止阀
  260. 2、材质:不锈钢
  261. 3、规格、压力等级:DN32
  262. 4、连接形式:丝接
  263. 你应该返回 “不锈钢截止阀DN32”
  264. 现在给定文字如下:
  265. ''' + label +'\n请给出答案'
  266. },
  267. ],
  268. extra_body={"thinking": {"type": "disabled"}},
  269. )
  270. json_string = completion.choices[0].message.content
  271. print(json_string)
  272. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  273. if bh.startswith("1841"):
  274. ##水龙头
  275. completion = aiclient.chat.completions.create(
  276. model="glm-4.5-air",
  277. messages=[
  278. {"role": "system", "content": "You are a helpful assistant."},
  279. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出水龙头的具体品种型号等信息。"+'''
  280. 例如,给定文字如下:
  281. 1、材质:带真空破坏器组合水龙头
  282. 2、型号、规格:DN20
  283. 你应该返回 “带真空破坏器组合水龙头DN20”
  284. 现在给定文字如下:
  285. ''' + label +'\n请给出答案'
  286. },
  287. ],
  288. extra_body={"thinking": {"type": "disabled"}},
  289. )
  290. json_string = completion.choices[0].message.content
  291. print(json_string)
  292. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  293. if bh.startswith("1813"):
  294. ##洗涤盆
  295. completion = aiclient.chat.completions.create(
  296. model="glm-4.5-air",
  297. messages=[
  298. {"role": "system", "content": "You are a helpful assistant."},
  299. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出洗涤盆(槽)的具体品种型号等信息。"+'''
  300. 例如,给定文字如下:
  301. 1、材质:不锈钢水槽
  302. 2、规格、类型:1500*500*300
  303. 你应该返回 “不锈钢水槽1500*500*300”
  304. 现在给定文字如下:
  305. ''' + label +'\n请给出答案'
  306. },
  307. ],
  308. extra_body={"thinking": {"type": "disabled"}},
  309. )
  310. json_string = completion.choices[0].message.content
  311. print(json_string)
  312. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  313. if bh.startswith("2001"):
  314. ##灭火器
  315. completion = aiclient.chat.completions.create(
  316. model="glm-4.5-air",
  317. messages=[
  318. {"role": "system", "content": "You are a helpful assistant."},
  319. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出灭火器的具体品种型号等信息。"+'''
  320. 例如,给定文字如下:
  321. 1、形式:手提式灭火器
  322. 2、规格、型号:MF/ABC5
  323. 3、每套含两具灭火器及配套灭火器箱
  324. 你应该返回 “手提式灭火器MF/ABC5”
  325. 现在给定文字如下:
  326. ''' + label +'\n请给出答案'
  327. },
  328. ],
  329. extra_body={"thinking": {"type": "disabled"}},
  330. )
  331. json_string = completion.choices[0].message.content
  332. print(json_string)
  333. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  334. if bh.startswith("261103"):
  335. ##接线箱
  336. completion = aiclient.chat.completions.create(
  337. model="glm-4.5-air",
  338. messages=[
  339. {"role": "system", "content": "You are a helpful assistant."},
  340. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出接线箱的具体品种型号等信息。"+'''
  341. 例如,给定文字如下:
  342. 1、名称:可燃气体报警控制箱
  343. 2、材质:钢制
  344. 你应该返回 “可燃气体报警控制箱”
  345. 现在给定文字如下:
  346. ''' + label +'\n请给出答案'
  347. },
  348. ],
  349. extra_body={"thinking": {"type": "disabled"}},
  350. )
  351. json_string = completion.choices[0].message.content
  352. print(json_string)
  353. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  354. if bh.startswith("34130226"):
  355. ##机柜
  356. completion = aiclient.chat.completions.create(
  357. model="glm-4.5-air",
  358. messages=[
  359. {"role": "system", "content": "You are a helpful assistant."},
  360. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出机柜的具体品种型号等信息。"+'''
  361. 例如,给定文字如下:
  362. 1、名称:能耗计量通讯管理机
  363. 2、安装方式:落地
  364. 你应该返回 “能耗计量通讯管理机”
  365. 现在给定文字如下:
  366. ''' + label +'\n请给出答案'
  367. },
  368. ],
  369. extra_body={"thinking": {"type": "disabled"}},
  370. )
  371. json_string = completion.choices[0].message.content
  372. print(json_string)
  373. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  374. if bh.startswith("34130264"):
  375. ##光缆
  376. completion = aiclient.chat.completions.create(
  377. model="glm-4.5-air",
  378. messages=[
  379. {"role": "system", "content": "You are a helpful assistant."},
  380. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出光缆的具体品种型号等信息。"+'''
  381. 例如,给定文字如下:
  382. 1、名称:光纤
  383. 2、安装方式:4芯光纤
  384. 你应该返回 “4芯光纤”
  385. 现在给定文字如下:
  386. ''' + label +'\n请给出答案'
  387. },
  388. ],
  389. extra_body={"thinking": {"type": "disabled"}},
  390. )
  391. json_string = completion.choices[0].message.content
  392. print(json_string)
  393. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  394. if bh.startswith("151309"):
  395. ##管件
  396. completion = aiclient.chat.completions.create(
  397. model="glm-4.5-air",
  398. messages=[
  399. {"role": "system", "content": "You are a helpful assistant."},
  400. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出管件(连接件)的具体品种型号等信息。"+'''
  401. 例如,给定文字如下:
  402. 1、材质:室内压缩空气接头箱
  403. 2、规格:12接头(配带DN50不锈钢阀门及法兰)
  404. 你应该返回 “室内压缩空气接头箱12接头(配带DN50不锈钢阀门及法兰)”
  405. 现在给定文字如下:
  406. ''' + label +'\n请给出答案'
  407. },
  408. ],
  409. extra_body={"thinking": {"type": "disabled"}},
  410. )
  411. json_string = completion.choices[0].message.content
  412. print(json_string)
  413. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  414. if bh.startswith("1625"):
  415. ##法兰阀门(水表)
  416. completion = aiclient.chat.completions.create(
  417. model="glm-4.5-air",
  418. messages=[
  419. {"role": "system", "content": "You are a helpful assistant."},
  420. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出法兰阀门(水表)的具体品种型号等信息。"+'''
  421. 例如,给定文字如下:
  422. 1、名称:法兰不锈钢蝶阀
  423. 2、型号、规格:D341F-16C型 DN250
  424. 3、连接形式:法兰连接
  425. 你应该返回 “法兰不锈钢蝶阀D341F-16C型 DN250”
  426. 现在给定文字如下:
  427. ''' + label +'\n请给出答案'
  428. },
  429. ],
  430. extra_body={"thinking": {"type": "disabled"}},
  431. )
  432. json_string = completion.choices[0].message.content
  433. print(json_string)
  434. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  435. if bh.startswith("170101"):
  436. ##法兰
  437. completion = aiclient.chat.completions.create(
  438. model="glm-4.5-air",
  439. messages=[
  440. {"role": "system", "content": "You are a helpful assistant."},
  441. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出法兰的具体品种型号等信息。"+'''
  442. 例如,给定文字如下:
  443. 1、材质:板式平焊钢制管法兰
  444. 2、型号、规格:20#-PL250(B)-16
  445. 3、连接形式:焊接
  446. 你应该返回 “板式平焊钢制管法兰20#-PL250(B)-16”
  447. 现在给定文字如下:
  448. ''' + label +'\n请给出答案'
  449. },
  450. ],
  451. extra_body={"thinking": {"type": "disabled"}},
  452. )
  453. json_string = completion.choices[0].message.content
  454. print(json_string)
  455. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  456. if '三通补强圈' in name_label_:
  457. if bh.startswith('01290'):#钢板
  458. completion = aiclient.chat.completions.create(
  459. model="glm-4.5-air",
  460. messages=[
  461. {"role": "system", "content": "You are a helpful assistant."},
  462. {"role": "user", "content": "给定一段工作内容的描述,请从工作内容中抽取出板材的具体品种型号等信息。"+'''
  463. 例如,给定文字如下:
  464. 1、材质:增强柔性石墨板
  465. 2、规格:RSB/304,RF200-16
  466. 你应该返回 “增强柔性石墨板”
  467. 如果没有提及具体板材,请直接回答“钢板”
  468. 现在给定文字如下:
  469. ''' + label +'\n请给出答案'
  470. },
  471. ],
  472. extra_body={"thinking": {"type": "disabled"}},
  473. )
  474. json_string = completion.choices[0].message.content
  475. print(json_string)
  476. result.append( {'bianma': bh, 'new_bianma': bh, 'mc': json_string, 'jg': 0})
  477. return result