rename main command (#40)

* update poetry.lock

* rename main command

* Remove Ylokh && Vitalentum && GptChatly
This commit is contained in:
Dmitry Afanasyev
2023-10-16 18:38:04 +03:00
committed by GitHub
parent a273a89ba0
commit f987453b5d
8 changed files with 433 additions and 305 deletions

View File

@@ -18,6 +18,7 @@ class BotStagesEnum(StrEnum):
website = "website"
about_bot = "about_bot"
github = "github"
help = "help"
class BotEntryPoints(StrEnum):
@@ -46,8 +47,6 @@ class ChatGptModelsEnum(StrEnum):
gpt_3_stream_binjie = "gpt-3-stream-binjie"
gpt_3_5_turbo_stream_CodeLinkAva = "gpt-3.5-turbo-stream-CodeLinkAva"
gpt_4_stream_ChatBase = "gpt-4-stream-ChatBase"
gpt_3_5_turbo_16k_stream_Ylokh = "gpt-3.5-turbo-16k-stream-Ylokh"
gpt_3_5_turbo_stream_Vitalentum = "gpt-3.5-turbo-stream-Vitalentum"
gpt_3_5_turbo_stream_GptGo = "gpt-3.5-turbo-stream-GptGo"
gpt_3_5_turbo_stream_Aibn = "gpt-3.5-turbo-stream-Aibn"
gpt_3_5_turbo_stream_FreeGpt = "gpt-3.5-turbo-stream-FreeGpt"
@@ -55,9 +54,11 @@ class ChatGptModelsEnum(StrEnum):
gpt_4_stream_Chatgpt4Online = "gpt-4-stream-Chatgpt4Online"
gpt_3_5_turbo_stream_gptalk = "gpt-3.5-turbo-stream-gptalk"
llama2 = "llama2"
gpt_3_5_turbo_stream_gptforlove = "gpt-3.5-turbo-stream-gptforlove"
gpt_3_5_turbo_16k_stream_Ylokh = "gpt-3.5-turbo-16k-stream-Ylokh"
gpt_3_5_turbo_stream_Vitalentum = "gpt-3.5-turbo-stream-Vitalentum"
gpt_3_5_turbo_stream_GptChatly = "gpt-3.5-turbo-stream-GptChatly"
gpt_3_5_turbo_stream_ChatgptDemo = "gpt-3.5-turbo-stream-ChatgptDemo"
gpt_3_5_turbo_stream_gptforlove = "gpt-3.5-turbo-stream-gptforlove"
@classmethod
def values(cls) -> set[str]:
@@ -68,4 +69,7 @@ class ChatGptModelsEnum(StrEnum):
return {
"gpt-3.5-turbo-stream-gptforlove",
"gpt-3.5-turbo-stream-aivvm",
"gpt-3.5-turbo-stream-GptChatly",
"gpt-3.5-turbo-stream-Vitalentum",
"gpt-3.5-turbo-16k-stream-Ylokh",
}

View File

@@ -12,7 +12,7 @@ from core.bot.services import ChatGptService, SpeechToTextService
from settings.config import settings
async def main_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str:
async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> str:
"""Send message on `/start`."""
if not update.message:
return BotEntryPoints.end
@@ -90,19 +90,17 @@ async def ask_question(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
async def voice_recognize(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
if not update.message:
return
await update.message.reply_text("Пожалуйста, ожидайте :)\nТрехминутная запись обрабатывается примерно 30 секунд")
if not update.message.voice:
await update.message.reply_text("Голосовое сообщение не найдено")
return
await update.message.reply_text("Пожалуйста, ожидайте :)\nТрехминутная запись обрабатывается примерно 30 секунд")
sound_file = await update.message.voice.get_file()
sound_bytes = await sound_file.download_as_bytearray()
with tempfile.NamedTemporaryFile(delete=False) as tmpfile:
tmpfile.write(sound_bytes)
logger.info("file has been saved", filename=tmpfile.name)
speech_to_text_service = SpeechToTextService(filename=tmpfile.name)
speech_to_text_service.get_text_from_audio()
part = 0

View File

@@ -16,7 +16,7 @@ from core.bot.commands import (
ask_question,
github,
help_command,
main_command,
start_command,
voice_recognize,
website,
)
@@ -37,7 +37,7 @@ bot_event_handlers.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, a
bot_event_handlers.add_handler(MessageHandler(filters.VOICE | filters.AUDIO, voice_recognize))
bot_event_handlers.add_handler(
ConversationHandler(
entry_points=[CommandHandler("start", main_command)],
entry_points=[CommandHandler("start", start_command)],
states={
BotEntryPoints.start_routes: [
CallbackQueryHandler(about_me, pattern="^" + BotStagesEnum.about_me + "$"),
@@ -46,7 +46,7 @@ bot_event_handlers.add_handler(
CallbackQueryHandler(about_bot, pattern="^" + BotStagesEnum.about_bot + "$"),
],
},
fallbacks=[CommandHandler("start", main_command)],
fallbacks=[CommandHandler("start", start_command)],
)
)
bot_event_handlers.add_handler(CallbackQueryHandler(about_me, pattern="^" + BotStagesEnum.about_me + "$"))