GithubHelp home page GithubHelp logo

jesusgautamah / chatgpt_assistant Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 309 KB

ChatGPT Virtual Assistant to Telegram and Discord with Voice Recognition

License: MIT License

Dockerfile 0.42% Ruby 99.17% Shell 0.41%
assistant aws aws-polly chatgpt chatgpt-api docker docker-compose ibm ibm-cloud ibm-watson ruby speech-recognition speech-synthesis text-to-speech voice-assistant azure

chatgpt_assistant's Introduction

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.

chatgpt_assistant's People

Contributors

code-factor avatar codefactor-io[bot] avatar dependabot[bot] avatar jesusgautamah avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

voltanbro

chatgpt_assistant's Issues

Audio Recognition not working

Describe the bug
A clear and concise description of what the bug is.
After the transcribe audio changed the return to json
the function in telegram bot is holding the key "text" instead of it's value
so the chatgpt api is receiving "text" instead of user audio content

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'telegram'
  2. Click on 'audio record'
  3. Send the audio
  4. See error

Fix 1 Complexity, 5 Maintainability issues in multiple files

CodeFactor found multiple issues last seen at 279a9cb:

Complex Code

Trailing spaces

Avoid use of wget without progress bar. Use wget --progress=dot:giga <url>. Or consider using -q or -nv (shorthands for --quiet or --no-verbose).

Avoid additional packages by specifying --no-install-recommends

Delete the apt-get lists after installing something

Conexão chat de voz

Describe the bug
Tentei conectar o bot apóes fazer login e não funcionou.

Expected behavior
Gostaria que ele me desse bom dia.

Parse messages when limit length is reached for each bot, create a helper!

Is your feature request related to a problem? Please describe.
Yes! When the message is too big the bot crash

Describe the solution you'd like
A clear and concise description of what you want to happen.
Create a helper in lib/bots/helpers/application_helper.rb
use scan method to parse the message in a array respect the length limit of each bot platform

Telegram user access error

Describe the bug
'telegram_user_access' is not returning the user access email

To Reproduce
Try to login

Expected behavior
User be authenticated

Additional context
Update the method to

    def telegram_user_access(visitor, new_access)
      other_access = where_user(telegram_id: visitor.telegram_id)
      other_access&.each { |access| access.update(telegram_id: nil) }
      return new_access.email if new_access.update(telegram_id: visitor.telegram_id)

      "something went wrong"
    end
    ```

Telegram user auth fail

Problem

The TelegramBot class has a bug in the def user @user ||= User.find... method that crashes when there is only one user logged in all chats. Additionally, the auth_usertelegram method no longer returns a user object it has to return the email.

Ruby Version: 3.2

Steps to reproduce

  1. Login with only one user in all chats.
  2. Execute TelegramBot class.
  3. Execute def user @user ||= User.find... method.
  4. The system should crash and prevent further processing.

Expected behavior

The def user @user ||= User.find... method should correctly return the user object using the TelegramBot class. The auth_usertelegram method should also return the user object correctly.

Actual behavior

The method crashes when there is only one user logged in all chats, and the auth_usertelegram method now only returns the email instead of the user object.

Suggested solution

change def user @user ||= User.find... to def user @user = User.find... and change the return of auth usertelegram to user email

Correct actor prompt

The prompt message is missed when messages memory limit is reached.
This activity has the objective of correct the system type prompt of the actors,
and send it even the memory limit is reached, replacing the first message with the prompt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.