diff --git a/app_spec.yml b/app_spec.yml index cec0598..ac78b7f 100644 --- a/app_spec.yml +++ b/app_spec.yml @@ -1,6 +1,6 @@ input: things: - name: things + name: wish value_type: str description: '' pray: diff --git a/handler.py b/handler.py index 7696a24..7b253ff 100644 --- a/handler.py +++ b/handler.py @@ -1,3 +1,5 @@ +from yi import YiProgram + def handle(conf): """ 该方法是部署之后,其他人调用你的服务时候的处理方法。 @@ -8,9 +10,24 @@ 参数请放到params字典中,我们会自动解析该变量。 """ - wish = conf['things'] # value_type: str # description: some description + wish = conf['wish'] # value_type: str # description: some description pray = conf['pray'] + obj = YiProgram() + turn_symbol_desc, main_indicate, support_indicate = obj.predict(wish, pray) + # add your code - return {'ret1': 'cat', 'ret2': 'dog'} + return { + 'turn_symbol_desc': turn_symbol_desc, + 'main_indicate': main_indicate, + 'support_indicate': support_indicate + } + +if __name__ == '__main__': + conf = { + 'wish': '恋爱', + 'pray': '找到对象', + } + results = handle(conf) + print(results) diff --git a/yi.py b/yi.py index 2a27686..9590517 100644 --- a/yi.py +++ b/yi.py @@ -162,8 +162,31 @@ f"辅预言:{support_indicate}") def predict(self, wish: str, pray: str): - today = datetime.datetime.now().__format__("%Y%m%d") - time_seed_str = wish + pray + today + ''' + Divination. + + Args: + wish(str) + pray(str) + + Returns: + turn_symbol_desc(str) + main_indicate(str) + support_indicate(str) + ''' + today = datetime.datetime.now().__format__("%Y%m%d") + time_seed_str = wish + pray + today + self._set_random_seed(time_seed_str) + + # 生成本卦和变卦 + origin_hexagram = self._gen_origin_hexagram() + support_hexagram = self._gen_support_hexagram(origin_hexagram) + origin_hexagram_dict_key = self._get_hexagram_dict_key(origin_hexagram) + support_hexagram_dict_key = self._get_hexagram_dict_key(support_hexagram) + turn_symbol_desc, main_indicate, support_indicate = self._parser_hexagram(origin_hexagram, support_hexagram) + + return turn_symbol_desc, main_indicate, support_indicate + if __name__ == "__main__": obj = YiProgram()