mirror of https://github.com/skygpu/skynet.git
change work request function to work with new ipfs logic
parent
995ab6c554
commit
1234d6c555
|
@ -265,7 +265,8 @@ class SkynetDiscordFrontend:
|
||||||
results[link] = png_img
|
results[link] = png_img
|
||||||
|
|
||||||
except UnidentifiedImageError:
|
except UnidentifiedImageError:
|
||||||
logging.warning(f'couldn\'t get ipfs binary data at {link}!')
|
logging.warning(
|
||||||
|
f'couldn\'t get ipfs binary data at {link}!')
|
||||||
|
|
||||||
tasks = [
|
tasks = [
|
||||||
get_and_set_results(ipfs_link),
|
get_and_set_results(ipfs_link),
|
||||||
|
@ -281,32 +282,25 @@ class SkynetDiscordFrontend:
|
||||||
png_img = results[ipfs_link]
|
png_img = results[ipfs_link]
|
||||||
|
|
||||||
if not png_img:
|
if not png_img:
|
||||||
await self.update_status_message(
|
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
||||||
status_msg,
|
embed.add_field(
|
||||||
caption,
|
name='Error', value=f'couldn\'t get ipfs hosted image [**here**]({ipfs_link})!')
|
||||||
reply_markup=build_redo_menu(),
|
await message.edit(embed=embed, view=SkynetView(self))
|
||||||
parse_mode='HTML'
|
|
||||||
)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# reword this function, may not need caption
|
# reword this function, may not need caption
|
||||||
caption, embed = generate_reply_caption(
|
caption, embed = generate_reply_caption(
|
||||||
user, params, tx_hash, worker, reward)
|
user, params, tx_hash, worker, reward, self.explorer_domain)
|
||||||
|
|
||||||
if not resp or resp.status_code != 200:
|
logging.info(f'success! sending generated image')
|
||||||
logging.error(f'couldn\'t get ipfs hosted image at {ipfs_link}!')
|
await message.delete()
|
||||||
embed.add_field(name='Error', value=f'couldn\'t get ipfs hosted image [**here**]({ipfs_link})!')
|
if file_id: # img2img
|
||||||
await message.edit(embed=embed, view=SkynetView(self))
|
embed.set_thumbnail(
|
||||||
else:
|
url='https://ipfs.skygpu.net/ipfs/' + binary_data + '/image.png')
|
||||||
logging.info(f'success! sending generated image')
|
embed.set_image(url=ipfs_link)
|
||||||
await message.delete()
|
await send(embed=embed, view=SkynetView(self))
|
||||||
if file_id: # img2img
|
else: # txt2img
|
||||||
embed.set_thumbnail(
|
embed.set_image(url=ipfs_link)
|
||||||
url='https://ipfs.skygpu.net/ipfs/' + binary_data + '/image.png')
|
await send(embed=embed, view=SkynetView(self))
|
||||||
embed.set_image(url=ipfs_link)
|
|
||||||
await send(embed=embed, view=SkynetView(self))
|
|
||||||
else: # txt2img
|
|
||||||
embed.set_image(url=ipfs_link)
|
|
||||||
await send(embed=embed, view=SkynetView(self))
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -32,7 +32,8 @@ class SKYExceptionHandler(ExceptionHandler):
|
||||||
|
|
||||||
|
|
||||||
def build_redo_menu():
|
def build_redo_menu():
|
||||||
btn_redo = InlineKeyboardButton("Redo", callback_data=json.dumps({'method': 'redo'}))
|
btn_redo = InlineKeyboardButton(
|
||||||
|
"Redo", callback_data=json.dumps({'method': 'redo'}))
|
||||||
inline_keyboard = InlineKeyboardMarkup()
|
inline_keyboard = InlineKeyboardMarkup()
|
||||||
inline_keyboard.add(btn_redo)
|
inline_keyboard.add(btn_redo)
|
||||||
return inline_keyboard
|
return inline_keyboard
|
||||||
|
@ -42,7 +43,7 @@ def prepare_metainfo_caption(user, worker: str, reward: str, meta: dict, embed)
|
||||||
prompt = meta["prompt"]
|
prompt = meta["prompt"]
|
||||||
if len(prompt) > 256:
|
if len(prompt) > 256:
|
||||||
prompt = prompt[:256]
|
prompt = prompt[:256]
|
||||||
|
|
||||||
gen_str = f'generated by {user.name}\n'
|
gen_str = f'generated by {user.name}\n'
|
||||||
gen_str += f'performed by {worker}\n'
|
gen_str += f'performed by {worker}\n'
|
||||||
gen_str += f'reward: {reward}\n'
|
gen_str += f'reward: {reward}\n'
|
||||||
|
@ -89,7 +90,8 @@ def generate_reply_caption(
|
||||||
url=f'https://{explorer_domain}/v2/explore/transaction/{tx_hash}',
|
url=f'https://{explorer_domain}/v2/explore/transaction/{tx_hash}',
|
||||||
color=discord.Color.blue())
|
color=discord.Color.blue())
|
||||||
|
|
||||||
meta_info = prepare_metainfo_caption(user, worker, reward, params, explorer_link)
|
meta_info = prepare_metainfo_caption(
|
||||||
|
user, worker, reward, params, explorer_link)
|
||||||
|
|
||||||
# why do we have this?
|
# why do we have this?
|
||||||
final_msg = '\n'.join([
|
final_msg = '\n'.join([
|
||||||
|
@ -98,7 +100,7 @@ def generate_reply_caption(
|
||||||
f'PARAMETER INFO:\n{meta_info}'
|
f'PARAMETER INFO:\n{meta_info}'
|
||||||
])
|
])
|
||||||
|
|
||||||
final_msg = '\n'.join([
|
final_msg += '\n'.join([
|
||||||
# f'***{explorer_link}***',
|
# f'***{explorer_link}***',
|
||||||
f'{meta_info}'
|
f'{meta_info}'
|
||||||
])
|
])
|
||||||
|
@ -112,6 +114,7 @@ async def get_global_config(cleos):
|
||||||
return (await cleos.aget_table(
|
return (await cleos.aget_table(
|
||||||
'telos.gpu', 'telos.gpu', 'config'))[0]
|
'telos.gpu', 'telos.gpu', 'config'))[0]
|
||||||
|
|
||||||
|
|
||||||
async def get_user_nonce(cleos, user: str):
|
async def get_user_nonce(cleos, user: str):
|
||||||
return (await cleos.aget_table(
|
return (await cleos.aget_table(
|
||||||
'telos.gpu', 'telos.gpu', 'users',
|
'telos.gpu', 'telos.gpu', 'users',
|
||||||
|
|
Loading…
Reference in New Issue