| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- from template import xuanxiang
- from config import simplemodel
- tuliaos=[
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 薄型 0.5小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 薄型 1小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 薄型 1.5小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 薄型 2小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 厚型 2小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 厚型 2.5小时',
- '第十七章 油漆、涂料、裱糊工程 17.1 油漆、涂料 17.1.2 金属面油漆 17.1.2.3 防火涂料 金属面防火涂料 厚型 3小时',
- ]
- tuliao_options=[]
- tuliao_letters='ABCDEFG'
- for i in range(len(tuliaos)):
- tuliao_options.append('给定选项'+tuliao_letters[i]+', 内容为' + tuliaos[i])
- import json
- with open('nantong_rule', 'r') as f:
- content = f.read()
- import json
- obj=json.loads(content)
- from fallback import fallback
- def aifilter1(A, #options
- B, #data
- aiclient,
- qwclient,
- sfclient,
- dw):
- options=[]
- letters = "ABCDEFGHIJKLMN"
- for i in range(len(A)):
- options.append("给定选项" + letters[i]+",内容为"+A[i] )
- completion = aiclient.chat.completions.create(
- model="glm-4.5-air",
- #model="Qwen/Qwen3-14B",
- messages=[
- {"role": "system", "content": "You are a helpful assistant."},
- {"role": "user", "content": " 特殊处理要求:去掉所有含有“五金配件”字样的选项"},
- {"role": "user", "content": " 特殊处理要求:去掉所有含有“金属面油漆”字样的选项"},
- {"role": "user", "content": " 重要提示:选项指的是给定的A、B、C之类的选项,不是指的工作内容中的可能的1、2、3这样罗列的特征"},
- {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
- {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果,删除选项必须对应到明确的特殊处理要求,不要擅自删除选项。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
- ],
- extra_body={"thinking": {"type": "disabled"}},
- #extra_body={"enable_thinking": False},
- )
- json_string = completion.choices[0].message.content
- print(json_string)
- completion = sfclient.chat.completions.create(
- model=simplemodel(),
- messages=xuanxiang(json_string),
- extra_body={"thinking": {"type": "disabled"}},
- #extra_body={"enable_thinking": False},
- )
- json_string = completion.choices[0].message.content
- print(json_string)
- answer=[]
- if 'A' in json_string:
- answer.append(A[0])
- if 'B' in json_string:
- answer.append(A[1])
- if 'C' in json_string:
- answer.append(A[2])
- if 'D' in json_string:
- answer.append(A[3])
- if 'E' in json_string:
- answer.append(A[4])
- if 'F' in json_string:
- answer.append(A[5])
- if 'G' in json_string:
- answer.append(A[6])
- if 'H' in json_string:
- answer.append(A[7])
- if 'I' in json_string:
- answer.append(A[8])
- if 'J' in json_string:
- answer.append(A[9])
- return answer
- def aifilter2(A, #options
- B, #data
- aiclient,
- qwclient,
- sfclient,
- dw):
- options=[]
- letters = "ABCDEFGHIJKLMN"
- for i in range(len(A)):
- options.append("给定选项" + letters[i]+",内容为"+A[i] )
- completion = aiclient.chat.completions.create(
- model="glm-4.5-air",
- #model="Qwen/Qwen3-14B",
- messages=[
- {"role": "system", "content": "You are a helpful assistant."},
- {"role": "user", "content": " 特殊处理要求:如果工作内容的描述没有明确提及无框,则去掉含有“无框”字样的选项"},
- {"role": "user", "content": " 特殊处理要求:防火门与放火卷帘门是完全不同的产品。如果工作内容的描述没有明确提及防火卷帘门,则去掉防火卷帘门的选项"},
- {"role": "user", "content": " 特殊处理要求:防火门与铝合金门是完全不同的产品。如果工作内容的描述是防火门,则去掉铝合金门的选项"},
- {"role": "user", "content": " 重要提示:除特殊处理要求提及的内容外,不需考虑选项内容与工作内容是否符合,只需要根据特殊处理要求做出处理"},
- {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",".join(options) + "。请根据处理要求做出处理,并返回结果,删除选项必须对应到明确的特殊处理要求,不要擅自删除选项。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
- ],
- extra_body={"thinking": {"type": "disabled"}},
- #extra_body={"enable_thinking": False},
- )
- json_string = completion.choices[0].message.content
- print(json_string)
- if len(json_string) < 4:
-
- answer=[]
- if 'A' in json_string:
- answer.append(A[0])
- if 'B' in json_string:
- answer.append(A[1])
- if 'C' in json_string:
- answer.append(A[2])
- if 'D' in json_string:
- answer.append(A[3])
- if 'E' in json_string:
- answer.append(A[4])
- if 'F' in json_string:
- answer.append(A[5])
- if 'G' in json_string:
- answer.append(A[6])
- if 'H' in json_string:
- answer.append(A[7])
- if 'I' in json_string:
- answer.append(A[8])
- if 'J' in json_string:
- answer.append(A[9])
-
-
- return answer
- completion = sfclient.chat.completions.create(
- model=simplemodel(),
- messages=xuanxiang(json_string),
- extra_body={"thinking": {"type": "disabled"}},
- #extra_body={"enable_thinking": False},
- )
- json_string = completion.choices[0].message.content
- print(json_string)
- answer=[]
- if 'A' in json_string:
- answer.append(A[0])
- if 'B' in json_string:
- answer.append(A[1])
- if 'C' in json_string:
- answer.append(A[2])
- if 'D' in json_string:
- answer.append(A[3])
- if 'E' in json_string:
- answer.append(A[4])
- if 'F' in json_string:
- answer.append(A[5])
- if 'G' in json_string:
- answer.append(A[6])
- if 'H' in json_string:
- answer.append(A[7])
- if 'I' in json_string:
- answer.append(A[8])
- if 'J' in json_string:
- answer.append(A[9])
- return answer
- def postprocess0108(selected, data, aiclient, qwclient, sfclient, label_name, name_dw):
- prime = aifilter1(selected, data, aiclient, qwclient, sfclient, name_dw)
- if len(prime) == 0:
- return []
-
- prime = aifilter2(prime, data, aiclient, qwclient, sfclient, name_dw)
- if len(prime) == 0:
- return []
- return selected
|