fallback.py 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from menchuangfallback import menchuangfallback
  2. def fallback(A, B, aiclient, qwclient, menchuang_collection, model):
  3. if B['bianma'].startswith("0109"):
  4. if B['bianma'].startswith("010902") and '非固化' in B['tz'] and '沥青防水涂料' in B['tz']:##屋面防水
  5. return ['第十章 屋面及防水工程 10.2 平面立面及其它防水 10.2.1 涂刷油类 水泥基渗透结晶 防水材料 二~三遍(厚2mm)'] ##需要换
  6. if B['bianma'].startswith("010902") and '高聚物' in B['tz'] and '改性沥青防水涂料' in B['tz']:##屋面防水
  7. return ['第十章 屋面及防水工程 10.2 平面立面及其它防水 10.2.1 涂刷油类 水泥基渗透结晶 防水材料 二~三遍(厚2mm)'] ##需要换
  8. if B['bianma'].startswith("010904") and '高聚物' in B['tz'] and '改性沥青防水涂料' in B['tz']:##屋面防水
  9. return ['第十章 屋面及防水工程 10.2 平面立面及其它防水 10.2.1 涂刷油类 水泥基渗透结晶 防水材料 二~三遍(厚2mm)'] ##需要换
  10. if B['bianma'].startswith("010904") and '非固化' in B['tz'] and '沥青防水涂料' in B['tz']:##屋面防水
  11. return ['第十章 屋面及防水工程 10.2 平面立面及其它防水 10.2.1 涂刷油类 水泥基渗透结晶 防水材料 二~三遍(厚2mm)'] ##需要换
  12. #menchuangfallback(A, B, aiclient, qwclient, menchuang_collection, model)
  13. if B['bianma'].startswith("0110"):
  14. result = []
  15. if '界面剂' in B['tz']:##屋面防水
  16. result.append('第十四章 墙柱面工程 14.1 一般抹灰 14.1.3 保温砂浆及抗裂基层 刷界面剂 混凝土面') ##需要换
  17. if '玻纤网' in B['tz']:##屋面防水
  18. result.append('第十四章 墙柱面工程 14.1 一般抹灰 14.1.3 保温砂浆及抗裂基层 墙面耐碱玻纤网格布 一层') ##需要换
  19. if '第十四章 墙柱面工程 14.1 一般抹灰 14.1.3 保温砂浆及抗裂基层 墙面耐碱玻纤网格布 一层' in result and '第十四章 墙柱面工程 14.1 一般抹灰 14.1.3 保温砂浆及抗裂基层 抗裂砂浆抹面4mm (网格布)' not in result:
  20. result.append('第十四章 墙柱面工程 14.1 一般抹灰 14.1.3 保温砂浆及抗裂基层 抗裂砂浆抹面4mm (网格布)')
  21. return result ##需要换
  22. options=[]
  23. letters = "ABCDEFGHIJKLMN"
  24. for i in range(len(A)):
  25. options.append("给定定额选项" + letters[i]+",内容为"+A[i])
  26. completion = qwclient.chat.completions.create(
  27. model="Qwen/Qwen3-32B",
  28. messages=[
  29. {"role": "system", "content": "You are a helpful assistant."},
  30. {"role": "user", "content": "问题描述: 给定一条工程量清单: " + B['label'] + " " + B['mc'] + " " + B['tz'] + ",清单描述了包括一道或多道工序的工作内容" + ",".join(options) + "。请筛选出恰当的定额选项,使得定额选项匹配上清单所描述的工作内容。如果清单描述有多道工作内容,则你可能需要筛选出多个选项。选项中可能有意思相同或相近的选项,对于相同或相近的一组选项,你要挑选出其中最恰当的选项,排除掉其余的选项,以防止重复套定额。请返回一个数组。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  31. ],
  32. #extra_body={"thinking": {"type": "disabled"}},
  33. extra_body={"enable_thinking": False},
  34. )
  35. json_string = completion.choices[0].message.content
  36. print(json_string)
  37. completion = aiclient.chat.completions.create(
  38. model="glm-4.5-flash",
  39. messages=[
  40. {"role": "system", "content": "You are a helpful assistant.请将最终答案以JSON格式输出"},
  41. {"role": "user", "content": " 给你一段文字如下, " + json_string + ",其中给出了一个类似于[A,B,C]的数组作为答案,请将该最终答案输出"},
  42. ],
  43. extra_body={"thinking": {"type": "disabled"}},
  44. )
  45. json_string = completion.choices[0].message.content
  46. print(json_string)
  47. answer=[]
  48. if 'A' in json_string:
  49. answer.append(A[0])
  50. if 'B' in json_string:
  51. answer.append(A[1])
  52. if 'C' in json_string:
  53. answer.append(A[2])
  54. if 'D' in json_string:
  55. answer.append(A[3])
  56. if 'E' in json_string:
  57. answer.append(A[4])
  58. if 'F' in json_string:
  59. answer.append(A[5])
  60. if 'G' in json_string:
  61. answer.append(A[6])
  62. if 'H' in json_string:
  63. answer.append(A[7])
  64. if 'I' in json_string:
  65. answer.append(A[8])
  66. if 'J' in json_string:
  67. answer.append(A[9])
  68. return answer