b1fb5aa
LMonan 3 years ago
3 changed file(s) with 45 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
00 input:
11 things:
2 name: things
2 name: wish
33 value_type: str
44 description: ''
55 pray:
0 from yi import YiProgram
1
02 def handle(conf):
13 """
24 该方法是部署之后,其他人调用你的服务时候的处理方法。
79 参数请放到params字典中,我们会自动解析该变量。
810 """
911
10 wish = conf['things'] # value_type: str # description: some description
12 wish = conf['wish'] # value_type: str # description: some description
1113 pray = conf['pray']
1214
15 obj = YiProgram()
16 turn_symbol_desc, main_indicate, support_indicate = obj.predict(wish, pray)
17
1318 # add your code
14 return {'ret1': 'cat', 'ret2': 'dog'}
19 return {
20 'turn_symbol_desc': turn_symbol_desc,
21 'main_indicate': main_indicate,
22 'support_indicate': support_indicate
23 }
24
25 if __name__ == '__main__':
26 conf = {
27 'wish': '恋爱',
28 'pray': '找到对象',
29 }
30 results = handle(conf)
31 print(results)
1532
161161 f"辅预言:{support_indicate}")
162162
163163 def predict(self, wish: str, pray: str):
164 today = datetime.datetime.now().__format__("%Y%m%d")
165 time_seed_str = wish + pray + today
164 '''
165 Divination.
166
167 Args:
168 wish(str)
169 pray(str)
170
171 Returns:
172 turn_symbol_desc(str)
173 main_indicate(str)
174 support_indicate(str)
175 '''
176 today = datetime.datetime.now().__format__("%Y%m%d")
177 time_seed_str = wish + pray + today
178 self._set_random_seed(time_seed_str)
179
180 # 生成本卦和变卦
181 origin_hexagram = self._gen_origin_hexagram()
182 support_hexagram = self._gen_support_hexagram(origin_hexagram)
183 origin_hexagram_dict_key = self._get_hexagram_dict_key(origin_hexagram)
184 support_hexagram_dict_key = self._get_hexagram_dict_key(support_hexagram)
185 turn_symbol_desc, main_indicate, support_indicate = self._parser_hexagram(origin_hexagram, support_hexagram)
186
187 return turn_symbol_desc, main_indicate, support_indicate
188
166189
167190 if __name__ == "__main__":
168191 obj = YiProgram()