postprocess0104.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import json
  2. from config import simplemodel
  3. from template import xuanxiang
  4. def aifilter(A, #options
  5. B, #data
  6. aiclient, sfclient):
  7. options=[]
  8. letters = "ABCDEFGHIJKLMN"
  9. for i in range(len(A)):
  10. options.append("给定选项" + letters[i]+",内容为"+A[i])
  11. completion = aiclient.chat.completions.create(
  12. model="glm-4.5-flash",
  13. messages=[
  14. {"role": "system", "content": "You are a helpful assistant."},
  15. {"role": "user", "content": " 处理要求:如果工作内容中没有明确提出砌贴砖,则去掉含有“砌贴砖”字样的选项"},
  16. {"role": "user", "content": "问题描述: 给定一段工作内容: " + B['label'] + " " + B['mc'] + " " + B['tz'] + "," + ",".join(options) + "。请根据处理要求做出处理,并返回结果,删除选项必须对应到明确的特殊处理要求,不要擅自删除选项。例如,如果处理完后剩余A,B,C三个选项,请返回[A,B,C]"},
  17. ],
  18. extra_body={"thinking": {"type": "disabled"}},
  19. )
  20. json_string = completion.choices[0].message.content
  21. print(json_string)
  22. completion = sfclient.chat.completions.create(
  23. model=simplemodel(),
  24. messages=xuanxiang(json_string),
  25. extra_body={"thinking": {"type": "disabled"}},
  26. )
  27. json_string = completion.choices[0].message.content
  28. print(json_string)
  29. answer=[]
  30. if 'A' in json_string:
  31. answer.append(A[0])
  32. if 'B' in json_string:
  33. answer.append(A[1])
  34. if 'C' in json_string:
  35. answer.append(A[2])
  36. if 'D' in json_string:
  37. answer.append(A[3])
  38. if 'E' in json_string:
  39. answer.append(A[4])
  40. if 'F' in json_string:
  41. answer.append(A[5])
  42. if 'G' in json_string:
  43. answer.append(A[6])
  44. if 'H' in json_string:
  45. answer.append(A[7])
  46. return answer
  47. def postprocess0104(selected, data, aiclient, sfclient):
  48. return aifilter(selected, data, aiclient, sfclient)