kourva / awesomechatgptbot Goto Github PK
View Code? Open in Web Editor NEWChatGPT Telegram bot: Free & Rich-Feature bot for enhanced conversations.
License: MIT License
ChatGPT Telegram bot: Free & Rich-Feature bot for enhanced conversations.
License: MIT License
When sending any promt to bot bot reply :
That's and error! Try again.
Describe the solution you'd like
Allow upload a file to chat and bot will analyze that file
In new update i see you implement TTS - Voice Reply/Response (Output), but maybe would be better also implement reversed voice feature?
I mean, don't you think about adding Voice Recording/Recognition feature (Input) to allow users asking TG-bot with Voice Messeges?
Thanks. Yeah I know that most phones has Dictation feature that translates speach to text. But i think about reposting voices from another chat to TG-bot so i have option not to rewrite entire text and just repost voice. It may be helpfull too if you can repost not only text but also voice to trigger TG-bot to answer that.
references to feature -
https://github.com/n3d1117/chatgpt-telegram-bot
https://github.com/father-bot/chatgpt_telegram_bot
when type /reset i get:
Dear XXX
You need to start the bot before using it! We need to create an account for you first:
t.me/XXX_bot?start=create
is it ok?
in your previous mistakenly uploaded file titles.py i saw multiply languages variants.
do you plan to add some of them to settings for opportunity to change language of the bot?)
Can I use face openai ai instead of deepinfra ai as the bot uses deepinfra ai as default
New tts provider
import requests
import json
import time
from pathlib import Path
from typing import Generator
from playsound import playsound
class FailedToGenerateResponseError(Exception):
"""Provider failed to fetch response"""
class Voicepods:
"""
A class to interact with the Voicepods text-to-speech API.
"""
def __init__(self, timeout: int = 20, proxies: dict = None):
"""
Initializes the Voicepods API client.
"""
self.api_endpoint = "https://voicepods-stream.vercel.app/api/resemble"
self.headers = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate, br, zstd',
'Accept-Language': 'en-US,en;q=0.9,en-IN;q=0.8',
'Content-Type': 'application/json',
'DNT': '1',
'Origin': 'https://voicepods-stream.vercel.app',
'Referer': 'https://voicepods-stream.vercel.app/',
'Sec-CH-UA': '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
'Sec-CH-UA-Mobile': '?0',
'Sec-CH-UA-Platform': '"Windows"',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
}
self.session = requests.Session()
self.session.headers.update(self.headers)
if proxies:
self.session.proxies.update(proxies)
self.timeout = timeout
self.audio_cache_dir = Path("./audio_cache")
def tts(self, text: str) -> str:
"""
Converts text to speech using the Voicepods API.
Args:
text (str): The text to be converted to speech.
Returns:
str: The filename of the saved audio file.
Raises:
exceptions.FailedToGenerateResponseError: If there is an error generating or saving the audio.
"""
payload = json.dumps({"query": text})
filename = self.audio_cache_dir / f"{int(time.time())}.wav" # Using timestamp for filename
try:
response = self.session.post(self.api_endpoint, data=payload, timeout=self.timeout)
response.raise_for_status()
content_type = response.headers.get('Content-Type', '')
if 'audio' not in content_type.lower():
raise ValueError(f"Unexpected content type: {content_type}")
audio_data = response.content
self._save_audio(audio_data, filename)
return filename.as_posix() # Return the filename as a string
except requests.exceptions.RequestException as e:
raise FailedToGenerateResponseError(f"Error generating audio: {e}")
def _save_audio(self, audio_data: bytes, filename: Path):
"""Saves the audio data to a WAV file in the audio cache directory."""
try:
# Create the audio_cache directory if it doesn't exist
self.audio_cache_dir.mkdir(parents=True, exist_ok=True)
riff_start = audio_data.find(b'RIFF')
if riff_start == -1:
raise ValueError("RIFF header not found in audio data")
trimmed_audio_data = audio_data[riff_start:]
with open(filename, "wb") as f:
f.write(trimmed_audio_data)
except Exception as e:
raise FailedToGenerateResponseError(f"Error saving audio: {e}")
# Example usage
if __name__ == "__main__":
voicepods = Voicepods()
text = "Hello, this is a test of the Voicepods text-to-speech system."
print("Generating audio...")
audio_file = voicepods.tts(text)
hello Mike!
thank you for such a good free project!
All works like a charm, but can you please instruct me how to use Inline mode with predefined roles?
I activated it in BotFather and when i start messege with tagging bot by its nickname like this @Kourva - telegram just adds text string with suggestion "Ask me", and when I type something - nothing happens.
can you please write a little guide in github README.md how to use Inline Roles with some examples.
Thank you!
Please add new free providers
(may be not totaly publicly free, but providers that require free api_key from discord like this provider - https://github.com/PawanOsman/ChatGPT - this is acceptable i think and is not too difficult to get one and add it in config file of this bot). thanks!
Now only 1 works and it is not as good as others were
Status for available providers:
**Deepinfra AI (LLAMA 70b):
status -> Online**
Fstha GPT (GPT 3.5 Turbo):
status -> Offline
Online GPT (GPT 3.5 Turbo):
status -> Offline
Fakeopen AI (GPT 3.5 Turbo):
status -> Offline
i created auto-updater for your project
crontab -e
0 4 * * * ~/updater_tg_gpt.sh
nano ~/updater_tg_gpt.sh
#!/bin/bash
# Find the AwesomeChatGPTBot directory
AWESOME_CHAT_GPT_BOT_PATH=$(find / -type d -name "AwesomeChatGPTBot" 2>/dev/null | awk '!seen[$0]++')
# Check if the directory was found
if [ -z "$AWESOME_CHAT_GPT_BOT_PATH" ]; then
echo "Directory AwesomeChatGPTBot not found."
exit 1
fi
# Define the backup config directory path
BACKUP_CONFIG_DIR=$(dirname "$AWESOME_CHAT_GPT_BOT_PATH")/BACKUP-CONFIG
# Create the backup config directory if it doesn't exist
mkdir -p "$BACKUP_CONFIG_DIR"
# Copy the token.txt file from the found directory to BACKUP-CONFIG
cp "$AWESOME_CHAT_GPT_BOT_PATH"/token.txt "$BACKUP_CONFIG_DIR"/
# Backup the Accounts directory and its contents
cp -R "$AWESOME_CHAT_GPT_BOT_PATH"/Accounts "$BACKUP_CONFIG_DIR"/
# Remove the old AwesomeChatGPTBot directory if it exists
if [ -d "$AWESOME_CHAT_GPT_BOT_PATH"-old ]; then
rm -rf "$AWESOME_CHAT_GPT_BOT_PATH"-old
fi
# Backup current version of AwesomeChatGPTBot before updating
mv "$AWESOME_CHAT_GPT_BOT_PATH" "$AWESOME_CHAT_GPT_BOT_PATH"-old
# Clone the new version of AwesomeChatGPTBot from the repository
git clone https://github.com/Kourva/AwesomeChatGPTBot "$AWESOME_CHAT_GPT_BOT_PATH"
# Copy back the token.txt file
cp "$BACKUP_CONFIG_DIR"/token.txt "$AWESOME_CHAT_GPT_BOT_PATH"/
# Restore the Accounts directory from backup
cp -R "$BACKUP_CONFIG_DIR"/Accounts "$AWESOME_CHAT_GPT_BOT_PATH"/
# Change to the directory with the new version of AwesomeChatGPTBot
cd "$AWESOME_CHAT_GPT_BOT_PATH" || exit
# Provide permissions to the Accounts directory
chmod -R 777 Accounts/
# Run the initialization script
python3 init.py
# Restart the telegram_bot service
systemctl restart telegram_bot.service
chmod 777 ~/updater_tg_gpt.sh
Thanks for the update!
New provider GPT-4 works with EN lang but when you use RU / Cyrillic lang - it answers with unreadable symbols like that:
>hi, who are you? can you draw a picture or analyze images?
Hello! I'm an AI language model developed by OpenAI, designed to assist with a wide range of questions and tasks by processing and generating text. I'm not able to draw pictures or directly analyze images, as my capabilities are focused on understanding and generating text-based content. However, I can certainly help describe techniques for drawing or analyzing images, provide insights based on descriptions of images, or assist with any other text-related inquiries you might have. If you have any questions or need assistance with something, feel free to ask!
>переведи на русский язык
ÐдÑавÑÑвÑйÑе! Я ÑвлÑÑÑÑ ÑзÑковой моделÑÑ Ð¸ÑкÑÑÑÑвенного инÑеллекÑа, ÑазÑабоÑанной OpenAI, пÑедназнаÑенной Ð´Ð»Ñ Ð¿Ð¾Ð¼Ð¾Ñи в ÑиÑоком ÑпекÑÑе вопÑоÑов и Ð·Ð°Ð´Ð°Ñ Ð¿ÑÑем обÑабоÑки и генеÑаÑии ÑекÑÑа. Я не Ð¼Ð¾Ð³Ñ ÑиÑоваÑÑ ÐºÐ°ÑÑинки или напÑÑмÑÑ Ð°Ð½Ð°Ð»Ð¸Ð·Ð¸ÑоваÑÑ Ð¸Ð·Ð¾Ð±ÑажениÑ, Ñак как мои возможноÑÑи ÑоÑÑедоÑоÑÐµÐ½Ñ Ð½Ð° понимании и Ñоздании ÑекÑÑового конÑенÑа. Тем не менее, Ñ Ð¾Ð¿Ñеделенно Ð¼Ð¾Ð³Ñ Ð¿Ð¾Ð¼Ð¾ÑÑ Ð¾Ð¿Ð¸ÑаÑÑ ÑеÑники ÑиÑÐ¾Ð²Ð°Ð½Ð¸Ñ Ð¸Ð»Ð¸ анализа изобÑажений, пÑедоÑÑавиÑÑ Ð¸Ð½ÑоÑмаÑÐ¸Ñ Ð½Ð° оÑнове опиÑаний изобÑажений или помоÑÑ Ñ Ð»ÑбÑми дÑÑгими вопÑоÑами, ÑвÑзаннÑми Ñ ÑекÑÑом. ÐÑли Ñ Ð²Ð°Ñ ÐµÑÑÑ Ð²Ð¾Ð¿ÑоÑÑ Ð¸Ð»Ð¸ вам нÑжна помоÑÑ Ñ Ñем-Ñо, не ÑÑеÑнÑйÑеÑÑ ÑпÑаÑиваÑÑ!
Hello, thank you to the creator of this source for providing the most unique source, I don't know how I can use the bot in the group, for example, ask a question in the group and the bot will answer it. Please help.
Unknown Issue!
Log:
[Errno 2] No such file or directory: 'Accounts/621520367/providers.json'
This error come when I message to the bot.
I have read openAI documentation that you can only build using their API that is not free. Here watch this.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
Add any other context about the problem here.
use webcsout package for more AI features and searching features in ur project
hi, @Kourva
may be you can change free public API-proxy from Fakeopen to local one like here - https://github.com/F33RNI/GPT-Telegramus#-chat-gpt-base-url-proxy ( https://github.com/acheong08/ChatGPTProxy )
it works same as public one and has very much lower risk to be banned because of private usage.
Hello! After last update I have error while run python code:
root@TG-GPT-bot:~/github/GPT/AwesomeChatGPTBot# python3 main.py
The Bot is online (id: 6191756482) [Normal MODE]...
2023-12-03 17:19:21,313 (__init__.py:960 MainThread) ERROR - TeleBot: "Infinity polling exception: module 'titles' has no attribute 'welcome_2'"
2023-12-03 17:19:21,313 (__init__.py:962 MainThread) ERROR - TeleBot: "Exception traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/telebot/__init__.py", line 955, in infinity_polling
self.polling(non_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/usr/local/lib/python3.10/dist-packages/telebot/__init__.py", line 1043, in polling
self.__threaded_polling(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/usr/local/lib/python3.10/dist-packages/telebot/__init__.py", line 1118, in __threaded_polling
raise e
File "/usr/local/lib/python3.10/dist-packages/telebot/__init__.py", line 1074, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/usr/local/lib/python3.10/dist-packages/telebot/util.py", line 147, in raise_exceptions
raise self.exception_info
File "/usr/local/lib/python3.10/dist-packages/telebot/util.py", line 90, in run
task(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/telebot/__init__.py", line 6801, in _run_middlewares_and_handler
result = handler['function'](message)
File "/root/github/GPT/AwesomeChatGPTBot/main.py", line 71, in start_command_handler
text=titles.welcome_2.format(user.get_name)
AttributeError: module 'titles' has no attribute 'welcome_2'
I look into titles.py and there is NO text 'welcome_2'. i suppose you need to fix titles.py and add to it all missing attributes.
Maybe you should use this code in title.py
"`\n@{} roles`\n"
insted of
"```\n@{} roles```\n"
# Help prompt for (/help) command:
help_message = (
"*List of global commands*:\n"
"1. /start: Start bot\n"
"2. /help: Show this message\n"
"3. /ping: Ping the Providers\n\n"
"*List of chat related commands*:\n"
"1. /reset: Reset chat history\n"
"2. /history: Get chat history\n"
"3. /chat: Chat in groups\n"
"4. /danmode: Use DAN mode in GPT\n\n"
"*Other commands*:\n"
"1. /features: See feature changes\n\n"
"*Inline usage*:"
"`\n@{} roles`\n"
"this will show all available roles.\n\n"
"*Chat command usage*:\n"
"```\n/chat hello world!```"
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.