Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

JesusGautamah/chatgpt_assistant

ChatGPT Assistant

Gem Version License: MIT Ruby Version

This Ruby gem provides an easy way to initialize a client for Telegram and Discord bots using the ChatGPT API, audio transcription, Text to Speech, creating an assistant that can answer questions in text and voice and have a conversation with the user.

Voice messages on telegram only - discord voice bot is not available and not planned to be implemented anymore

Discord voice bot is been replaced by a voice assistant local packege to act like google assistant, alexa, siri, cortana, etc. The voice assistant is been developed to linux and android, but it can be ported to other platforms in the future.

Speech to Text services - OpenAI Audio Transcription

More services will be added in the future

Text to Speech services - IBM Watson, AWS Polly, Azure Text to Speech

Languages supported currently: en, pt

Registration and Account Confirmation are avaiable on telegram only, sign in with the same credentials on discord after registering on telegram.

Requirements

  • Ruby > 2.6.0 - for the gem who can create bots projects in your machine
  • Ruby 3.2.2 - inside the docker container or run the bots in your machine
  • Docker
  • Docker Compose
  • PostgreSQL
  • Telegram Bot API Token
  • Discord Bot API Token
  • IBM Cloud Text to Speech API Key or AWS Polly API Key
  • OpenAI API Key

Installation

To install the gem, run:

gem install chatgpt_assistant

Alternatively, you can clone/fork this repo to use it as you wish.

Installation as a gem example

gem install chatgpt_assistant
chatgpt_assistant PATH_TO_FOLDER
cd PATH_TO_FOLDER
cp .env_sample .env
bundle install

Installation as a repo

Run in your terminal:

git clone https://github.com/JesusGautamah/chatgpt_assistant.git
cd chatgpt_assistant
cp .env_sample .env
bundle install

Make sure to run bundle before using the Lucy Dockerunner rake tasks.

Then, edit the .env_sample file to include the necessary credentials and rename it to .env. Run bundle install to install the necessary dependencies.

Include LUCY_SU=sudo in your .env if u run docker compose with sudo

Migrate your database

rake compose:up && sudo docker compose run --rm telegram exe/chatgpt_bot migrate
rake chatgpt_actors:install

Usage

You can start the Docker Compose services required for the gem using the rake tasks provided by the Lucy Dockerunner gem. These tasks include compose:up, compose:down, compose:status, compose:shell, compose:restart, and others listed previously.

For example, to start the services, run:

rake compose:up

To stop the services, run:

rake compose:down

After starting the Docker Compose services, you can use the features of the gem to create a chat assistant that responds to questions in both text and voice using the services mentioned above.

Discord Bot Commands

The discord commands prefix can be changed in the .env file. The default prefix is !!

  • !!start - shows the welcome message
  • !!help - shows the help message
  • !!login email:password - logs in the user. Remember to use private messages to register or login and share a server with right permissions with the bot to message it.
  • !!list - lists the user created chatbots
  • !!sl_chat CHAT TITLE - starts a chat with the chatbot with the given title
  • !!new_chat CHAT TITLE - creates a new chatbot with the given title
  • !!ask TEXT - sends a text to the chatbot

Telegram Bot Commands

  • /start - shows the welcome message
  • /help - shows the help message
  • login/email:password - logs in the user. Remember to use private messages to register or login.
  • register/email:password - registers a new user, email is not verfied yet, so you can use any email, the password is encrypted with bcrypt and stored in the database with salt. Remember to use private messages to register or login.
  • confirm/* name:token - confirms the user account. Remember to use private messages to register or login
  • list - lists the user created chatbots
  • sl_chat/CHAT TITLE - starts a chat with the chatbot with the given title
  • new_chat/CHAT TITLE - creates a new chatbot with the given title
  • TEXT - sends a text to the chatbot
  • VOICE_MESSAGE or AUDIO FILE - sends a voice message to the chatbot and returns the response in voice

Contributing

A good way to contribute is add your language to DefaultMessages class in lib/chatgpt_assistant/default_messages.rb. You can also add your language to the list of languages in the README.md file.

Bug reports and pull requests are welcome on GitHub at https://github.com/JesusGautamah/chatgpt_assistant. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Repography logo / Recent activity Time period

Timeline graph Issue status graph

Pull request status graph Trending topics

Top contributors Activity map

Contributors

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the ChatgptAssistant project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.