#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2020-2024 (c) Randy W @xtdevs, @xtsea # # from : https://github.com/TeamKillerX # Channel : @RendyProjects # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import time import os from pyrogram import * from pyrogram.types import * from pyrogram.errors import * from akn.utils.handler import * from akn.utils.logger import LOGS from akn.utils.scripts import progress from akenoai import * from akenoai.types import DifferentAPIDefault js = AkenoXJs(DifferentAPIDefault()).connect() @Client.on_message( ~filters.scheduled & filters.command(["hybrid"]) & ~filters.forwarded ) async def hybridai(client, message): if len(message.command) > 1: prompt = message.text.split(maxsplit=1)[1] elif message.reply_to_message: prompt = message.reply_to_message.text else: return await message.reply_text("Give ask from gpt") try: response = await js.chat.create( "akenox/AkenoX-1.9-Hybrid", api_key=os.environ["AKENOX_AI_PREM"], params_data={"query": prompt}, is_obj=True ) if len(response.results) > 4096: with open("chat.txt", "w+", encoding="utf8") as out_file: out_file.write(response.results) await message.reply_document( document="chat.txt", disable_notification=True ) os.remove("chat.txt") else: await message.reply_text(response.results) except Exception as e: LOGS.info(f"Error: hybridai {str(e)}") await message.reply_text("Error try again") @Client.on_message( ~filters.scheduled & filters.command(["fluxai"]) & ~filters.forwarded ) async def aztimgfluxai_(client: Client, message: Message): question = message.text.split(" ", 1)[1] if len(message.command) > 1 else None if not question: return await message.reply_text("Please provide a question for Flux.") pro = await message.reply_text("Generating image, please wait...") try: response = await js.image.create( "black-forest-labs/flux-1-schnell", image_read=True, params_data={"query": question}, ) file_path = "randydev.jpg" with open(file_path, "wb") as f: f.write(response) await pro.edit_text("Uploading image...") await message.reply_photo( file_path, progress=progress, progress_args=( pro, time.time(), "Uploading image..." ) ) await pro.delete() if os.path.exists(file_path): os.remove(file_path) except ChatSendPhotosForbidden: return await pro.edit_text("You can't send photos in this chat") except Exception as e: LOGS.error(f"Error: aztimgfluxai_ {str(e)}") await pro.edit_text("error generating the image.")