2023-03-20 12:02:37 +00:00
|
|
|
# ChatGPT
|
2023-03-21 00:07:49 +00:00
|
|
|
ChatGPT is a simple IRC bot written in Python. It connects to OpenAI endpoints to answer questions.
|
2023-03-20 12:02:37 +00:00
|
|
|
|
|
|
|
ChatGPT uses official bindings from OpenAI to interact with the API through HTTP requests:
|
|
|
|
https://platform.openai.com/docs/api-reference
|
|
|
|
|
|
|
|
### Prerequisities:
|
|
|
|
|
|
|
|
Create an account and obtain your API key: https://platform.openai.com/account/api-keys
|
|
|
|
|
|
|
|
Install python3 and the official Python bindings:
|
|
|
|
```
|
2023-03-21 19:41:46 +00:00
|
|
|
$ apt install python3 (Debian/Ubuntu)
|
|
|
|
$ yum install python3 (RedHat/CentOS)
|
|
|
|
$ pip3 install openai
|
|
|
|
$ git clone https://github.com/knrd1/chatgpt.git
|
|
|
|
$ cd chatgpt
|
|
|
|
$ cp example-chat.conf chat.conf
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
|
|
|
### Configuration:
|
|
|
|
|
2023-03-21 09:20:37 +00:00
|
|
|
Edit chat.conf and change variables. Example configuration for IRCNet:
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
2023-03-21 09:20:37 +00:00
|
|
|
[openai]
|
|
|
|
api_key = sk-XXXXXXXXXXXXXXX
|
|
|
|
|
|
|
|
[irc]
|
|
|
|
server = open.ircnet.net
|
2023-03-20 12:02:37 +00:00
|
|
|
port = 6667
|
2023-03-21 09:20:37 +00:00
|
|
|
channel = #irc
|
|
|
|
nickname = MyBot
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
2023-03-21 00:16:52 +00:00
|
|
|
### Optional settings:
|
|
|
|
|
2023-03-21 09:20:37 +00:00
|
|
|
You can optionally adjust following settings in chatgpt.py, please see docs for more details:
|
2023-03-20 12:18:45 +00:00
|
|
|
https://platform.openai.com/docs/api-reference/completions
|
2023-03-20 12:17:28 +00:00
|
|
|
```
|
2023-03-21 19:41:46 +00:00
|
|
|
temperature=0.8,
|
|
|
|
max_tokens=1000,
|
|
|
|
top_p=1,
|
|
|
|
frequency_penalty=0,
|
|
|
|
presence_penalty=0
|
|
|
|
request_timeout=180
|
2023-03-20 12:17:28 +00:00
|
|
|
```
|
2023-03-21 09:20:37 +00:00
|
|
|
Also, you can edit the model, the list of compatible models below:
|
2023-03-20 12:37:57 +00:00
|
|
|
```
|
2023-03-22 18:05:23 +00:00
|
|
|
model="gpt-3.5-turbo",
|
2023-03-20 12:37:57 +00:00
|
|
|
```
|
2023-03-20 12:02:37 +00:00
|
|
|
### Connecting bot to IRC server:
|
|
|
|
```
|
|
|
|
$ python3 chatgpt.py
|
|
|
|
```
|
|
|
|
### Interaction:
|
2023-03-20 13:02:37 +00:00
|
|
|
ChatGPT will interact only if you mention its nickname:
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
|
|
|
10:31:12 <@knrd1> ChatGPT: hello, how are you?
|
|
|
|
10:31:14 < ChatGPT> Hi there, I'm doing well, thank you. How about you?
|
2023-03-21 09:20:37 +00:00
|
|
|
10:35:56 <@knrd1> ChatGPT: do you like IRC?
|
|
|
|
10:35:59 < ChatGPT> Yes, I like IRC. It is a great way to communicate with people from around the world.
|
|
|
|
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
|
|
|
### Model endpoint compatibility
|
|
|
|
|
2023-03-22 18:05:23 +00:00
|
|
|
ChatGPT uses endpoint v1/chat/completions. Following models are compatible.
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
2023-03-22 18:05:23 +00:00
|
|
|
gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314, gpt-3.5-turbo, gpt-3.5-turbo-0301
|
2023-03-20 12:02:37 +00:00
|
|
|
```
|
2023-03-21 09:20:37 +00:00
|
|
|
More details about models: https://platform.openai.com/docs/models
|