mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-03-28 18:41:43 +01:00
add replicate dvms, minor fixes, add otherstuff tests
This commit is contained in:
parent
972785d28d
commit
ff327e9117
171
nostr_dvm/tasks/imagegeneration_replicate.py
Normal file
171
nostr_dvm/tasks/imagegeneration_replicate.py
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from PIL import Image
|
||||||
|
from nostr_sdk import Kind
|
||||||
|
|
||||||
|
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||||
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
|
from nostr_dvm.utils.definitions import EventDefinitions
|
||||||
|
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
|
||||||
|
from nostr_dvm.utils.nip88_utils import NIP88Config
|
||||||
|
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
||||||
|
from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||||
|
from nostr_dvm.utils.zap_utils import get_price_per_sat
|
||||||
|
|
||||||
|
"""
|
||||||
|
This File contains a Module to generate an Image on replicate and receive results back.
|
||||||
|
|
||||||
|
Accepted Inputs: Prompt (text)
|
||||||
|
Outputs: An url to an Image
|
||||||
|
Params:
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ImageGenerationReplicate(DVMTaskInterface):
|
||||||
|
KIND: Kind = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||||
|
TASK: str = "text-to-image"
|
||||||
|
FIX_COST: float = 120
|
||||||
|
dependencies = [("nostr-dvm", "nostr-dvm"),
|
||||||
|
("replicate", "replicate")]
|
||||||
|
|
||||||
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None,
|
||||||
|
options=None, task=None):
|
||||||
|
super().__init__(name, dvm_config, nip89config, nip88config, admin_config, options, task)
|
||||||
|
if options is not None:
|
||||||
|
self.model = options["model"]
|
||||||
|
else:
|
||||||
|
self.model = None
|
||||||
|
|
||||||
|
async def init_dvm(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
dvm_config.SCRIPT = os.path.abspath(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
async def is_input_supported(self, tags, client=None, dvm_config=None):
|
||||||
|
for tag in tags:
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_value = tag.as_vec()[1]
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type != "text":
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'output':
|
||||||
|
output = tag.as_vec()[1]
|
||||||
|
if (output == "" or
|
||||||
|
not (output == "image/png" or "image/jpg"
|
||||||
|
or output == "image/png;format=url" or output == "image/jpg;format=url")):
|
||||||
|
print("Output format not supported, skipping..")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def create_request_from_nostr_event(self, event, client=None, dvm_config=None):
|
||||||
|
request_form = {"jobID": event.id().to_hex() + "_" + self.NAME.replace(" ", "")}
|
||||||
|
prompt = ""
|
||||||
|
width = "1"
|
||||||
|
height = "1"
|
||||||
|
if self.model is None:
|
||||||
|
self.model = "stability-ai/stable-diffusion-3",
|
||||||
|
|
||||||
|
for tag in event.tags():
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type == "text":
|
||||||
|
prompt = tag.as_vec()[1]
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'param':
|
||||||
|
print("Param: " + tag.as_vec()[1] + ": " + tag.as_vec()[2])
|
||||||
|
if tag.as_vec()[1] == "size":
|
||||||
|
if len(tag.as_vec()) > 3:
|
||||||
|
width = (tag.as_vec()[2])
|
||||||
|
height = (tag.as_vec()[3])
|
||||||
|
elif len(tag.as_vec()) == 3:
|
||||||
|
split = tag.as_vec()[2].split(":")
|
||||||
|
if len(split) > 1:
|
||||||
|
width = split[0]
|
||||||
|
height = split[1]
|
||||||
|
elif tag.as_vec()[1] == "model":
|
||||||
|
model = tag.as_vec()[2]
|
||||||
|
elif tag.as_vec()[1] == "quality":
|
||||||
|
quality = tag.as_vec()[2]
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"prompt": prompt,
|
||||||
|
"model": self.model,
|
||||||
|
"aspect_ratio": width + ":" + height,
|
||||||
|
"number": 1
|
||||||
|
}
|
||||||
|
request_form['options'] = json.dumps(options)
|
||||||
|
|
||||||
|
return request_form
|
||||||
|
|
||||||
|
async def process(self, request_form):
|
||||||
|
try:
|
||||||
|
options = self.set_options(request_form)
|
||||||
|
|
||||||
|
import replicate
|
||||||
|
#width = int(options["size"].split("x")[0])
|
||||||
|
#height = int(options["size"].split("x")[1])
|
||||||
|
output = replicate.run(
|
||||||
|
options["model"],
|
||||||
|
input={"prompt": options["prompt"],
|
||||||
|
"cfg": 3.5,
|
||||||
|
"steps": 28,
|
||||||
|
"prompt_upsampling": True,
|
||||||
|
"aspect_ratio": options["aspect_ratio"],
|
||||||
|
"output_format": "jpg",
|
||||||
|
"output_quality": 90,
|
||||||
|
"negative_prompt": "",
|
||||||
|
"prompt_strength": 0.85,
|
||||||
|
"safety_tolerance": 5
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print(output[0])
|
||||||
|
response = requests.get(output[0])
|
||||||
|
image = Image.open(BytesIO(response.content)).convert("RGB")
|
||||||
|
image.save("./outputs/image.jpg")
|
||||||
|
result = await upload_media_to_hoster("./outputs/image.jpg")
|
||||||
|
return result
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error in Module")
|
||||||
|
raise Exception(e)
|
||||||
|
|
||||||
|
|
||||||
|
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||||
|
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||||
|
# playground or elsewhere
|
||||||
|
def build_example(name, identifier, admin_config):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
|
||||||
|
"about": "I use Replicate to run StableDiffusion 3",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"ratio": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1:1" , "3:2", "4:5"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
return ImageGenerationReplicate(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
process_venv(ImageGenerationReplicate)
|
166
nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py
Normal file
166
nostr_dvm/tasks/imagegeneration_replicate_fluxpro.py
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from PIL import Image
|
||||||
|
from nostr_sdk import Kind
|
||||||
|
|
||||||
|
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||||
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
|
from nostr_dvm.utils.definitions import EventDefinitions
|
||||||
|
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
|
||||||
|
from nostr_dvm.utils.nip88_utils import NIP88Config
|
||||||
|
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
||||||
|
from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||||
|
from nostr_dvm.utils.zap_utils import get_price_per_sat
|
||||||
|
|
||||||
|
"""
|
||||||
|
This File contains a Module to generate an Image on replicate and receive results back.
|
||||||
|
|
||||||
|
Accepted Inputs: Prompt (text)
|
||||||
|
Outputs: An url to an Image
|
||||||
|
Params:
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ImageGenerationReplicateFluxPro(DVMTaskInterface):
|
||||||
|
KIND: Kind = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||||
|
TASK: str = "text-to-image"
|
||||||
|
FIX_COST: float = 120
|
||||||
|
dependencies = [("nostr-dvm", "nostr-dvm"),
|
||||||
|
("replicate", "replicate")]
|
||||||
|
|
||||||
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None,
|
||||||
|
options=None, task=None):
|
||||||
|
super().__init__(name, dvm_config, nip89config, nip88config, admin_config, options, task)
|
||||||
|
if options is not None:
|
||||||
|
self.model = options["model"]
|
||||||
|
else:
|
||||||
|
self.model = None
|
||||||
|
|
||||||
|
async def init_dvm(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
dvm_config.SCRIPT = os.path.abspath(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
async def is_input_supported(self, tags, client=None, dvm_config=None):
|
||||||
|
for tag in tags:
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_value = tag.as_vec()[1]
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type != "text":
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'output':
|
||||||
|
output = tag.as_vec()[1]
|
||||||
|
if (output == "" or
|
||||||
|
not (output == "image/png" or "image/jpg"
|
||||||
|
or output == "image/png;format=url" or output == "image/jpg;format=url")):
|
||||||
|
print("Output format not supported, skipping..")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def create_request_from_nostr_event(self, event, client=None, dvm_config=None):
|
||||||
|
request_form = {"jobID": event.id().to_hex() + "_" + self.NAME.replace(" ", "")}
|
||||||
|
prompt = ""
|
||||||
|
width = "1024"
|
||||||
|
height = "1024"
|
||||||
|
|
||||||
|
for tag in event.tags():
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type == "text":
|
||||||
|
prompt = tag.as_vec()[1]
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'param':
|
||||||
|
print("Param: " + tag.as_vec()[1] + ": " + tag.as_vec()[2])
|
||||||
|
if tag.as_vec()[1] == "size":
|
||||||
|
if len(tag.as_vec()) > 3:
|
||||||
|
width = (tag.as_vec()[2])
|
||||||
|
height = (tag.as_vec()[3])
|
||||||
|
elif len(tag.as_vec()) == 3:
|
||||||
|
split = tag.as_vec()[2].split(":")
|
||||||
|
if len(split) > 1:
|
||||||
|
width = split[0]
|
||||||
|
height = split[1]
|
||||||
|
elif tag.as_vec()[1] == "model":
|
||||||
|
model = tag.as_vec()[2]
|
||||||
|
elif tag.as_vec()[1] == "quality":
|
||||||
|
quality = tag.as_vec()[2]
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"prompt": prompt,
|
||||||
|
"size": width + "x" + height,
|
||||||
|
"number": 1
|
||||||
|
}
|
||||||
|
request_form['options'] = json.dumps(options)
|
||||||
|
|
||||||
|
return request_form
|
||||||
|
|
||||||
|
async def process(self, request_form):
|
||||||
|
try:
|
||||||
|
options = self.set_options(request_form)
|
||||||
|
|
||||||
|
import replicate
|
||||||
|
#width = int(options["size"].split("x")[0])
|
||||||
|
#height = int(options["size"].split("x")[1])
|
||||||
|
output = replicate.run(
|
||||||
|
"black-forest-labs/flux-1.1-pro",
|
||||||
|
input={"prompt": options["prompt"],
|
||||||
|
"aspect_ratio": "5:4",
|
||||||
|
"output_format": "jpg",
|
||||||
|
"output_quality": 80,
|
||||||
|
"safety_tolerance": 2,
|
||||||
|
"prompt_upsampling": True
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print(output)
|
||||||
|
response = requests.get(output)
|
||||||
|
image = Image.open(BytesIO(response.content)).convert("RGB")
|
||||||
|
image.save("./outputs/image.jpg")
|
||||||
|
result = await upload_media_to_hoster("./outputs/image.jpg")
|
||||||
|
return result
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error in Module")
|
||||||
|
raise Exception(e)
|
||||||
|
|
||||||
|
def write_text(data: str, path: str):
|
||||||
|
with open(path, 'w') as file:
|
||||||
|
file.write(data)
|
||||||
|
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||||
|
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||||
|
# playground or elsewhere
|
||||||
|
def build_example(name, identifier, admin_config):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
|
||||||
|
"about": "I use Replicate to run FluxPro",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"ratio": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1:1" , "3:2", "4:5"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
return ImageGenerationReplicateFluxPro(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
process_venv(ImageGenerationReplicateFluxPro)
|
165
nostr_dvm/tasks/imagegeneration_replicate_recraft.py
Normal file
165
nostr_dvm/tasks/imagegeneration_replicate_recraft.py
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from PIL import Image
|
||||||
|
from nostr_sdk import Kind
|
||||||
|
|
||||||
|
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface, process_venv
|
||||||
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
|
from nostr_dvm.utils.definitions import EventDefinitions
|
||||||
|
from nostr_dvm.utils.dvmconfig import DVMConfig, build_default_config
|
||||||
|
from nostr_dvm.utils.nip88_utils import NIP88Config
|
||||||
|
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
||||||
|
from nostr_dvm.utils.output_utils import upload_media_to_hoster
|
||||||
|
from nostr_dvm.utils.zap_utils import get_price_per_sat
|
||||||
|
|
||||||
|
"""
|
||||||
|
This File contains a Module to generate an Image on replicate and receive results back.
|
||||||
|
|
||||||
|
Accepted Inputs: Prompt (text)
|
||||||
|
Outputs: An url to an Image
|
||||||
|
Params:
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
class ImageGenerationReplicateRecraft(DVMTaskInterface):
|
||||||
|
KIND: Kind = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||||
|
TASK: str = "text-to-image"
|
||||||
|
FIX_COST: float = 120
|
||||||
|
dependencies = [("nostr-dvm", "nostr-dvm"),
|
||||||
|
("replicate", "replicate")]
|
||||||
|
|
||||||
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None,
|
||||||
|
options=None, task=None):
|
||||||
|
super().__init__(name, dvm_config, nip89config, nip88config, admin_config, options, task)
|
||||||
|
if options is not None:
|
||||||
|
self.model = options["model"]
|
||||||
|
else:
|
||||||
|
self.model = None
|
||||||
|
|
||||||
|
async def init_dvm(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, nip88config: NIP88Config = None,
|
||||||
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
dvm_config.SCRIPT = os.path.abspath(__file__)
|
||||||
|
|
||||||
|
|
||||||
|
async def is_input_supported(self, tags, client=None, dvm_config=None):
|
||||||
|
for tag in tags:
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_value = tag.as_vec()[1]
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type != "text":
|
||||||
|
return False
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'output':
|
||||||
|
output = tag.as_vec()[1]
|
||||||
|
if (output == "" or
|
||||||
|
not (output == "image/png" or "image/jpg"
|
||||||
|
or output == "image/png;format=url" or output == "image/jpg;format=url")):
|
||||||
|
print("Output format not supported, skipping..")
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
async def create_request_from_nostr_event(self, event, client=None, dvm_config=None):
|
||||||
|
request_form = {"jobID": event.id().to_hex() + "_" + self.NAME.replace(" ", "")}
|
||||||
|
prompt = ""
|
||||||
|
width = "1024"
|
||||||
|
height = "1024"
|
||||||
|
if self.model is None:
|
||||||
|
self.model = "stability-ai/stable-diffusion-3",
|
||||||
|
|
||||||
|
for tag in event.tags():
|
||||||
|
if tag.as_vec()[0] == 'i':
|
||||||
|
input_type = tag.as_vec()[2]
|
||||||
|
if input_type == "text":
|
||||||
|
prompt = tag.as_vec()[1]
|
||||||
|
|
||||||
|
elif tag.as_vec()[0] == 'param':
|
||||||
|
print("Param: " + tag.as_vec()[1] + ": " + tag.as_vec()[2])
|
||||||
|
if tag.as_vec()[1] == "size":
|
||||||
|
if len(tag.as_vec()) > 3:
|
||||||
|
width = (tag.as_vec()[2])
|
||||||
|
height = (tag.as_vec()[3])
|
||||||
|
elif len(tag.as_vec()) == 3:
|
||||||
|
split = tag.as_vec()[2].split(":")
|
||||||
|
if len(split) > 1:
|
||||||
|
width = split[0]
|
||||||
|
height = split[1]
|
||||||
|
elif tag.as_vec()[1] == "model":
|
||||||
|
model = tag.as_vec()[2]
|
||||||
|
elif tag.as_vec()[1] == "quality":
|
||||||
|
quality = tag.as_vec()[2]
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"prompt": prompt,
|
||||||
|
"size": width + "x" + height,
|
||||||
|
"number": 1
|
||||||
|
}
|
||||||
|
request_form['options'] = json.dumps(options)
|
||||||
|
|
||||||
|
return request_form
|
||||||
|
|
||||||
|
async def process(self, request_form):
|
||||||
|
try:
|
||||||
|
options = self.set_options(request_form)
|
||||||
|
|
||||||
|
import replicate
|
||||||
|
#width = int(options["size"].split("x")[0])
|
||||||
|
#height = int(options["size"].split("x")[1])
|
||||||
|
output = replicate.run(
|
||||||
|
"recraft-ai/recraft-v3",
|
||||||
|
input={"prompt": options["prompt"],
|
||||||
|
"size": options["size"],
|
||||||
|
"style": "any",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
print(output)
|
||||||
|
response = requests.get(output)
|
||||||
|
image = Image.open(BytesIO(response.content)).convert("RGB")
|
||||||
|
image.save("./outputs/image.jpg")
|
||||||
|
result = await upload_media_to_hoster("./outputs/image.jpg")
|
||||||
|
return result
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print("Error in Module")
|
||||||
|
raise Exception(e)
|
||||||
|
|
||||||
|
def write_text(data: str, path: str):
|
||||||
|
with open(path, 'w') as file:
|
||||||
|
file.write(data)
|
||||||
|
# We build an example here that we can call by either calling this file directly from the main directory,
|
||||||
|
# or by adding it to our playground. You can call the example and adjust it to your needs or redefine it in the
|
||||||
|
# playground or elsewhere
|
||||||
|
def build_example(name, identifier, admin_config):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
|
||||||
|
"about": "I use Replicate to run Recraft",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"ratio": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1:1" , "3:2", "4:5"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
return ImageGenerationReplicateRecraft(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
process_venv(ImageGenerationReplicateRecraft)
|
@ -105,9 +105,12 @@ def post_process_list_to_events(result):
|
|||||||
if len(result_list) == 0:
|
if len(result_list) == 0:
|
||||||
return "No results found"
|
return "No results found"
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
e_tag = Tag.parse(tag)
|
try:
|
||||||
result_str = result_str + "nostr:" + EventId.from_hex(
|
e_tag = Tag.parse(tag)
|
||||||
e_tag.as_vec()[1]).to_bech32() + "\n"
|
id = EventId.from_hex(e_tag.as_vec()[1]).to_bech32()
|
||||||
|
result_str = result_str + "nostr:" + id + "\n"
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return result_str
|
return result_str
|
||||||
|
|
||||||
|
|
||||||
@ -117,9 +120,12 @@ def post_process_list_to_users(result):
|
|||||||
if len(result_list) == 0:
|
if len(result_list) == 0:
|
||||||
return "No results found"
|
return "No results found"
|
||||||
for tag in result_list:
|
for tag in result_list:
|
||||||
p_tag = Tag.parse(tag)
|
try:
|
||||||
result_str = result_str + "nostr:" + PublicKey.parse(
|
p_tag = Tag.parse(tag)
|
||||||
p_tag.as_vec()[1]).to_bech32() + "\n"
|
key = PublicKey.parse(p_tag.as_vec()[1]).to_bech32()
|
||||||
|
result_str = result_str + "nostr:" + key + "\n"
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return result_str
|
return result_str
|
||||||
|
|
||||||
|
|
||||||
|
446
tests/otherstuff.py
Normal file
446
tests/otherstuff.py
Normal file
@ -0,0 +1,446 @@
|
|||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import threading
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import dotenv
|
||||||
|
from nostr_sdk import Keys, LogLevel, init_logger
|
||||||
|
|
||||||
|
from nostr_dvm.bot import Bot
|
||||||
|
from nostr_dvm.tasks.convert_media import MediaConverter
|
||||||
|
from nostr_dvm.tasks.discovery_bot_farms import DiscoveryBotFarms
|
||||||
|
from nostr_dvm.tasks.discovery_censor_wot import DiscoverReports
|
||||||
|
from nostr_dvm.tasks.discovery_inactive_follows import DiscoverInactiveFollows
|
||||||
|
from nostr_dvm.tasks.imagegeneration_openai_dalle import ImageGenerationDALLE
|
||||||
|
from nostr_dvm.tasks.imagegeneration_replicate import ImageGenerationReplicate
|
||||||
|
from nostr_dvm.tasks.imagegeneration_replicate_fluxpro import ImageGenerationReplicateFluxPro
|
||||||
|
from nostr_dvm.tasks.imagegeneration_replicate_recraft import ImageGenerationReplicateRecraft
|
||||||
|
from nostr_dvm.tasks.imagegeneration_replicate_sdxl import ImageGenerationReplicateSDXL
|
||||||
|
from nostr_dvm.tasks.imagegeneration_sd35_api import ImageGenerationSD35
|
||||||
|
from nostr_dvm.tasks.videogeneration_replicate_svd import VideoGenerationReplicateSVD
|
||||||
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
|
from nostr_dvm.utils.dvmconfig import build_default_config, DVMConfig
|
||||||
|
from nostr_dvm.utils.nip89_utils import NIP89Config, check_and_set_d_tag
|
||||||
|
from nostr_dvm.utils.nostr_utils import check_and_set_private_key
|
||||||
|
from nostr_dvm.utils.zap_utils import get_price_per_sat, check_and_set_ln_bits_keys
|
||||||
|
|
||||||
|
|
||||||
|
# Some other DVMs to run.
|
||||||
|
|
||||||
|
use_logger = True
|
||||||
|
log_level = LogLevel.ERROR
|
||||||
|
|
||||||
|
|
||||||
|
if use_logger:
|
||||||
|
init_logger(log_level)
|
||||||
|
|
||||||
|
def build_sd35(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
|
||||||
|
dvm_config.NEW_USER_BALANCE = 0
|
||||||
|
dvm_config.USE_OWN_VENV = False
|
||||||
|
dvm_config.ENABLE_NUTZAP = False
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://i.nostr.build/NOXcCIPmOZrDTK35.jpg",
|
||||||
|
"about": "I draw images using Stable diffusion ultra",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"negative_prompt": {
|
||||||
|
"required": False,
|
||||||
|
"values": []
|
||||||
|
},
|
||||||
|
"ratio": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1:1", "5:4", "3:2", "16:9","21:9", "9:21", "9:16", "2:3", "4:5"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
|
||||||
|
nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
aconfig = AdminConfig()
|
||||||
|
aconfig.REBROADCAST_NIP89 = announce # We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
|
||||||
|
aconfig.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
aconfig.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
aconfig.PRIVKEY = dvm_config.PRIVATE_KEY
|
||||||
|
aconfig.MELT_ON_STARTUP = False # set this to true to melt cashu tokens to our ln address on startup
|
||||||
|
|
||||||
|
|
||||||
|
options= {"API_KEY": os.getenv("STABILITY_KEY")}
|
||||||
|
|
||||||
|
|
||||||
|
return ImageGenerationSD35(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=aconfig, options=options)
|
||||||
|
|
||||||
|
def build_dalle(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
dvm_config.NEW_USER_BALANCE = 0
|
||||||
|
dvm_config.USE_OWN_VENV = True
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/22f2267ca9d4ee9d5e8a0c7818a9fa325bbbcdac5573a60a2d163e699bb69923.jpg",
|
||||||
|
"about": "I create Images bridging OpenAI's DALL·E 3",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"size": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1024:1024", "1024x1792", "1792x1024"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
|
||||||
|
nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
# We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
|
||||||
|
return ImageGenerationDALLE(name=name, dvm_config=dvm_config, nip89config=nip89config, admin_config=admin_config)
|
||||||
|
|
||||||
|
def build_svd(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
dvm_config.USE_OWN_VENV = False
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
profit_in_sats = 10
|
||||||
|
cost_in_cent = 4.0
|
||||||
|
dvm_config.FIX_COST = int(((cost_in_cent / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/c33ca6fc4cc038ca4adb46fdfdfda34951656f87ee364ef59095bae1495ce669.jpg",
|
||||||
|
"about": "I use Stable Video Diffusion to create short videos",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
|
||||||
|
nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
# We add an optional AdminConfig for this one, and tell the dvm to rebroadcast its NIP89
|
||||||
|
return VideoGenerationReplicateSVD(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
def build_media_converter(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://cdn.nostr.build/i/a177be1159da5aad8396a1188f686728d55647d3a7371549584daf2b5e50eec9.jpg",
|
||||||
|
"about": "I convert videos from urls to given output format.",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"media_format": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["video/mp4", "audio/mp3"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
return MediaConverter(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
def build_inactive_follows_finder(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
dvm_config.USE_OWN_VENV = False
|
||||||
|
dvm_config.FIX_COST = 0
|
||||||
|
|
||||||
|
# Add NIP89
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/50621bbf8082c478bc06a06684e1c443b5d37f1362ad56d679cab7328e0481db.jpg",
|
||||||
|
"about": "I discover npubs you follow, but that have been inactive on Nostr for the last 90 days",
|
||||||
|
"action": "unfollow",
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"user": {
|
||||||
|
"required": False,
|
||||||
|
"values": [],
|
||||||
|
"description": "Do the task for another user"
|
||||||
|
},
|
||||||
|
"since_days": {
|
||||||
|
"required": False,
|
||||||
|
"values": [],
|
||||||
|
"description": "The number of days a user has not been active to be considered inactive"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY,
|
||||||
|
nip89info["image"])
|
||||||
|
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
return DiscoverInactiveFollows(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
def build_1984(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
dvm_config.USE_OWN_VENV = False
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
# Add NIP89
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/19872a2edd866258fa9eab137631efda89310d52b2c6ea8f99ef057325aa1c7b.jpg",
|
||||||
|
"about": "I show users that have been reported by either your followers or your Web of Trust. Note: Anyone can report, so you might double check and decide for yourself who to mute. Considers spam, illegal and impersonation reports. Notice: This works with NIP51 mute lists. Not all clients support the new mute list format.",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"action": "mute", # follow, unfollow, mute, unmute
|
||||||
|
"nip90Params": {
|
||||||
|
"since_days": {
|
||||||
|
"required": False,
|
||||||
|
"values": [],
|
||||||
|
"description": "The number of days a report is ago in order to be considered "
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
return DiscoverReports(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
def build_botfarms(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
dvm_config.USE_OWN_VENV = False
|
||||||
|
dvm_config.SHOWLOG = True
|
||||||
|
dvm_config.SCHEDULE_UPDATES_SECONDS = 600 # Every 10 seconds
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
# Add NIP89
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://image.nostr.build/981b560820bc283c58de7989b7abc6664996b487a531d852e4ef7322586a2122.jpg",
|
||||||
|
"about": "I hunt down bot farms.",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"action": "mute", # follow, unfollow, mute, unmute
|
||||||
|
"nip90Params": {
|
||||||
|
"max_results": {
|
||||||
|
"required": False,
|
||||||
|
"values": [],
|
||||||
|
"description": "The number of maximum results to return (default currently 20)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
options = {"relay": "wss://relay.damus.io"}
|
||||||
|
|
||||||
|
return DiscoveryBotFarms(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config, options=options)
|
||||||
|
|
||||||
|
def build_replicate(name, identifier, model, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://i.nostr.build/qnoBIN4jSkfF8IHk.png",
|
||||||
|
"about": "I use Replicate to run StableDiffusion XL",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"size": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1024:1024", "1024x1792", "1792x1024"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
opts = {"model": model}
|
||||||
|
|
||||||
|
return ImageGenerationReplicate(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config, options=opts)
|
||||||
|
|
||||||
|
|
||||||
|
def build_replicate_recraft(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://i.nostr.build/jSbrXvYglXCzSeAc.jpg",
|
||||||
|
"about": "I use Replicate to run Recraft v3",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"size": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["1024:1024"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
|
||||||
|
return ImageGenerationReplicateRecraft(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
def build_replicate_fluxpro(name, identifier, announce):
|
||||||
|
dvm_config = build_default_config(identifier)
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
admin_config.LUD16 = dvm_config.LN_ADDRESS
|
||||||
|
admin_config.REBROADCAST_NIP89 = announce
|
||||||
|
admin_config.REBROADCAST_NIP65_RELAY_LIST = announce
|
||||||
|
|
||||||
|
profit_in_sats = 10
|
||||||
|
dvm_config.FIX_COST = int(((4.0 / (get_price_per_sat("USD") * 100)) + profit_in_sats))
|
||||||
|
|
||||||
|
nip89info = {
|
||||||
|
"name": name,
|
||||||
|
"image": "https://i.nostr.build/AQTujqzVmLxLmG16.jpg",
|
||||||
|
"about": "I use Replicate to FluxPro 1.1.",
|
||||||
|
"encryptionSupported": True,
|
||||||
|
"cashuAccepted": True,
|
||||||
|
"nip90Params": {
|
||||||
|
"size": {
|
||||||
|
"required": False,
|
||||||
|
"values": ["5:4"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nip89config = NIP89Config()
|
||||||
|
nip89config.DTAG = check_and_set_d_tag(identifier, name, dvm_config.PRIVATE_KEY, nip89info["image"])
|
||||||
|
nip89config.CONTENT = json.dumps(nip89info)
|
||||||
|
|
||||||
|
|
||||||
|
return ImageGenerationReplicateFluxPro(name=name, dvm_config=dvm_config, nip89config=nip89config,
|
||||||
|
admin_config=admin_config)
|
||||||
|
|
||||||
|
|
||||||
|
def playground(announce=False):
|
||||||
|
#bot_config = DVMConfig()
|
||||||
|
bot_config = build_default_config("bot")
|
||||||
|
#bot_config.PRIVATE_KEY = check_and_set_private_key("bot")
|
||||||
|
#npub = Keys.parse(bot_config.PRIVATE_KEY).public_key().to_bech32()
|
||||||
|
#invoice_key, admin_key, wallet_id, lnaddress = check_and_set_ln_bits_keys("bot",npub)
|
||||||
|
#bot_config.LNBITS_INVOICE_KEY = invoice_key
|
||||||
|
#bot_config.LNBITS_ADMIN_KEY = admin_key # The dvm might pay failed jobs back
bot_config.LNBITS_URL = os.getenv("LNBITS_HOST")
|
||||||
|
|
||||||
|
if os.getenv("OPENAI_API_KEY") is not None and os.getenv("OPENAI_API_KEY") != "":
|
||||||
|
dalle = build_dalle("Dall-E 3", "dalle3", announce)
|
||||||
|
bot_config.SUPPORTED_DVMS.append(dalle)
|
||||||
|
dalle.run()
|
||||||
|
if os.getenv("STABILITY_KEY") is not None and os.getenv("STABILITY_KEY") != "":
|
||||||
|
sd35 = build_sd35("Stable Diffusion Ultra", "sd35", announce)
|
||||||
|
sd35.run()
|
||||||
|
|
||||||
|
if os.getenv("REPLICATE_API_TOKEN") is not None and os.getenv("REPLICATE_API_TOKEN") != "":
|
||||||
|
model = "stability-ai/stable-diffusion-3.5-large"
|
||||||
|
sd3replicate = build_replicate("Stable Diffusion 3.5 Large", "replicate_svd", model, announce)
|
||||||
|
bot_config.SUPPORTED_DVMS.append(sd3replicate)
|
||||||
|
sd3replicate.run()
|
||||||
|
|
||||||
|
model = "black-forest-labs/flux-1.1-pro"
|
||||||
|
fluxreplicate = build_replicate_fluxpro("Flux 1.1. Pro", "fluxpro", announce)
|
||||||
|
bot_config.SUPPORTED_DVMS.append(fluxreplicate)
|
||||||
|
fluxreplicate.run()
|
||||||
|
|
||||||
|
recraftreplicate = build_replicate_recraft("Recraft v3", "recraftsvg", announce)
|
||||||
|
bot_config.SUPPORTED_DVMS.append(recraftreplicate)
|
||||||
|
recraftreplicate.run()
|
||||||
|
|
||||||
|
|
||||||
|
media_bringer = build_media_converter("Nostr AI DVM Media Converter", "media_converter", announce)
|
||||||
|
#bot_config.SUPPORTED_DVMS.append(media_bringer)
|
||||||
|
media_bringer.run()
|
||||||
|
|
||||||
|
|
||||||
|
discover_inactive = build_inactive_follows_finder("Those who left", "discovery_inactive_follows", announce)
|
||||||
|
bot_config.SUPPORTED_DVMS.append(discover_inactive)
|
||||||
|
discover_inactive.run()
|
||||||
|
|
||||||
|
|
||||||
|
discovery_censor = build_1984("Censorship 1984", "discovery_censor", announce)
|
||||||
|
#bot_config.SUPPORTED_DVMS.append(discovery_censor)
|
||||||
|
discovery_censor.run()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
discovery_bots = build_botfarms("Bot Hunter", "discovery_botfarms", announce)
|
||||||
|
#bot_config.SUPPORTED_DVMS.append(discovery_bots)
|
||||||
|
discovery_bots.run()
|
||||||
|
|
||||||
|
|
||||||
|
admin_config = AdminConfig()
|
||||||
|
#admin_config.REBROADCAST_NIP65_RELAY_LIST = True
|
||||||
|
x = threading.Thread(target=Bot, args=([bot_config, admin_config]))
|
||||||
|
x.start()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
env_path = Path('.env')
|
||||||
|
if not env_path.is_file():
|
||||||
|
with open('.env', 'w') as f:
|
||||||
|
print("Writing new .env file")
|
||||||
|
f.write('')
|
||||||
|
if env_path.is_file():
|
||||||
|
print(f'loading environment from {env_path.resolve()}')
|
||||||
|
dotenv.load_dotenv(env_path, verbose=True, override=True)
|
||||||
|
else:
|
||||||
|
raise FileNotFoundError(f'.env file not found at {env_path} ')
|
||||||
|
announce = False
|
||||||
|
playground(announce)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user