GithubHelp home page GithubHelp logo

easy-ernie's Introduction

提示

  1. 有封号风险.
  2. 由于文心一言的Acs-Token算法的参数不定时的变化,所以包里调用了API.感兴趣的或有自动更新方法的可以联系我.
  3. 若出现了用户访问被限制请到Isuue回复,我会及时更新Acs-Token算法的参数.

Release

介绍

简洁的调用文心一言的WebAPI.

需求

  1. 语言: Python3.8+.
  2. 其他: 文心一言账户.

安装

pip install easy-ernie --upgrade

Cookie

图片1

  1. 访问文心一言.
  2. 打开开发者工具.
  3. 找到应用程序(Application).
  4. 在左侧点击存储(Storage)-Cookies-https://yiyan.baidu.com.
  5. 在列表中点击BAIDUID.
  6. 复制下方Value的值.
  7. BDUSS_BFESS同理.

使用

Ernie

from easy_ernie import Ernie

if __name__ == '__main__':
    ernie = Ernie('BAIDUID', 'BDUSS_BFESS')
    sessionName = '你好'
    result1 = ernie.ask('你好', sessionName=sessionName)
    sessionId = result1['sessionId']
    chatBotId = result1['chatBotId']
    print(result1)
    result2 = ernie.ask('我给你发的上一个消息是什么', sessionId=sessionId, sessionName=sessionName, parentChatId=chatBotId)
    print(result2)
    ernie.deleteConversation(sessionId)

FastErinie

from easy_ernie import FastErnie

if __name__ == '__main__':
    fastErnie = FastErnie('BAIDUID', 'BDUSS_BFESS')
    print(fastErnie.ask('你好'))
    print(fastErnie.ask('我给你发的上一个消息是什么'))
    fastErnie.close()

更多方法查看Wiki.

感谢

灵感来源自acheong08,ls233.

easy-ernie's People

Contributors

xiaoxinyo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.