https://github.com/oiramnet/chatgpt-irc-bot
ChatGPT IRC Bot
https://github.com/oiramnet/chatgpt-irc-bot
ai bot chatgpt irc
Last synced: 10 months ago
JSON representation
ChatGPT IRC Bot
- Host: GitHub
- URL: https://github.com/oiramnet/chatgpt-irc-bot
- Owner: oiramNet
- License: mit
- Created: 2024-10-07T01:11:45.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-12-20T09:07:06.000Z (over 1 year ago)
- Last Synced: 2025-04-14T12:08:31.089Z (about 1 year ago)
- Topics: ai, bot, chatgpt, irc
- Language: Python
- Homepage:
- Size: 39.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ChatGPT IRC Bot
__ChatGPT IRC Bot__ is a simple IRC bot written in Python. It was initially forked from the [knrd1/chatgpt](https://github.com/knrd1/chatgpt) but turned into its own project. It connects to __OpenAI__ endpoints to answer questions or generate images and uses official bindings from __OpenAI__ to interact with the API through the HTTP requests. You can find more details about API [here](https://platform.openai.com/docs/api-reference).
## Prerequisites
1. Create an account and obtain your API key: https://platform.openai.com/account/api-keys
2. Install Python3 and the official Python bindings (__openai__: 0.28.0, __0.28.1__; __pyshorteners__)
> Note that only version __0.28.x__ of __openai__ is supported, and the latest version is __0.28.1__.
* Debian/Ubuntu
```
apt install python3 python3-pip
pip3 install openai==0.28.1 pyshorteners
```
* RedHat/CentOS
```
yum install python3 python3-pip
pip3 install openai==0.28.1 pyshorteners
```
* FreeBSD
```
pkg install python311 py311-pip
pip install openai==0.28.1 pyshorteners
```
## Installation
Clone the package using the below command. It will copy files into the __ChatGPT-IRC-Bot__ directory, which you can later rename.
```
git clone https://github.com/oiramNet/ChatGPT-IRC-Bot.git
```
## Configuration
ChatGPT IRC Bot uses a plaintext file as its configuration file. The package includes an example configuration file (__chat.conf.sample__) set to connect to IRCnet. You can copy and modify it.
```
cd ChatGPT-IRC-Bot
cp chat.conf.sample chat.conf
```
> Variable __context__ is optional, you can leave it blank or enter what you want the bot to know and how you want it to behave. This will only work with the models connecting to the endpoint __/v1/chat/completions__ (see below).
```
[openai]
api_key = sk-XXXXXXXXXXXXXXX
[chatcompletion]
model = gpt-4o-mini
role = user
context =
temperature = 0.8
max_tokens = 1000
top_p = 1
frequency_penalty = 0
presence_penalty = 0
request_timeout = 60
[irc]
server = open.ircnet.net
port = 6667
ssl = false
channels = #oiram
nickname = SampleBot
ident = samplebot
realname = Sample Bot
password =
```
### Model endpoint compatibility
ChatGPT IRC Bot can use one of three API models:
* Models that support endpoint __/v1/completions__ (Legacy)
> gpt-3.5-turbo-instruct, babbage-002, davinci-002
* Models that support endpoint __/v1/chat/completions__
> __gpt-4o-mini__, gpt-4o, gpt-4, gpt-4-turbo, gpt-4-turbo-preview, gpt-3.5-turbo
* Models that support the creation of an image using endpoint __/v1/images/generations__
> dall-e-2, dall-e-3
We suggest starting experimenting with __gpt-4o-mini__ model. More details about models can be found [here](https://platform.openai.com/docs/models).
## Running bot
To start the bot, you can just run the command below.
* Debian/Ubuntu/RedHat/CentOS
```
python3 chatgpt.py chat.conf
```
* FreeBSD
```
python3.11 chatgpt.py chat.conf
```
You can use the __screen__ command to run it in the background and keep it running even after you log out of your session.
* Debian/Ubuntu/RedHat/CentOS
```
screen python3 chatgpt.py chat.conf
```
* FreeBSD
```
screen python3.11 chatgpt.py chat.conf
```
To detach from the __screen__ session (leaving your ChatGPT IRC Bot running in the background), press Ctrl + A followed by d (for "detach").
If you need to reattach to the screen session later, use the following command:
```
screen -r
```
## Interaction
ChatGPT IRC Bot will interact only if you direct your question using its nickname.
```
12:34:12 < user> SampleBot: how are you?
12:34:13 < SampleBot> I'm just a computer program, so I don't have feelings, but I'm here and ready to help you! How can I assist you today?
12:56:21 < user> SampleBot: do you like IRC?
12:56:22 < SampleBot> As an AI, I don't have personal preferences or feelings, but I can provide information about IRC! Internet Relay Chat (IRC) is a popular protocol for real-time communication and has been used for
decades. Many people appreciate it for its simplicity and the sense of community it fosters. If you have specific questions or topics about IRC, feel free to ask!
```
If you set the model to __dall-e-2__ or __dall-e-3__, the ChatGPT IRC Bot will return a shortened URL to the generated image.
```
13:14:05 < user> SampleBot: red apples on the table
13:14:35 < SampleBot> https://tinyurl.com/1a2b3c4d
```
## Docker
To build the Docker image, you can use the following command:
```
docker build -t my-chatgpt-app .
```
To run the Docker container, you can use the following command:
```
docker run -it my-chatgpt-app
```
To detach from a running Docker, press Ctrl + P. While holding down Ctrl, press Q.
To reattach to the container later, use the following command:
```
docker attach
```