Downloads · 30 days
0
kamron254843/tkdytddytttttttttxk
tkdytddytttttttttxk is a machine learning model from kamron254843. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-2.5.
import asyncio from aiogram import Bot, Dispatcher, types from openai import AsyncOpenAI
Downloads · 30 days
0
Access
Public
Updated Aug 3, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md1.5 KB · 50%
From the Hugging Face model README
import asyncio from aiogram import Bot, Dispatcher, types from openai import AsyncOpenAI
TELEGRAM_TOKEN = "ВАШ_ТОКЕН_ОТ_BOTFATHER" OPENAI_API_KEY = "ВАШ_API_КЛЮЧ_ОТ_OPENAI"
bot = Bot(token=TELEGRAM_TOKEN) dp = Dispatcher() ai_client = AsyncOpenAI(api_key=OPENAI_API_KEY)
@dp.message() async def handle_message(message: types.Message): # Отправляем уведомление, что бот «печатает» await bot.send_chat_action(chat_id=message.chat.id, action="typing")
try:
# Запрос к нейросети ChatGPT
response = await ai_client.chat.completions.create(
model="gpt-4o-mini", # Быстрая и экономичная модель
messages=[
{"role": "system", "content": "Ты дружелюбный и полезный ИИ-ассистент в Telegram."},
{"role": "user", "content": message.text}
]
)
# Отправляем ответ пользователю
await message.answer(response.choices[0].message.content)
except Exception as e:
await message.answer("Произошла ошибка при обращении к ИИ. Попробуйте позже.")
print(f"Ошибка: {e}")
async def main(): await dp.start_polling(bot)
if name == "main": asyncio.run(main())