mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 20:41:33 +01:00
added dependencies (and dependencies per task)
This commit is contained in:
4
.idea/dvm.iml
generated
4
.idea/dvm.iml
generated
@@ -4,8 +4,10 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
|
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv_package_test" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv_package_test2" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="jdk" jdkName="Python 3.10 (dvm) (3)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,5 +3,5 @@
|
|||||||
<component name="Black">
|
<component name="Black">
|
||||||
<option name="sdkName" value="Python 3.10 (dvm)" />
|
<option name="sdkName" value="Python 3.10 (dvm)" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (dvm) (2)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (dvm) (3)" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
import json
|
import json
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from nostr_sdk import Keys
|
from nostr_sdk import Keys
|
||||||
|
|
||||||
|
from nostr_dvm.dvm import DVM
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||||
from nostr_dvm.utils.nip89_utils import NIP89Config
|
from nostr_dvm.utils.nip89_utils import NIP89Config
|
||||||
from nostr_dvm.dvm import DVM
|
|
||||||
from nostr_dvm.utils.output_utils import post_process_result
|
from nostr_dvm.utils.output_utils import post_process_result
|
||||||
|
|
||||||
|
|
||||||
@@ -23,11 +25,13 @@ class DVMTaskInterface:
|
|||||||
ACCEPTS_CASHU = True # DVMs build with this framework support encryption, but others might not.
|
ACCEPTS_CASHU = True # DVMs build with this framework support encryption, but others might not.
|
||||||
dvm_config: DVMConfig
|
dvm_config: DVMConfig
|
||||||
admin_config: AdminConfig
|
admin_config: AdminConfig
|
||||||
|
dependencies = []
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, admin_config: AdminConfig = None,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, admin_config: AdminConfig = None,
|
||||||
options=None, task=None):
|
options=None, task=None):
|
||||||
self.init(name, dvm_config, admin_config, nip89config, task)
|
self.init(name, dvm_config, admin_config, nip89config, task)
|
||||||
self.options = options
|
self.options = options
|
||||||
|
self.install_dependencies(self.dependencies)
|
||||||
|
|
||||||
def init(self, name, dvm_config, admin_config=None, nip89config=None, task=None):
|
def init(self, name, dvm_config, admin_config=None, nip89config=None, task=None):
|
||||||
self.NAME = name
|
self.NAME = name
|
||||||
@@ -80,6 +84,13 @@ class DVMTaskInterface:
|
|||||||
"""Post-process the data and return the result Use default function, if not overwritten"""
|
"""Post-process the data and return the result Use default function, if not overwritten"""
|
||||||
return post_process_result(result, event)
|
return post_process_result(result, event)
|
||||||
|
|
||||||
|
def install_dependencies(self, packages):
|
||||||
|
import pip
|
||||||
|
for package in packages:
|
||||||
|
try:
|
||||||
|
__import__(package.split("=")[0])
|
||||||
|
except ImportError:
|
||||||
|
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_options(request_form):
|
def set_options(request_form):
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class ImageGenerationDALLE(DVMTaskInterface):
|
|||||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||||
TASK: str = "text-to-image"
|
TASK: str = "text-to-image"
|
||||||
FIX_COST: float = 120
|
FIX_COST: float = 120
|
||||||
|
dependencies = ["openai==1.3.5"]
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class ImageGenerationReplicateSDXL(DVMTaskInterface):
|
|||||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||||
TASK: str = "text-to-image"
|
TASK: str = "text-to-image"
|
||||||
FIX_COST: float = 120
|
FIX_COST: float = 120
|
||||||
|
dependencies = ["replicate==0.21.1"]
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
|||||||
@@ -28,11 +28,14 @@ class TextExtractionPDF(DVMTaskInterface):
|
|||||||
KIND: int = EventDefinitions.KIND_NIP90_EXTRACT_TEXT
|
KIND: int = EventDefinitions.KIND_NIP90_EXTRACT_TEXT
|
||||||
TASK: str = "pdf-to-text"
|
TASK: str = "pdf-to-text"
|
||||||
FIX_COST: float = 0
|
FIX_COST: float = 0
|
||||||
|
dependencies = ["pypdf==3.17.1"]
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
super().__init__(name, dvm_config, nip89config, admin_config, options)
|
super().__init__(name, dvm_config, nip89config, admin_config, options)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_input_supported(self, tags):
|
def is_input_supported(self, tags):
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
if tag.as_vec()[0] == 'i':
|
if tag.as_vec()[0] == 'i':
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import dotenv
|
import dotenv
|
||||||
from litellm import completion
|
|
||||||
|
|
||||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface
|
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface
|
||||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||||
@@ -27,6 +27,7 @@ class TextGenerationOLLAMA(DVMTaskInterface):
|
|||||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_TEXT
|
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_TEXT
|
||||||
TASK: str = "text-to-text"
|
TASK: str = "text-to-text"
|
||||||
FIX_COST: float = 0
|
FIX_COST: float = 0
|
||||||
|
dependencies = ["litellm==1.12.3"]
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
@@ -71,6 +72,8 @@ class TextGenerationOLLAMA(DVMTaskInterface):
|
|||||||
return request_form
|
return request_form
|
||||||
|
|
||||||
def process(self, request_form):
|
def process(self, request_form):
|
||||||
|
from litellm import completion
|
||||||
|
|
||||||
options = DVMTaskInterface.set_options(request_form)
|
options = DVMTaskInterface.set_options(request_form)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class TranslationGoogle(DVMTaskInterface):
|
|||||||
KIND: int = EventDefinitions.KIND_NIP90_TRANSLATE_TEXT
|
KIND: int = EventDefinitions.KIND_NIP90_TRANSLATE_TEXT
|
||||||
TASK: str = "translation"
|
TASK: str = "translation"
|
||||||
FIX_COST: float = 0
|
FIX_COST: float = 0
|
||||||
|
dependencies = ["translatepy==2.3"]
|
||||||
|
|
||||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||||
admin_config: AdminConfig = None, options=None):
|
admin_config: AdminConfig = None, options=None):
|
||||||
|
|||||||
22
setup.py
22
setup.py
@@ -6,17 +6,29 @@ LONG_DESCRIPTION = '-'
|
|||||||
|
|
||||||
# Setting up
|
# Setting up
|
||||||
setup(
|
setup(
|
||||||
# the name must match the folder name 'verysimplemodule'
|
|
||||||
name="nostr-dvm",
|
name="nostr-dvm",
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
author="Believethehype",
|
author="Believethehype",
|
||||||
author_email="-",
|
author_email="-",
|
||||||
description=DESCRIPTION,
|
description=DESCRIPTION,
|
||||||
long_description=LONG_DESCRIPTION,
|
long_description=LONG_DESCRIPTION,
|
||||||
packages=find_packages(),
|
packages=find_packages(include=['nostr_dvm']),
|
||||||
install_requires=[], # add any additional packages that
|
install_requires=["nostr-sdk==0.0.5",
|
||||||
# needs to be installed along with your package. Eg: 'caer'
|
"bech32==1.2.0",
|
||||||
|
"pycryptodome==3.19.0",
|
||||||
|
"python-dotenv==1.0.0",
|
||||||
|
"emoji==2.8.0",
|
||||||
|
"eva-decord==0.6.1",
|
||||||
|
"ffmpegio==0.8.5",
|
||||||
|
"lnurl==0.4.1",
|
||||||
|
"pandas==2.1.3",
|
||||||
|
"Pillow==10.1.0",
|
||||||
|
"PyUpload==0.1.4",
|
||||||
|
"requests==2.31.0",
|
||||||
|
"instaloader==4.10.1",
|
||||||
|
"pytube==15.0.0",
|
||||||
|
"moviepy==2.0.0.dev2"
|
||||||
|
],
|
||||||
keywords=['nostr', 'nip90', 'dvm', 'data vending machine'],
|
keywords=['nostr', 'nip90', 'dvm', 'data vending machine'],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
|
|||||||
Reference in New Issue
Block a user