import json def only(tz, aiclient): completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,其中描述了一项安装工作的工作内容。这段文字可能会注明,该项工作不用考虑安装的设备本身的费用,只需考虑安装费。这段文字也可能不做任何注明。"+''' 例如,给定文字如下: 1、名称:高真空焊烟净化机组控制箱(箱随设备提供计安装费) 这段文字注明了仅计安装费 再例如,给定文字如下: 1、名称:母线槽始端箱(超高) 2、型号:15C 3、容量(A):1800A 这段文字没有注明 ''' + '现在给定文字如下:'+tz+"\n请判断是否注明了仅计安装费,请直接回答是或者否"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content if '是' in mc: return True return False def need_buchong(debm, tz, aiclient): if debm == '4-266' or debm == '4-267' or debm =='4-268' or debm=='4-269' or debm=='4-270': return not only(tz, aiclient) if debm == '4-265': return not only(tz, aiclient) if debm == '4-203' or debm =='4-204' or debm=='4-205' or debm=='4-206': return not only(tz, aiclient) if debm == '4-918' or debm =='4-919': return not only(tz, aiclient) if debm in ['1-'+str(x) for x in range(684,702)]: return not only(tz, aiclient) if debm in ['9-'+str(x) for x in range(153,163)]: return not only(tz, aiclient) if debm in ['9-'+str(x) for x in range(200,206)]: return not only(tz, aiclient) if debm in ['6-'+str(x) for x in range(23,36)]: return not only(tz, aiclient) if debm in ['6-'+str(x) for x in range(64,92)]: return not only(tz, aiclient) return False def buchong_cailiao(aiclient, debm, tz): if debm in ['6-'+str(x) for x in range(64,92)]: bh = '610000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出流量表的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:热式动力气体质量流量计 2、型号:50-5000Nm,141/h,PN1.6MPa 你应该返回 "热式动力气体质量流量计50-5000Nm,141/h,PN1.6MPa" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm in ['6-'+str(x) for x in range(23,36)]: bh = '610000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出压力表的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:压力表 2、型号:含表阀及弯管 3、规格:Y-100型,0-1.6MPa 你应该返回 "压力表Y-100型 含表阀及弯管" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm in ['9-'+str(x) for x in range(200,206)]: bh = '910000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出显示器、报警器、控制器的关键信息并返回。"+''' 例如,给定文字如下: 名称: 燃气声光报警器 你应该返回 "燃气声光报警器" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm in ['9-'+str(x) for x in range(153,163)]: bh = '910000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出探测器的关键信息并返回。"+''' 例如,给定文字如下: 名称:可燃气体探测器 你应该返回 "可燃气体探测器" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm in ['1-'+str(x) for x in range(684,702)]: bh = '110000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出轴流通风机的关键信息并返回。"+''' 例如,给定文字如下: 名称:侧墙轴流风机 你应该返回 "侧墙轴流风机" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm.startswith('4-918') or debm.startswith('4-919'): bh = '410000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出避雷网的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:防雷网 2、材质:镀锌扁钢 3、规格:25*4 你应该返回 "镀锌扁钢 25*4" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm.startswith('4-203') or debm.startswith('4-204') or debm.startswith('4-205') or debm.startswith('4-206'): bh = '410000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出始端箱(分线箱)的关键信息(电流容量)并返回。"+''' 例如,给定文字如下: 1、名称:母线槽始端箱(超高) 2. 型号2D 3. 容量(A):800A 你应该返回 "母线槽始端箱800A" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm.startswith('4-265'): bh = '410000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出控制箱的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:照明按钮控制箱 你应该返回 "照明按钮控制箱" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) if debm.startswith('4-266') or debm.startswith('4-267') or debm.startswith('4-268') or debm.startswith('4-269') or debm.startswith('4-230'): bh = '410000F' completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,请抽取出配电箱的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:配电箱 2、型号:L5A 3、规格:600*1500*400 4、基础形式、材质、规格:10#槽钢 5、安装方式:落地安装 6、电气元器件,模块按设计配置齐全 7、详见设计图纸,满足设计及规范要求 你应该返回 "配电箱L5A" 再例如,给定文字如下: 1、名称:消火栓泵配电柜XFX 2、型号:600*1500*400 4、基础形式、材质、规格:10#槽钢 5、安装方式:落地安装 6、电气元器件,模块按设计配置齐全 7、详见设计图纸,满足设计及规范要求 你应该返回 "消火栓泵配电柜XFX" 再例如,给定文字如下: 1、名称:配电箱C-AT 2、型号:非标,详见系统图 4、基础形式、材质、规格:10#槽钢 5、安装方式:落地安装 6、电气元器件,模块按设计配置齐全 7、详见设计图纸,满足设计及规范要求 你应该返回 "配电箱C-AT" ''' + '现在给定文字如下:'+tz+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) return {'CLBH': bh, 'CLMC': mc, 'JLDW': '台', 'YSJG': 0, 'SL': 1, 'HJ': 0} def tihuan(aiclient, old_name, tz): completion = aiclient.chat.completions.create( model="glm-4.5-air", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "给定一段文字,再给定一个材料,请抽取出该材料的关键信息并返回。"+''' 例如,给定文字如下: 1、名称:密集型铜母线(超高) 2、型号:XL-M-63A/5P 3、容量(A):63A 4、含配套支架 给定材料为 “母线槽 每相400A以下”, 你应该返回 “密集型铜母线XL-M-63A/5P” 再例如,给定文字如下: 1、名称:接地母线 2、材质:镀锌扁钢 3、规格:-40*4 给定材料为 “接地母线”, 你应该返回 “镀锌扁钢 40*4” 再例如,给定文字如下: 1、名称:消防电源通讯管理机 2、型号:配DPD信号 3、安装方式:落地安装 给定材料为 “槽钢”, 因为文字没有提及槽钢,所以你原封不动返回材料名,这里你应该返回“槽钢” ''' + '现在给定文字如下:'+tz+"\n给定材料为 "+old_name+"\n请返回结果"}, ], extra_body={"thinking": {"type": "disabled"}}, ) mc = completion.choices[0].message.content print(mc) return mc def buchong(aiclient, json_string, debm, tz): obj = json.loads(json_string) print(debm) if need_buchong(debm, tz, aiclient): obj['clde'].append(buchong_cailiao(aiclient, debm, tz)) for entry in obj['clde']: if entry['CLBH'].startswith('CL'): entry['CLMC']=tihuan(aiclient, entry['CLMC'], tz) return json.dumps(obj, ensure_ascii=False)