mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 16:37:30 +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$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv_package_test" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv_package_test2" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.10 (dvm) (3)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,5 +3,5 @@
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.10 (dvm)" />
|
||||
</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>
|
||||
@@ -1,12 +1,14 @@
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from threading import Thread
|
||||
|
||||
from nostr_sdk import Keys
|
||||
|
||||
from nostr_dvm.dvm import DVM
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
from nostr_dvm.utils.dvmconfig import DVMConfig
|
||||
from nostr_dvm.utils.nip89_utils import NIP89Config
|
||||
from nostr_dvm.dvm import DVM
|
||||
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.
|
||||
dvm_config: DVMConfig
|
||||
admin_config: AdminConfig
|
||||
dependencies = []
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config, admin_config: AdminConfig = None,
|
||||
options=None, task=None):
|
||||
self.init(name, dvm_config, admin_config, nip89config, task)
|
||||
self.options = options
|
||||
self.install_dependencies(self.dependencies)
|
||||
|
||||
def init(self, name, dvm_config, admin_config=None, nip89config=None, task=None):
|
||||
self.NAME = name
|
||||
@@ -80,6 +84,13 @@ class DVMTaskInterface:
|
||||
"""Post-process the data and return the result Use default function, if not overwritten"""
|
||||
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
|
||||
def set_options(request_form):
|
||||
|
||||
@@ -30,6 +30,7 @@ class ImageGenerationDALLE(DVMTaskInterface):
|
||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||
TASK: str = "text-to-image"
|
||||
FIX_COST: float = 120
|
||||
dependencies = ["openai==1.3.5"]
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||
admin_config: AdminConfig = None, options=None):
|
||||
|
||||
@@ -31,6 +31,7 @@ class ImageGenerationReplicateSDXL(DVMTaskInterface):
|
||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_IMAGE
|
||||
TASK: str = "text-to-image"
|
||||
FIX_COST: float = 120
|
||||
dependencies = ["replicate==0.21.1"]
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||
admin_config: AdminConfig = None, options=None):
|
||||
|
||||
@@ -28,11 +28,14 @@ class TextExtractionPDF(DVMTaskInterface):
|
||||
KIND: int = EventDefinitions.KIND_NIP90_EXTRACT_TEXT
|
||||
TASK: str = "pdf-to-text"
|
||||
FIX_COST: float = 0
|
||||
dependencies = ["pypdf==3.17.1"]
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||
admin_config: AdminConfig = None, options=None):
|
||||
super().__init__(name, dvm_config, nip89config, admin_config, options)
|
||||
|
||||
|
||||
|
||||
def is_input_supported(self, tags):
|
||||
for tag in tags:
|
||||
if tag.as_vec()[0] == 'i':
|
||||
|
||||
@@ -3,7 +3,7 @@ import os
|
||||
from pathlib import Path
|
||||
|
||||
import dotenv
|
||||
from litellm import completion
|
||||
|
||||
|
||||
from nostr_dvm.interfaces.dvmtaskinterface import DVMTaskInterface
|
||||
from nostr_dvm.utils.admin_utils import AdminConfig
|
||||
@@ -27,6 +27,7 @@ class TextGenerationOLLAMA(DVMTaskInterface):
|
||||
KIND: int = EventDefinitions.KIND_NIP90_GENERATE_TEXT
|
||||
TASK: str = "text-to-text"
|
||||
FIX_COST: float = 0
|
||||
dependencies = ["litellm==1.12.3"]
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||
admin_config: AdminConfig = None, options=None):
|
||||
@@ -71,6 +72,8 @@ class TextGenerationOLLAMA(DVMTaskInterface):
|
||||
return request_form
|
||||
|
||||
def process(self, request_form):
|
||||
from litellm import completion
|
||||
|
||||
options = DVMTaskInterface.set_options(request_form)
|
||||
|
||||
try:
|
||||
|
||||
@@ -27,6 +27,7 @@ class TranslationGoogle(DVMTaskInterface):
|
||||
KIND: int = EventDefinitions.KIND_NIP90_TRANSLATE_TEXT
|
||||
TASK: str = "translation"
|
||||
FIX_COST: float = 0
|
||||
dependencies = ["translatepy==2.3"]
|
||||
|
||||
def __init__(self, name, dvm_config: DVMConfig, nip89config: NIP89Config,
|
||||
admin_config: AdminConfig = None, options=None):
|
||||
|
||||
22
setup.py
22
setup.py
@@ -6,17 +6,29 @@ LONG_DESCRIPTION = '-'
|
||||
|
||||
# Setting up
|
||||
setup(
|
||||
# the name must match the folder name 'verysimplemodule'
|
||||
name="nostr-dvm",
|
||||
version=VERSION,
|
||||
author="Believethehype",
|
||||
author_email="-",
|
||||
description=DESCRIPTION,
|
||||
long_description=LONG_DESCRIPTION,
|
||||
packages=find_packages(),
|
||||
install_requires=[], # add any additional packages that
|
||||
# needs to be installed along with your package. Eg: 'caer'
|
||||
|
||||
packages=find_packages(include=['nostr_dvm']),
|
||||
install_requires=["nostr-sdk==0.0.5",
|
||||
"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'],
|
||||
classifiers=[
|
||||
"Development Status :: 3 - Alpha",
|
||||
|
||||
Reference in New Issue
Block a user