当前位置:首页 > 资讯 > 正文

百度人工智能-写作文和文案

百度人工智能-写作文和文案

def zuowenbd():
    import wenxin_api
    # import wenxin_api  # 可以通过"pip install wenxin-api"命令安装
    #pip install --upgrade wenxin-api
    #https://wenxin.baidu.com/wenxin/docs#2l6tgx5rc
    from wenxin_api.tasks.composition import Composition
    # zixun_title = entryvar.get()
    showinfo('notice', '查找按钮左边第二个z输入框(eg:友谊),输入作文标题,然后点击作文按钮,搜到的作文内容显示在翻译区.失败的话可以再次点击作文按钮,现在开始等待...')
    zixun_title2 = entryvar2.get()
    wenxin_api.ak = "agjkbF4ygqtlqLQSoE7pXbgHce4yUjsk"
    wenxin_api.sk = "wxGFQHUTk02yMVH3pjAGboD4aSeGIyDh"
    input_dict = {
        "text": zixun_title2,
        "seq_len": 600, #字数
        "topp": 0.8,#多样性
        "penalty_score":1.2, #重复内容最少
        "min_dec_len": 256,
        "is_unidirectional": 0,
        "task_prompt": "zuowen"
    }
    try:
        rst = Composition.create(**input_dict)['result']
        print(rst)
        textPad3fanyi.delete(0.0, 'end')
        textPad3fanyi.insert('end',zixun_title2+':'+ rst)
        # https://www.jc2182.com/python/python-text-translation.html
        showinfo('notice', '作文内容显示在 翻译区.')
        # frame3fanyi.tkraise()
        # frame3fanyi.frame.tkraise()
    except:
        showinfo('notice', '本次搜索失败,再点一次吧.')
def wenanbd():
    import wenxin_api
    zixun_title2 = entryvar2.get()
    from wenxin_api.tasks.official_documents import OfficialDocuments
    wenxin_api.ak = "agjkbF4ygqtlqLQSoE7pXbgHce4yUjsk"
    wenxin_api.sk = "wxGFQHUTk02yMVH3pjAGboD4aSeGIyDh"
    input_dict = {
        "text": zixun_title2,
        "seq_len": 512,
        "topp": 0.9,
        "penalty_score": 1.2,
        "min_dec_len": 32,
        "is_unidirectional": 0,
        "task_prompt": "adtext"
    }
    rst = OfficialDocuments.create(**input_dict)['result']
    print(rst)

最新文章