Skip to content

Commit

Permalink
更新README
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOFF-ive committed Apr 2, 2023
1 parent 2d7507a commit f6ce3f7
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
· 音频转文字
· 一键启动
· 聊天记录保存
· 快速响应

### 启动之前
1. 准备好你的 [OpenAI API Key](https://platform.openai.com/account/api-keys)
2. 在系统环境变量中新增一条变量```OPENAI_API_KEY```,变量值为你的[OpenAI API Key](https://platform.openai.com/account/api-keys)

### 启动项目
1. 下载项目到本地
Expand All @@ -26,7 +31,7 @@
D:\code\ChatGPT-CLI\Virtualenv\Scripts\python.exe D:\code\ChatGPT-CLI\main.py
PAUSE
```
2. 在系统环境变量中新增chat.bat的地址,即可在cmd中输入chat命令快速启动项目
2. 在系统环境变量PATH中新增chat.bat的地址,即可在cmd中输入chat命令快速启动项目
<div style="text-align:center">
<img src="./static/cmd_run.png" alt="cmd_run">
</div>
Expand All @@ -45,6 +50,9 @@ PAUSE
<img src="./static/powershell_run.png" alt="powershell_run">
</div>

### 项目配置
在使用前

### 如何使用
该项目共有五个选项```chat file save image audio```,当程序提示```Action```时即可输入选项并进入对应的模式,输入```quit```可以退出该程序,也可以直接关闭程序:D,接下来将分别介绍各个选项的作用:
#### chat
Expand All @@ -58,4 +66,30 @@ PAUSE
#### audio
输入音频文件的路径,返回该音频翻译的文字内容

**注意**:所有选项都可以通过输入```quit```返回主菜单
**注意**:所有选项都可以通过输入```quit```返回主菜单

### 自定义程序
修改main.py文件中的部分代码来定制化你的聊天机器人:D
```python
system_prompt: str = "You are a helpful assistant."
model: str = "gpt-3.5-turbo"
temperature: int = 1
n: int = 1
stream: bool = True
stop: bytes = None
max_tokens: int = 2048
presence_penalty: int = 0
frequency_penalty: int = 0
```
参数的具体含义参考[OpenAI API官网](https://platform.openai.com/docs/api-reference)

### 使用截图
<div style="text-align:center">
<img src="./static/example1.png" alt="example1">
</div>
<div style="text-align:center">
<img src="./static/example2.png" alt="example2">
</div>
<div style="text-align:center">
<img src="./static/example3.png" alt="example3">
</div>
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
messages: list[dict] = []
currentFile: str = ""

system_prompt: str = "You are a helpful assistant."
model: str = "gpt-3.5-turbo"
temperature: int = 1
n: int = 1
Expand Down Expand Up @@ -59,10 +60,9 @@ def parseResult_stream(completions):

def initOpenAI():
Log.info("OpenAI Initializing")
global messages
openai.organization = "org-nQ2su19ado3KvvI9HE5vAZHO"
global messages,system_prompt
openai.api_key = os.getenv("OPENAI_API_KEY")
messages.append({"role": "system", "content": "You are a helpful assistant."})
messages.append({"role": "system", "content": system_prompt})
Log.info("OpenAI Initialized")


Expand Down Expand Up @@ -100,7 +100,7 @@ def setFile():
return
try:
Log.info("Loading File {}".format(fileName))
with open(fileName, 'r') as f:
with open(os.path.join(chat_logs_path, fileName), 'r') as f:
messages.clear()
currentFile = fileName
for line in f:
Expand Down
Binary file added static/example1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/example2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/example3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f6ce3f7

Please sign in to comment.