Giter Club home page Giter Club logo

chagpt-api-call's Introduction

ChaGPT-API-Call

overall

This project uses python to simply implement the experience of how to call Chagpt's api for dialogue and other tasks.

how to run

  1. install python package(terminal):
    • install openai api(optional): "pip install openai";
    • install tiktoken to calculate the length of tokens: "pip install tiktoken" ,if tips "time out",please add the local sources,such as "pip install tiktoken -- timeout=300 -i https://pypi.tuna.tsinghua.edu.cn/simple";
  2. if you want to show conversation on your web, you can install flask use this conmmand: "pip install -r requirements.txt"
  3. Add your openAI key to the "authorization" in the config/chatgpt_config.py;
  4. Two method you can choose:
    • show in terminal:run this command "python test.py" in your terminal,or run test.py in your ide.
    • show in your local web:
      • run this command "python manager.py"
      • run html use ide,click the browser button image

notice

  • You can also use the OpenAI api (https://platform.openai.com/docs/guides/chat) to call, but it’s more flexible and convenient to implement by yourself to expand more applicatioins.

    image

  • The dialogue is entered directly from the command line. By default, the context of the dialogue will always be accumulated. If you want to clear the context, you can directly enter 'clear' on the command line.

  • The recently added method of deleting the history dialogue is implemented in tools/utils.py. At present, I think there is still a lot of room for optimization in this method. I try to adjust the parameters, this set of default parameters in config.py is relatively optimal in my attempt, you can also configure it in this file.

features

  • support mutil-turn dialogue
  • support delete the former dialogue automatically when the token length exceeds the limit of OpenAI API
  • support show conversation on local web

dialogue show

  • multi turn image

  • Preserve context ability after deleting several dialogues in round 45 image

  • local web show the conversation image

chagpt-api-call's People

Contributors

christophezhao 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.