from yi import YiProgram

def handle(conf):
    """
    该方法是部署之后，其他人调用你的服务时候的处理方法。
    请按规范填写参数结构，这样我们就能替你自动生成配置文件，方便其他人的调用。
    范例：
    params['key'] = value # value_type: str # description: some description
    value_type 可以选择：img, video, audio, str, int, float, [int], [str], [float]
    参数请放到params字典中，我们会自动解析该变量。
    """

    # get the input params
    wish = conf['所求之事']  # value_type: str # description: some description
    pray = conf['祈祷']

    # predict
    obj = YiProgram()
    origin_hexagram, support_hexagram, turn_symbol_desc, main_indicate, support_indicate = obj.predict(wish, pray)
    
    # return results
    return {
        '本卦': origin_hexagram,
        '变卦': support_hexagram,
        '说明': turn_symbol_desc,
        '主预言': main_indicate,
        '辅预言': support_indicate
    }

if __name__ == '__main__':
    wish = '愿世界不再有战争！'
    pray = '愿每一个人能每天开心、快乐！'
    conf = {
        '所求之事': wish,
        '祈祷': pray
    }
    results = handle(conf)
    print('results:\n', results)
    