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
- 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";
- if you want to show conversation in your browser, you can install flask service dependency libraries use this conmmand: "pip install -r requirements.txt"
- Add your openAI key to the "authorization" in the config/chatgpt_config.py;
-
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 browser:
- run this command "python manager.py"
- open your browser, and type the address:http://127.0.0.1:9200/ ,then you can see the page load as below:
notice
features
- support mutil-turn dialogue
- support delete the former dialogue automatically when the token length exceeds the limit of OpenAI API
dialogue show
todo
- The content returned by the API can streaming display.