import time
from fallback import fallback
from config import simplemodel
from template import xuanxiang
from fallback import fallback
zhijing=['百叶风口', '矩形送风口', '矩形空气分布器', '旋转吹风口' , '方形散流器', '圆形、流线型散流器', '送吸风口', '活动篦式风口', '网式风口', '钢百叶窗']
fengkou1=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 900', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 1280','第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 1800', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 2500', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 3300', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口周长(mm以内) 4200', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 5200', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 6400', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 7700', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 9000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 11000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 14000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 17000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 百叶风口(周长mm以内) 20000']
fengkou2=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形送风口周长(mm以内) 400', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形送风口周长(mm以内) 600', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形送风口周长(mm以内) 800']
fengkou3=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形空气分布器周长(mm以内) 1200', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形空气分布器周长(mm以内) 1500', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 矩形空气分布器周长(mm以内) 2100']
fengkou4=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 旋转吹风口直径(mm以内) 320', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 旋转吹风口直径(mm以内) 450']
fengkou5=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 方形散流器周长(mm以内) 500', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 方形散流器周长(mm以内) 1000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 方形散流器周长(mm以内) 2000']
fengkou6=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 圆形、流线形散流器直径(mm以内) 200', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 圆形、流线形散流器直径(mm以内) 360', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 圆形、流线形散流器直径(mm以内) 500']
fengkou7=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 送吸风口周长(mm以内) 1000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 送吸风口周长(mm以内) 1600', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 送吸风口周长(mm以内) 2000']
fengkou8=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 活动篦式风口周长(mm以内) 1330', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 活动篦式风口周长(mm以内) 1910', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 活动篦式风口周长(mm以内) 2590']
fengkou9=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 网式风口周长(mm以内) 900', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 网式风口周长(mm以内) 1500', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 网式风口周长(mm以内) 2000', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 网式风口周长(mm以内) 2600']
fengkou10=['第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 钢百叶窗 框内面积(m2以内) 0.5', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 钢百叶窗 框内面积(m2以内) 1.0', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 钢百叶窗 框内面积(m2以内) 2.0', '第七册 通风空调工程 第三章 通风管道部件制作安装 3.4 碳钢风口、散流器、百叶窗 3.4.2 碳钢风口、散流器、百叶窗安装 钢百叶窗 框内面积(m2以内) 4.0']
def select_fengkou10(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou10)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou10[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou10) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou10) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou10) > 2:
            answer.append('C')
        if 'D' in json_string and len(fengkou10) > 3:
            answer.append('D')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou10) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou10) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou10) > 2:
        answer.append('C')
    if 'D' in json_string and len(fengkou10) > 3:
        answer.append('D')
    
    return answer
def select_fengkou9(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou9)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou9[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou9) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou9) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou9) > 2:
            answer.append('C')
        if 'D' in json_string and len(fengkou9) > 3:
            answer.append('D')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou9) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou9) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou9) > 2:
        answer.append('C')
    if 'D' in json_string and len(fengkou9) > 3:
        answer.append('D')
    
    return answer
def select_fengkou8(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou8)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou8[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou8) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou8) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou8) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou8) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou8) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou8) > 2:
        answer.append('C')
    
    return answer
def select_fengkou7(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou7)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou7[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou7) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou7) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou7) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou7) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou7) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou7) > 2:
        answer.append('C')
    
    return answer
def select_fengkou6(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou6)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou6[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou6) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou6) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou6) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou6) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou6) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou6) > 2:
        answer.append('C')
    
    return answer
def select_fengkou5(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou5)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou5[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou5) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou5) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou5) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou5) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou5) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou5) > 2:
        answer.append('C')
    
    return answer
def select_fengkou4(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou4)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou4[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou4) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou4) > 1:
            answer.append('B')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou4) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou4) > 1:
        answer.append('B')
    
    return answer
def select_fengkou3(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou3)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou3[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou3) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou3) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou3) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou3) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou3) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou3) > 2:
        answer.append('C')
    
    return answer
def select_fengkou2(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou2)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou2[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou2) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou2) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou2) > 2:
            answer.append('C')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou2) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou2) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou2) > 2:
        answer.append('C')
    
    return answer
def select_fengkou1(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(fengkou1)):
        options.append("给定选项" + letters[i]+"，内容为"+fengkou1[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(fengkou1) > 0:
            answer.append('A')
        if 'B' in json_string and len(fengkou1) > 1:
            answer.append('B')
        if 'C' in json_string and len(fengkou1) > 2:
            answer.append('C')
        if 'D' in json_string and len(fengkou1) > 3:
            answer.append('D')
        if 'E' in json_string and len(fengkou1) > 4:
            answer.append('E')
        if 'F' in json_string and len(fengkou1) > 5:
            answer.append('F')
        if 'G' in json_string and len(fengkou1) > 6:
            answer.append('G')
        if 'H' in json_string and len(fengkou1) > 7:
            answer.append('H')
        if 'I' in json_string and len(fengkou1) > 8:
            answer.append('I')
        if 'J' in json_string and len(fengkou1) > 9:
            answer.append('J')
        if 'K' in json_string and len(fengkou1) > 10:
            answer.append('K')
        if 'L' in json_string and len(fengkou1) > 11:
            answer.append('L')
        if 'M' in json_string and len(fengkou1) > 12:
            answer.append('M')
        if 'N' in json_string and len(fengkou1) > 13:
            answer.append('N')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(fengkou1) > 0:
        answer.append('A')
    if 'B' in json_string and len(fengkou1) > 1:
        answer.append('B')
    if 'C' in json_string and len(fengkou1) > 2:
        answer.append('C')
    if 'D' in json_string and len(fengkou1) > 3:
        answer.append('D')
    if 'E' in json_string and len(fengkou1) > 4:
        answer.append('E')
    if 'F' in json_string and len(fengkou1) > 5:
        answer.append('F')
    if 'G' in json_string and len(fengkou1) > 6:
        answer.append('G')
    if 'H' in json_string and len(fengkou1) > 7:
        answer.append('H')
    if 'I' in json_string and len(fengkou1) > 8:
        answer.append('I')
    if 'J' in json_string and len(fengkou1) > 9:
        answer.append('J')
    if 'K' in json_string and len(fengkou1) > 10:
        answer.append('K')
    if 'L' in json_string and len(fengkou1) > 11:
        answer.append('L')
    if 'M' in json_string and len(fengkou1) > 12:
        answer.append('M')
    if 'N' in json_string and len(fengkou1) > 13:
        answer.append('N')
    
    return answer
def select_fengkou(
       B, #data
       aiclient,
             qwclient,
              sfclient,
             dw):
    options=[]
    letters = "ABCDEFGHIJKLMN"
    for i in range(len(zhijing)):
        options.append("给定选项" + letters[i]+"，内容为"+zhijing[i] )

    completion = aiclient.chat.completions.create(
        model="glm-4.5-air",
        #model="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"role": "user", "content": "问题描述： 给定一段工作内容: " + B['label'] + " " +  B['mc'] + " " + B['tz'] +  "，".join(options) + "。请选择最合适的选项，并返回字母代号，例如，返回 A"},
        ],
        extra_body={"thinking": {"type": "disabled"}},
        #extra_body={"enable_thinking": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(zhijing) > 0:
            answer.append('A')
        if 'B' in json_string and len(zhijing) > 1:
            answer.append('B')
        if 'C' in json_string and len(zhijing) > 2:
            answer.append('C')
        if 'D' in json_string and len(zhijing) > 3:
            answer.append('D')
        if 'E' in json_string and len(zhijing) > 4:
            answer.append('E')
        if 'F' in json_string and len(zhijing) > 5:
            answer.append('F')
        if 'G' in json_string and len(zhijing) > 6:
            answer.append('G')
        if 'H' in json_string and len(zhijing) > 7:
            answer.append('H')
        if 'I' in json_string and len(zhijing) > 8:
            answer.append('I')
        if 'J' in json_string and len(zhijing) > 9:
            answer.append('J')
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(zhijing) > 0:
        answer.append('A')
    if 'B' in json_string and len(zhijing) > 1:
        answer.append('B')
    if 'C' in json_string and len(zhijing) > 2:
        answer.append('C')
    if 'D' in json_string and len(zhijing) > 3:
        answer.append('D')
    if 'E' in json_string and len(zhijing) > 4:
        answer.append('E')
    if 'F' in json_string and len(zhijing) > 5:
        answer.append('F')
    if 'G' in json_string and len(zhijing) > 6:
        answer.append('G')
    if 'H' in json_string and len(zhijing) > 7:
        answer.append('H')
    if 'I' in json_string and len(zhijing) > 8:
        answer.append('I')
    if 'J' in json_string and len(zhijing) > 9:
        answer.append('J')
    
    return answer
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="THUDM/GLM-Z1-9B-0414",
        #model="ernie-speed-128k",
        messages=[
            {"role": "system", "content": "You are a helpful assistant."},
            {"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": True},
        #stream=True
    )
    json_string = completion.choices[0].message.content
    print(json_string)
    if len([x for x in json_string if x != ',' and x != '[' and x != ']' and x != ' ' and (x < 'A' or x > 'M')]) < 5:
        answer=[]
        if 'A' in json_string and len(A) > 0:
            answer.append(A[0])
        if 'B' in json_string and len(A) > 1:
            answer.append(A[1])
        if 'C' in json_string and len(A) > 2:
            answer.append(A[2])
        if 'D' in json_string and len(A) > 3:
            answer.append(A[3])
        if 'E' in json_string and len(A) > 4:
            answer.append(A[4])
        if 'F' in json_string and len(A) > 5:
            answer.append(A[5])
        if 'G' in json_string and len(A) > 6:
            answer.append(A[6])
        if 'H' in json_string and len(A) > 7:
            answer.append(A[7])
        if 'I' in json_string and len(A) > 8:
            answer.append(A[8])
        if 'J' in json_string and len(A) > 9:
            answer.append(A[9])
        return answer
    completion = sfclient.chat.completions.create(
        #model="glm-4.5-flash",
        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 and len(A) > 0:
        answer.append(A[0])
    if 'B' in json_string and len(A) > 1:
        answer.append(A[1])
    if 'C' in json_string and len(A) > 2:
        answer.append(A[2])
    if 'D' in json_string and len(A) > 3:
        answer.append(A[3])
    if 'E' in json_string and len(A) > 4:
        answer.append(A[4])
    if 'F' in json_string and len(A) > 5:
        answer.append(A[5])
    if 'G' in json_string and len(A) > 6:
        answer.append(A[6])
    if 'H' in json_string and len(A) > 7:
        answer.append(A[7])
    if 'I' in json_string and len(A) > 8:
        answer.append(A[8])
    if 'J' in json_string and len(A) > 9:
        answer.append(A[9])
    return answer

def postprocess0307(selected, data, aiclient, qwclient, sfclient, label_name, name_dw, candidates):
    prime = aifilter1(selected, data, aiclient, qwclient, sfclient, name_dw)
    if len([x for x in prime if '风口' in x]) > 0:
        if data['dw'] == '个':
            prime = [x for x in prime if '风口' not in x]
            t = select_fengkou(data, aiclient, qwclient, sfclient, name_dw)
            if 'A' in t:
                t = select_fengkou1(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou1[0])
                if 'B' in t:
                    prime.append(fengkou1[1])
                if 'C' in t:
                    prime.append(fengkou1[2])
                if 'D' in t:
                    prime.append(fengkou1[3])
                if 'E' in t:
                    prime.append(fengkou1[4])
                if 'F' in t:
                    prime.append(fengkou1[5])
                if 'G' in t:
                    prime.append(fengkou1[6])
                if 'H' in t:
                    prime.append(fengkou1[7])
                if 'I' in t:
                    prime.append(fengkou1[8])
                if 'J' in t:
                    prime.append(fengkou1[9])
                if 'K' in t:
                    prime.append(fengkou1[10])
                if 'L' in t:
                    prime.append(fengkou1[11])
                if 'M' in t:
                    prime.append(fengkou1[12])
                if 'N' in t:
                    prime.append(fengkou1[13])

            elif 'B' in t:
                t = select_fengkou2(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou2[0])
                if 'B' in t:
                    prime.append(fengkou2[1])
                if 'C' in t:
                    prime.append(fengkou2[2])
            elif 'C' in t:
                t = select_fengkou3(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou3[0])
                if 'B' in t:
                    prime.append(fengkou3[1])
                if 'C' in t:
                    prime.append(fengkou3[2])
            elif 'D' in t:
                t = select_fengkou4(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou4[0])
                if 'B' in t:
                    prime.append(fengkou4[1])
            elif 'E' in t:
                t = select_fengkou5(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou5[0])
                if 'B' in t:
                    prime.append(fengkou5[1])
                if 'C' in t:
                    prime.append(fengkou5[2])
            elif 'F' in t:
                t = select_fengkou6(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou6[0])
                if 'B' in t:
                    prime.append(fengkou6[1])
                if 'C' in t:
                    prime.append(fengkou6[2])
            elif 'G' in t:
                t = select_fengkou7(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou7[0])
                if 'B' in t:
                    prime.append(fengkou7[1])
                if 'C' in t:
                    prime.append(fengkou7[2])
            elif 'H' in t:
                t = select_fengkou8(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou8[0])
                if 'B' in t:
                    prime.append(fengkou8[1])
                if 'C' in t:
                    prime.append(fengkou8[2])
            elif 'I' in t:
                t = select_fengkou9(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou9[0])
                if 'B' in t:
                    prime.append(fengkou9[1])
                if 'C' in t:
                    prime.append(fengkou9[2])
                if 'D' in t:
                    prime.append(fengkou9[3])
            elif 'J' in t:
                t = select_fengkou10(data, aiclient, qwclient, sfclient, name_dw)
                if 'A' in t:
                    prime.append(fengkou10[0])
                if 'B' in t:
                    prime.append(fengkou10[1])
                if 'C' in t:
                    prime.append(fengkou10[2])
                if 'D' in t:
                    prime.append(fengkou10[3])



    return prime
