mirror of https://github.com/skygpu/skynet.git
update max size params and add discord return card
parent
2e47ee97f2
commit
2440fe32db
|
@ -133,8 +133,8 @@ MP_ENABLED_ROLES = ['god']
|
||||||
|
|
||||||
MIN_STEP = 1
|
MIN_STEP = 1
|
||||||
MAX_STEP = 100
|
MAX_STEP = 100
|
||||||
MAX_WIDTH = 512
|
MAX_WIDTH = 1024
|
||||||
MAX_HEIGHT = 656
|
MAX_HEIGHT = 1024
|
||||||
MAX_GUIDANCE = 20
|
MAX_GUIDANCE = 20
|
||||||
|
|
||||||
DEFAULT_SEED = None
|
DEFAULT_SEED = None
|
||||||
|
|
|
@ -116,10 +116,12 @@ class SkynetDiscordFrontend:
|
||||||
status_msg,
|
status_msg,
|
||||||
method: str,
|
method: str,
|
||||||
params: dict,
|
params: dict,
|
||||||
ctx: discord.TextChannel,
|
ctx: discord.ext.commands.context.Context | discord.Message,
|
||||||
file_id: str | None = None,
|
file_id: str | None = None,
|
||||||
binary_data: str = ''
|
binary_data: str = ''
|
||||||
):
|
):
|
||||||
|
send = ctx.channel.send
|
||||||
|
|
||||||
if params['seed'] == None:
|
if params['seed'] == None:
|
||||||
params['seed'] = random.randint(0, 0xFFFFFFFF)
|
params['seed'] = random.randint(0, 0xFFFFFFFF)
|
||||||
|
|
||||||
|
@ -259,8 +261,8 @@ class SkynetDiscordFrontend:
|
||||||
ipfs_link = f'https://ipfs.{DEFAULT_DOMAIN}/ipfs/{ipfs_hash}/image.png'
|
ipfs_link = f'https://ipfs.{DEFAULT_DOMAIN}/ipfs/{ipfs_hash}/image.png'
|
||||||
resp = await get_ipfs_file(ipfs_link)
|
resp = await get_ipfs_file(ipfs_link)
|
||||||
|
|
||||||
# caption = generate_reply_caption(
|
caption, embed = generate_reply_caption(
|
||||||
# user, params, tx_hash, worker, reward)
|
user, params, tx_hash, worker, reward)
|
||||||
|
|
||||||
if not resp or resp.status_code != 200:
|
if not resp or resp.status_code != 200:
|
||||||
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
||||||
|
@ -273,7 +275,9 @@ class SkynetDiscordFrontend:
|
||||||
#
|
#
|
||||||
else:
|
else:
|
||||||
logging.info(f'success! sending generated image')
|
logging.info(f'success! sending generated image')
|
||||||
image = io.BytesIO(resp.raw)
|
# image = io.BytesIO(resp.raw)
|
||||||
|
# embed.set_image(url=ipfs_link)
|
||||||
|
# embed.add_field(name='params', value=caption)
|
||||||
# await self.bot.delete_message(
|
# await self.bot.delete_message(
|
||||||
# chat_id=status_msg.chat.id, message_id=status_msg.id)
|
# chat_id=status_msg.chat.id, message_id=status_msg.id)
|
||||||
if file_id: # img2img
|
if file_id: # img2img
|
||||||
|
@ -298,6 +302,7 @@ class SkynetDiscordFrontend:
|
||||||
# reply_markup=build_redo_menu(),
|
# reply_markup=build_redo_menu(),
|
||||||
# parse_mode='HTML'
|
# parse_mode='HTML'
|
||||||
# )
|
# )
|
||||||
await ctx.reply(
|
|
||||||
file=discord.File(image, 'image.png')
|
embed.set_image(url=ipfs_link)
|
||||||
)
|
embed.add_field(name='Parameters:', value=caption)
|
||||||
|
await send(embed=embed)
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Txt2ImgButton(discord.ui.Button):
|
||||||
await db_call(
|
await db_call(
|
||||||
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
'update_user_stats', user.id, 'txt2img', last_prompt=prompt)
|
||||||
|
|
||||||
ec = await work_request(user.name, status_msg, 'txt2img', params, msg)
|
ec = await work_request(user, status_msg, 'txt2img', params, msg)
|
||||||
|
|
||||||
if ec == 0:
|
if ec == 0:
|
||||||
await db_call('increment_generated', user.id)
|
await db_call('increment_generated', user.id)
|
||||||
|
|
|
@ -9,6 +9,7 @@ from datetime import datetime, timezone
|
||||||
from telebot.types import InlineKeyboardButton, InlineKeyboardMarkup
|
from telebot.types import InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
from telebot.async_telebot import ExceptionHandler
|
from telebot.async_telebot import ExceptionHandler
|
||||||
from telebot.formatting import hlink
|
from telebot.formatting import hlink
|
||||||
|
import discord
|
||||||
|
|
||||||
from skynet.constants import *
|
from skynet.constants import *
|
||||||
|
|
||||||
|
@ -37,59 +38,59 @@ def build_redo_menu():
|
||||||
return inline_keyboard
|
return inline_keyboard
|
||||||
|
|
||||||
|
|
||||||
def prepare_metainfo_caption(tguser, worker: str, reward: str, meta: dict) -> str:
|
def prepare_metainfo_caption(user, worker: str, reward: str, meta: dict) -> str:
|
||||||
prompt = meta["prompt"]
|
prompt = meta["prompt"]
|
||||||
if len(prompt) > 256:
|
if len(prompt) > 256:
|
||||||
prompt = prompt[:256]
|
prompt = prompt[:256]
|
||||||
|
|
||||||
|
meta_str = f'__by {user.name}__\n'
|
||||||
|
meta_str += f'*performed by {worker}*\n'
|
||||||
|
meta_str += f'__**reward: {reward}**__\n'
|
||||||
|
|
||||||
meta_str = f'<u>by {tg_user_pretty(tguser)}</u>\n'
|
meta_str += f'`prompt:` {prompt}\n'
|
||||||
meta_str += f'<i>performed by {worker}</i>\n'
|
meta_str += f'`seed: {meta["seed"]}`\n'
|
||||||
meta_str += f'<b><u>reward: {reward}</u></b>\n'
|
meta_str += f'`step: {meta["step"]}`\n'
|
||||||
|
meta_str += f'`guidance: {meta["guidance"]}`\n'
|
||||||
meta_str += f'<code>prompt:</code> {prompt}\n'
|
|
||||||
meta_str += f'<code>seed: {meta["seed"]}</code>\n'
|
|
||||||
meta_str += f'<code>step: {meta["step"]}</code>\n'
|
|
||||||
meta_str += f'<code>guidance: {meta["guidance"]}</code>\n'
|
|
||||||
if meta['strength']:
|
if meta['strength']:
|
||||||
meta_str += f'<code>strength: {meta["strength"]}</code>\n'
|
meta_str += f'`strength: {meta["strength"]}`\n'
|
||||||
meta_str += f'<code>algo: {meta["model"]}</code>\n'
|
meta_str += f'`algo: {meta["model"]}`\n'
|
||||||
if meta['upscaler']:
|
if meta['upscaler']:
|
||||||
meta_str += f'<code>upscaler: {meta["upscaler"]}</code>\n'
|
meta_str += f'`upscaler: {meta["upscaler"]}`\n'
|
||||||
|
|
||||||
meta_str += f'<b><u>Made with Skynet v{VERSION}</u></b>\n'
|
meta_str += f'__**Made with Skynet v{VERSION}**__\n'
|
||||||
meta_str += f'<b>JOIN THE SWARM: @skynetgpu</b>'
|
meta_str += f'**JOIN THE SWARM: @skynetgpu**'
|
||||||
return meta_str
|
return meta_str
|
||||||
|
|
||||||
|
|
||||||
def generate_reply_caption(
|
def generate_reply_caption(
|
||||||
tguser, # telegram user
|
user, # discord user
|
||||||
params: dict,
|
params: dict,
|
||||||
tx_hash: str,
|
tx_hash: str,
|
||||||
worker: str,
|
worker: str,
|
||||||
reward: str
|
reward: str
|
||||||
):
|
):
|
||||||
explorer_link = hlink(
|
explorer_link = discord.Embed(
|
||||||
'SKYNET Transaction Explorer',
|
title='[SKYNET Transaction Explorer]',
|
||||||
f'https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{tx_hash}'
|
url=f'https://explorer.{DEFAULT_DOMAIN}/v2/explore/transaction/{tx_hash}',
|
||||||
)
|
color=discord.Color.blue())
|
||||||
|
|
||||||
meta_info = prepare_metainfo_caption(tguser, worker, reward, params)
|
meta_info = prepare_metainfo_caption(user, worker, reward, params)
|
||||||
|
|
||||||
|
# why do we have this?
|
||||||
final_msg = '\n'.join([
|
final_msg = '\n'.join([
|
||||||
'Worker finished your task!',
|
'Worker finished your task!',
|
||||||
explorer_link,
|
# explorer_link,
|
||||||
f'PARAMETER INFO:\n{meta_info}'
|
f'PARAMETER INFO:\n{meta_info}'
|
||||||
])
|
])
|
||||||
|
|
||||||
final_msg = '\n'.join([
|
final_msg = '\n'.join([
|
||||||
f'<b><i>{explorer_link}</i></b>',
|
# f'***{explorer_link}***',
|
||||||
f'{meta_info}'
|
f'{meta_info}'
|
||||||
])
|
])
|
||||||
|
|
||||||
logging.info(final_msg)
|
logging.info(final_msg)
|
||||||
|
|
||||||
return final_msg
|
return final_msg, explorer_link
|
||||||
|
|
||||||
|
|
||||||
async def get_global_config(cleos):
|
async def get_global_config(cleos):
|
||||||
|
|
Loading…
Reference in New Issue