fallback.py 4.4 KB

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