prompt_example.txt 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. 示例:
  2. 规则集名称:通用规则
  3. 规则集默认输出:-1
  4. 规则集:
  5. 规则1: 变量:年龄 age 逻辑:年龄小于18或大于等于65 输出:1 结果备注: 1代表好
  6. 规则2: 变量:欠税总额 qsze 逻辑:欠税总额大于500 输出:3 结果备注: 3代表一般
  7. 规则3: 变量:非银行机构未结清贷款机构数 fyjgwjqs 逻辑:非银行机构未结清贷款机构数大于10 输出:2
  8. 输出:
  9. def handle_general_rules(data:dict):
  10. # 通用规则
  11. # 输出结果备注:
  12. # 1代表好
  13. # 3代表一般
  14. age = data.get("age")
  15. qsze = data.get("qsze")
  16. fyjgwjqs = data.get("fyjgwjqs")
  17. if age is not None:
  18. if age < 18 or age >= 65:
  19. return 1
  20. if qsze is not None:
  21. if qsze > 500:
  22. return 3
  23. if fyjgwjqs is not None:
  24. if fyjgwjqs > 10:
  25. return 2
  26. return -1
  27. ```
  28. 待处理规则:
  29. 规则集名称:极优质客户
  30. 规则集默认输出:接受
  31. 规则集:
  32. 规则1: 变量:年龄 age 性别 sex 逻辑:男性客户年龄小于22岁或大于60岁,普通女性客户小于22岁或大于55岁 输出:拒绝 变量备注: 性别为男或者女
  33. 规则2: 变量:是否本行关系人 sfbhgxr 逻辑:sfbhgxr=1 输出:拒绝
  34. 规则3: 变量:配偶在黑名单中 pozhmdz 逻辑:pozhmdz=1 输出:拒绝
  35. 规则4: 变量:行内审慎客户 hnsskh 逻辑:hnsskh=1 输出:拒绝
  36. 规则5: 变量:呆账信息汇总、资产处置信息汇总、保证人代偿信息汇总数据中有记录的 ydzhzccz 逻辑:ydzhzccz=1 输出:拒绝
  37. 规则6: 变量:资产处置信息余额的zcczye 逻辑:zcczye>0 输出:拒绝
  38. 规则7: 变量:保证人代偿信息余额的 bzrdcye 逻辑:bzrdcye>0 输出:拒绝
  39. 规则8: 变量:呆账贷记卡是记录dzdjkjl_cnt 逻辑:dzdjkjl_cnt>0 输出:拒绝
  40. 规则9: 变量:对外担保信息中担保贷款五级分类 dbxxwjfl 逻辑:对外担保信息中担保贷款五级分类是“次级”或“可疑”或“损失” 输出:拒绝
  41. 规则10: 变量:当前逾期金额 dqyqje 逻辑:dqyqje>0 输出:拒绝
  42. 规则11: 变量:客户存在公安负面信息 gafmxx_cnt 逻辑:gafmxx_cnt>0 输出:拒绝
  43. 规则12: 变量:客户存在失信被执行人信息 ssxrzxxx_cnt 逻辑:ssxrzxxx_cnt>0 输出:拒绝
  44. 规则13: 变量:公积金缴至年月距申请时的月份数gjjjfyffs 逻辑:公积金缴至年月距申请时的月份数大于3 输出:拒绝
  45. 规则14: 变量:公积金近1年累计缴纳次数 gjjjncs_l122m 逻辑:公积金近1年累计缴纳次数小于6 输出:拒绝
  46. 规则15: 变量:贷记卡最近24个月的还款记录中逾期天数 djkyqts_l24m 逾期金额 yqje 逻辑:贷记卡或贷记卡最近24个月的还款记录中逾期天数(3-7、D、Z、G字符)且逾期金额500元以上 输出:拒绝
  47. 规则16: 变量:借款人最近24个月最大连续逾期期数jkrzdlxyqqs_l24m 累计逾期次数 ljyqqs 逻辑:借款人最近24个月最大连续逾期期数>3或累计逾期次数>6 输出:拒绝
  48. 规则17: 变量:非银行机构未结清贷款笔数 fyjgwjqdkbs 逻辑:非银行机构未结清贷款笔数>=3 输出:拒绝
  49. 规则18: 变量:近一个月非本行审批查询机构数 fbhspcxs_l1m 近3个月非本月审批查询机构数 fbhspcxs_l3m 近6个月非本行审批查询机构数 fbhspcxs_l6m 逻辑:近一个月非本行审批查询机构数>3或近3个月非本月审批查询机构数>5或近6个月非本行审批查询机构数>8 输出:拒绝
  50. 规则19: 变量:一代模型评分 ydmxpf 逻辑:一代模型评分>0.766 输出:拒绝
  51. 请根据```内的示例以及待处理规则中的变量、计算逻辑及输出,用Python语言生成功能函数代码。
  52. 返回结果要求:
  53. 1、只返回功能函数代码,不要多余的输出。
  54. 2、代码逻辑应严格按照待处理要求中的条件,不要自行添加多余的逻辑。
  55. 3、代码的语法要符合python的语法规范,返回的代码应该是可执行的。
  56. 4、规则里有 结果备注 的请在函数中的 输出结果备注 处进行备注,没有的则无输出结果备注
  57. # 角色
  58. 你是一个专业的Python代码生成器,能够根据给定的流程图和函数内容,用Python语言生成完整的流程执行代码。
  59. 给定的函数内容:
  60. def handle_general_rules(data:dict):
  61. # 通用规则
  62. # 输出结果备注:
  63. # 0代表拒绝,1代表接受
  64. sex = data.get("sex")
  65. age = data.get("age")
  66. pboc_score = data.get("pboc_score")
  67. incomeM = data.get("incomeM")
  68. qzzxbjz = data.get("qzzxbjz")
  69. yzxbje = data.get("yzxbje")
  70. wjqxedkbss = data.get("wjqxedkbss")
  71. xedkjgs = data.get("xedkjgs")
  72. if sex is not None and age is not None:
  73. if (sex == "男" and (22 <= age <= 60)) or (sex == "女" and (22 <= age <= 55)):
  74. return 1
  75. if pboc_score is not None:
  76. if pboc_score > 0.523:
  77. return 0
  78. if incomeM is not None:
  79. if incomeM < 2000:
  80. return 0
  81. if qzzxbjz is not None and yzxbje is not None:
  82. if (qzzxbjz - yzxbje) > 20000:
  83. return 0
  84. if wjqxedkbss is not None or xedkjgs is not None:
  85. if (wjqxedkbss is not None and wjqxedkbss > 4) or (xedkjgs is not None and xedkjgs > 2):
  86. return 0
  87. return 1.0
  88. def handle_kequn_rules(data:dict):
  89. # 客群规则
  90. # 输出结果备注:
  91. # 公积金单位较优客户
  92. # 金融资产较优客户
  93. # 房贷客户
  94. gjjdwlx = data.get("gjjdwlx")
  95. sex = data.get("sex")
  96. age = data.get("age")
  97. gjjkhsj = data.get("gjjkhsj")
  98. gjjjncs_l12m = data.get("gjjjncs_l12m")
  99. nrjjrzc = data.get("nrjjrzc")
  100. rjzc_l3m = data.get("rjzc_l3m")
  101. whkkhsj = data.get("whkkhsj")
  102. xymxpf = data.get("xymxpf")
  103. wjqfdyyhke = data.get("wjqfdyyhke")
  104. yhkqs = data.get("yhkqs")
  105. zcyqts = data.get("zcyqts")
  106. yqcs_l24m = data.get("yqcs_l24m")
  107. if gjjdwlx is not None and sex is not None and age is not None and gjjkhsj is not None and gjjjncs_l12m is not None:
  108. if (gjjdwlx in ("国家机关", "事业单位", "国企", "医院") and
  109. ((sex == "男" and 22 <= age <= 60) or (sex == "女" and 22 <= age <= 55)) and
  110. gjjkhsj >= 1 and gjjjncs_l12m >= 6):
  111. return "公积金单位较优客户"
  112. if nrjjrzc is not None and rjzc_l3m is not None and whkkhsj is not None and xymxpf is not None:
  113. if (nrjjrzc > 10 and rjzc_l3m >= 1 and whkkhsj >= 1 and
  114. (xymxpf > 0.397 or xymxpf == -1)):
  115. return "金融资产较优客户"
  116. if wjqfdyyhke is not None and yhkqs is not None and zcyqts is not None and yqcs_l24m is not None:
  117. if ((wjqfdyyhke > 4000 and yhkqs > 12 and yqcs_l24m <= 2 and zcyqts <= 30) or
  118. (0 < wjqfdyyhke <= 4000 and yhkqs > 24 and yqcs_l24m <= 2 and zcyqts <= 30)):
  119. return "房贷客户"
  120. return "其它"
  121. def handle_extremely_high_quality_customer_rules(data:dict):
  122. # 极优质客户规则
  123. # 输出结果备注:
  124. age = data.get("age")
  125. sex = data.get("sex")
  126. sfbhgxr = data.get("sfbhgxr")
  127. pozhmdz = data.get("pozhmdz")
  128. hnsskh = data.get("hnsskh")
  129. ydzhzccz = data.get("ydzhzccz")
  130. zcczye = data.get("zcczye")
  131. bzrdcye = data.get("bzrdcye")
  132. dzdjkjl_cnt = data.get("dzdjkjl_cnt")
  133. dbxxwjfl = data.get("dbxxwjfl")
  134. dqyqje = data.get("dqyqje")
  135. gafmxx_cnt = data.get("gafmxx_cnt")
  136. ssxrzxxx_cnt = data.get("ssxrzxxx_cnt")
  137. gjjjfyffs = data.get("gjjjfyffs")
  138. gjjjncs_l122m = data.get("gjjjncs_l122m")
  139. djkyqts_l24m = data.get("djkyqts_l24m")
  140. yqje = data.get("yqje")
  141. jkrzdlxyqqs_l24m = data.get("jkrzdlxyqqs_l24m")
  142. ljyqqs = data.get("ljyqqs")
  143. fyjgwjqdkbs = data.get("fyjgwjqdkbs")
  144. fbhspcxs_l1m = data.get("fbhspcxs_l1m")
  145. fbhspcxs_l3m = data.get("fbhspcxs_l3m")
  146. fbhspcxs_l6m = data.get("fbhspcxs_l6m")
  147. ydmxpf = data.get("ydmxpf")
  148. if age is not None and sex is not None:
  149. if (sex == "男" and (age < 22 or age > 60)) or (sex == "女" and (age < 22 or age > 55)):
  150. return "拒绝"
  151. if sfbhgxr is not None:
  152. if sfbhgxr == 1:
  153. return "拒绝"
  154. if pozhmdz is not None:
  155. if pozhmdz == 1:
  156. return "拒绝"
  157. if hnsskh is not None:
  158. if hnsskh == 1:
  159. return "拒绝"
  160. if ydzhzccz is not None:
  161. if ydzhzccz == 1:
  162. return "拒绝"
  163. if zcczye is not None:
  164. if zcczye > 0:
  165. return "拒绝"
  166. if bzrdcye is not None:
  167. if bzrdcye > 0:
  168. return "拒绝"
  169. if dzdjkjl_cnt is not None:
  170. if dzdjkjl_cnt > 0:
  171. return "拒绝"
  172. if dbxxwjfl is not None:
  173. if dbxxwjfl in ["次级", "可疑", "损失"]:
  174. return "拒绝"
  175. if dqyqje is not None:
  176. if dqyqje > 0:
  177. return "拒绝"
  178. if gafmxx_cnt is not None:
  179. if gafmxx_cnt > 0:
  180. return "拒绝"
  181. if ssxrzxxx_cnt is not None:
  182. if ssxrzxxx_cnt > 0:
  183. return "拒绝"
  184. if gjjjfyffs is not None:
  185. if gjjjfyffs > 3:
  186. return "拒绝"
  187. if gjjjncs_l122m is not None:
  188. if gjjjncs_l122m < 6:
  189. return "拒绝"
  190. if djkyqts_l24m is not None and yqje is not None:
  191. if (djkyqts_l24m in ["3", "4", "5", "6", "7", "D", "Z", "G"] and yqje > 500):
  192. return "拒绝"
  193. if jkrzdlxyqqs_l24m is not None and ljyqqs is not None:
  194. if jkrzdlxyqqs_l24m > 3 or ljyqqs > 6:
  195. return "拒绝"
  196. if fyjgwjqdkbs is not None:
  197. if fyjgwjqdkbs >= 3:
  198. return "拒绝"
  199. if fbhspcxs_l1m is not None and fbhspcxs_l3m is not None and fbhspcxs_l6m is not None:
  200. if fbhspcxs_l1m > 3 or fbhspcxs_l3m > 5 or fbhspcxs_l6m > 8:
  201. return "拒绝"
  202. if ydmxpf is not None:
  203. if ydmxpf > 0.766:
  204. return "拒绝"
  205. return "接受"
  206. def handle_important_customer_rules(data:dict):
  207. # 要客规则
  208. # 输出结果备注: 无
  209. bhgxr = data.get("bhgxr")
  210. dqyqje = data.get("dqyqje")
  211. wbhdkhxykyqye = data.get("wbhdkhxykyqye")
  212. if bhgxr is not None:
  213. if bhgxr == 1:
  214. return "拒绝"
  215. if dqyqje is not None:
  216. if dqyqje > 0:
  217. return "拒绝"
  218. if wbhdkhxykyqye is not None:
  219. if wbhdkhxykyqye == 1:
  220. return "拒绝"
  221. return "拒绝"
  222. def handle_gov_vip_rules(data:dict):
  223. # 是否要客
  224. # 输出结果备注:
  225. # 1代表是要客
  226. # 0代表不是要客
  227. GovVip = data.get("GovVip")
  228. if GovVip is not None:
  229. if GovVip == 1:
  230. return 1
  231. elif GovVip == 0:
  232. return 0
  233. return 0.0
  234. def handle_high_quality_customer_credit(data:dict):
  235. # 极优质客户额度
  236. # 输出结果备注: 无
  237. dwlx = data.get("dwlx")
  238. incomeM = data.get("incomeM")
  239. if dwlx is not None and incomeM is not None:
  240. if dwlx == "国家机关" and 0 < incomeM < 5000:
  241. return 60000
  242. if dwlx == "国家机关" and 5000 <= incomeM < 12000:
  243. return 180000
  244. if dwlx == "国家机关" and 12000 <= incomeM < 15000:
  245. return 250000
  246. if dwlx == "国家机关" and incomeM > 15000:
  247. return 300000
  248. if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and 0 < incomeM < 6000:
  249. return 50000
  250. if dwlx == "国家机关" and 6000 <= incomeM < 14000:
  251. return 150000
  252. if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and 14000 <= incomeM < 16000:
  253. return 220000
  254. if (dwlx == "三甲医院" or dwlx == "优质学校" or dwlx == "国网") and incomeM > 16000:
  255. return 300000
  256. return 0.0
  257. def handle_customer_credit(data:dict):
  258. # 客群额度
  259. # 输出结果备注: 无
  260. kqlx = data.get("kqlx")
  261. incomeM = data.get("incomeM")
  262. if kqlx is not None and incomeM is not None:
  263. if kqlx == "公积金单位较优客户":
  264. if 0 < incomeM < 5000:
  265. return 60000
  266. elif 5000 <= incomeM < 12000:
  267. return 180000
  268. elif 12000 <= incomeM < 15000:
  269. return 250000
  270. elif incomeM > 15000:
  271. return 300000
  272. elif kqlx == "房贷客户":
  273. if 0 < incomeM < 6000:
  274. return 50000
  275. elif 6000 <= incomeM < 14000:
  276. return 150000
  277. elif 14000 <= incomeM < 16000:
  278. return 220000
  279. elif incomeM > 16000:
  280. return 300000
  281. return 0.0
  282. 函数与节点对应关系:
  283. 通用规则: handle_general_rules
  284. 客群规则: handle_kequn_rules
  285. 极优质客户: handle_extremely_high_quality_customer_rules
  286. 要客规则: handle_important_customer_rules
  287. 是否要客: handle_gov_vip_rules
  288. 极优质客户额度: handle_high_quality_customer_credit
  289. 客群额度: handle_customer_credit
  290. 流程描述:
  291. ```
  292. 开始 --> [是否要客: 1] --> 要客规则 --> 结束
  293. 开始 --> [是否要客: 0] --> 极优质客户
  294. [极优质客户: 拒绝] --> 通用规则
  295. [极优质客户: 接受] --> 极优质客户额度 --> 结束
  296. [通用规则: 0] --> 结束
  297. [通用规则: 1] --> 客群规则 --> 客群额度 --> 结束
  298. ```
  299. 流程描述说明:
  300. 1、[满足条件: *] 为判断上一个节点的输出是否符合条件
  301. 请把```括号内的流程描述的内容转换为python代码,流程中的各个节点参考给定的函数内容与函数与节点对应关系,并构造测试数据data,代码样式如下。
  302. from handle_general_rules import handle_general_rules
  303. from handle_kequn_rules import handle_kequn_rules
  304. from handle_extremely_high_quality_customer_rules import handle_extremely_high_quality_customer_rules
  305. from handle_important_customer_rules import handle_important_customer_rules
  306. from handle_gov_vip_rules import handle_gov_vip_rules
  307. from handle_high_quality_customer_credit import handle_high_quality_customer_credit
  308. from handle_customer_credit import handle_customer_credit
  309. def main(data: dict):
  310. 流程逻辑
  311. if __name__ == "__main__":
  312. data = 测试数据
  313. print(main(data))
  314. 返回结果要求:
  315. 1、针对流程分支情况请参考给定的函数内容及函数的输出结果备注。
  316. 2、开始节点与结束节点,无实际意义,结束节点直接返回其上一个节点输出的结果。
  317. 3、只返回函数代码,不要多余的输出。
  318. 4、代码逻辑应严格按照流程描述中的逻辑,不要自行添加多余的逻辑。
  319. 5、代码的语法要符合python的语法规范,返回的代码应该是可执行的。