# MyChatGPT
A casual and simple homemade ChatGPT Python script that can run using terminal (as long as you have an API).
Just run the code and type something.
**(NOTE: Your input must end with a '#', such as 'How are you? #')**
## How To Use:
### 1. Install `openai`, and download the script
For MacOS and Linux:
`pip install openai==0.28 readline`
For Windows:
`pip install openai==0.28 pyreadline3`
Then, download (or copy) `mychatgpt.py` in this repository.
### 2. Prepare an API
Azure API: https://azure.microsoft.com/en-us/products/cognitive-services/openai-service
OpenAI API: https://platform.openai.com/account/api-keys
### 3. Input your API Key
Replace the `INPUT_YOUR_API_KEY` in `mychatgpt.py` with your API Key;
If you use Azure API, replace `INPUT_YOUR_ENDPOINT_URL` and `INPUT_YOUR_MODEL_NAME` with yours.
### 4. (Optional) Edit your `.bashrc` or `.zshrc`
Edit your `.bashrc` or `.zshrc` to add this line to the bottom:
`alias mychatgpt='python3 /PATH_TO_MYCHATGPT/mychatgpt.py'`
Remember to replace `PATH_TO_MYCHATGPT` with the real path.
### 5. Run
Open terminal, and run:
```
python3 /PATH_TO_MYCHATGPT/mychatgpt.py
```
Remember to replace `PATH_TO_MYCHATGPT` with the real path.
If you performed step 4, just run `mychatgpt`.
Then use it.
**(NOTE: Your input must end with a '#', such as 'How are you? #')**
#### Run with commands
Run with additional prompts:
```
mychatgpt --prompt YOUR_PROMPT
```
Run with setting the temperature to 1.1 (the higher the value, the random the text, default 1.0):
```
mychatgpt --temperature 1.1
```
Run and save conversation history on the fly:
```
mychatgpt --save SAVE_PATH
```
Load conversation history and run:
```
mychatgpt --load LOAD_PATH
```
## Some commands
Run `mychatgpt`, and input "help", you will see:
```
----------------------------------------
HELP:
exit: exit the conversation.
clear: clear the conversation history.
history: show the conversation history.
back: go back to the previous stage of the conversation.
temperature: check and change the temperature.
load FILE_PATH: load the conversation history from a file.
save FILE_PATH: save the conversation history to a file.
help: show the help message.
----------------------------------------
```
simple ChatGPT Python script that cSupport Azure API..zip
需积分: 0 54 浏览量
2023-12-24
13:12:40
上传
评论
收藏 4KB ZIP 举报
极致人生-010
- 粉丝: 3237
- 资源: 3077
最新资源
- 测试aaaaaaabbbbb
- VID20240521070643.mp4
- Android系统原理与开发学习要点详解-培训课件.zip
- 部署yolov8的tensorrt模型支持检测分割姿态估计的C++源码+部署步骤.zip
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈