import re with open('gangjiegouhuansuan','r') as f: content = f.read() import json obj = json.loads(content) options=[] for i in range(len(obj['mc'])): options.append('给定选项A'+str(i)+', 内容为'+obj['mc'][i]) options = ','.join(options) def callzaihuansuan0106_0(bianma, label, A,B,C, aiclient, qwclient):##C->tz completion = aiclient.chat.completions.create( model="glm-4.5-flash", messages=[ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "问题描述: 给定一段工作内容描述,内容为" + C + "," + options + ",请选出最匹配工作内容的选项并输出。例如如果你觉得A11选项最匹配,请输出A11"}, ], extra_body={"thinking": {"type": "disabled"}}, ) json_string = completion.choices[0].message.content print(json_string) if len(json_string) < 4: return json_string completion = aiclient.chat.completions.create( model="glm-4.5-flash", messages=[ {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"}, {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一个类似于A10的表达式作为结果,请将该最终结果输出"}, ], extra_body={"thinking": {"type": "disabled"}}, ) json_string = completion.choices[0].message.content print(json_string) lines = json_string.split('\n') lines = [x for x in lines if ':' in x] line = lines[0].split(':')[1] line = line.replace('\'', '') line = line.replace('\"', '') matched_letters = re.findall(r'[a-zA-Z0-9]', line) return ''.join(matched_letters) def callzaihuansuan0106_1(bianma, label, A,B,C, aiclient, qwclient):##C->tz t = callzaihuansuan0106_0(bianma, label, A,B,C, aiclient, qwclient) t=t.replace('A', '') t = int(t) t = obj['alpha'][t] return "{" + "\n" + "answer: A=" + str(t) + "*B\n}" def callzaihuansuan0106_2(bianma, label, A,B,C, aiclient, qwclient):##C->tz t = callzaihuansuan0106_0(bianma, label, A,B,C, aiclient, qwclient) t=t.replace('A', '') t = int(t) t = obj['alpha'][t]/10 return "{" + "\n" + "answer: A=" + str(t) + "*B\n}" def callzaihuansuan0106_3(bianma, label, A,B,C, aiclient, qwclient):##C->tz t = callzaihuansuan0106_0(bianma, label, A,B,C, aiclient, qwclient) t=t.replace('A', '') t = int(t) t = obj['alpha'][t]/100 return "{" + "\n" + "answer: A=" + str(t) + "*B\n}"